aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_darwin.h
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2021-12-02 10:39:37 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2021-12-03 12:32:03 +0100
commitc7c20675f58e3edaa53538928c0963144fd524e5 (patch)
tree0552f0896774be7b0d933e95432e63ff8ef13ba4 /executor/executor_darwin.h
parent6df0f018b545aaf2b9bbcfde8b6e530cf90da9be (diff)
executor: reserve fds that will belong to kcov
As now kcov instances may get set up during fuzzing, performing dup2 in cover_open is no longer safe as it may close some important resource. Prevent that by reserving most of fds that belong to the kcov fds range. Unfortunately we must duplicate the code because of the way kcov implementations are organized.
Diffstat (limited to 'executor/executor_darwin.h')
-rw-r--r--executor/executor_darwin.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/executor/executor_darwin.h b/executor/executor_darwin.h
index c16691663..d6efe0063 100644
--- a/executor/executor_darwin.h
+++ b/executor/executor_darwin.h
@@ -121,3 +121,11 @@ static bool use_cover_edges(uint64 pc)
{
return true;
}
+
+static void cover_reserve_fd(cover_t* cov)
+{
+ int fd = open("/dev/null", O_RDONLY);
+ if (fd < 0)
+ fail("failed to open /dev/null");
+ dup2(fd, cov->fd);
+}