aboutsummaryrefslogtreecommitdiffstats
path: root/executor/shmem.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-06-04 12:55:41 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-06-24 09:57:34 +0000
commite16e2c9a4cb6937323e861b646792a6c4c978a3c (patch)
tree6c513e98e5f465b44a98546d8984485d2c128582 /executor/shmem.h
parent90d67044dab68568e8f35bc14b68055dbd166eff (diff)
executor: add runner mode
Move all syz-fuzzer logic into syz-executor and remove syz-fuzzer. Also restore syz-runtest functionality in the manager. Update #4917 (sets most signal handlers to SIG_IGN)
Diffstat (limited to 'executor/shmem.h')
-rw-r--r--executor/shmem.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/executor/shmem.h b/executor/shmem.h
index ab9d17300..b7722ff99 100644
--- a/executor/shmem.h
+++ b/executor/shmem.h
@@ -3,6 +3,7 @@
#include <fcntl.h>
#include <stddef.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
@@ -10,20 +11,22 @@
class ShmemFile
{
public:
- // Maps shared memory region of size 'size' from a new file 'file', preferably at the address 'preferred'.
- ShmemFile(const char* file, void* preferred, size_t size)
+ // Maps shared memory region of size 'size' from a new temp file.
+ ShmemFile(size_t size)
{
- fd_ = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600);
+ char file_name[] = "syz.XXXXXX";
+ fd_ = mkstemp(file_name);
if (fd_ == -1)
- failmsg("shmem open failed", "file=%s", file);
- if (fallocate(fd_, 0, 0, size))
+ failmsg("shmem open failed", "file=%s", file_name);
+ if (posix_fallocate(fd_, 0, size))
failmsg("shmem fallocate failed", "size=%zu", size);
- Mmap(fd_, preferred, size, true);
- if (unlink(file))
+ Mmap(fd_, nullptr, size, true);
+ if (unlink(file_name))
fail("shmem unlink failed");
}
- // Maps shared memory region from the file 'fd' in read/write or write-only mode.
+ // Maps shared memory region from the file 'fd' in read/write or write-only mode,
+ // preferably at the address 'preferred'.
ShmemFile(int fd, void* preferred, size_t size, bool write)
{
Mmap(fd, preferred, size, write);