aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/linux_common.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-03-30 20:04:20 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-03-30 20:08:05 +0200
commit8fbce0e4423f701145e111531f6f41cc02e086cf (patch)
tree5843ecc545550778645e1b4e32a80b2e0000a196 /pkg/csource/linux_common.go
parent7c923cf8d45b650c4251503c11e74653779c74c4 (diff)
executor: fix compilation warnings
SYS_memfd_create define produces warning in scource if system headers already contain the definition (we strip all ifdefs!). The same is true for CLONE_NEWCGROUP but we just never hit it yet. Also fix format string for 32 bits. Also fix potential uninit var in csource, and a missing new line.
Diffstat (limited to 'pkg/csource/linux_common.go')
-rw-r--r--pkg/csource/linux_common.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/pkg/csource/linux_common.go b/pkg/csource/linux_common.go
index c9c8e871e..1646401da 100644
--- a/pkg/csource/linux_common.go
+++ b/pkg/csource/linux_common.go
@@ -933,18 +933,16 @@ struct fs_image_segment {
#define IMAGE_MAX_SEGMENTS 4096
#define IMAGE_MAX_SIZE (32 << 20)
-#ifndef SYS_memfd_create
#if defined(__i386__)
-#define SYS_memfd_create 356
+#define SYZ_memfd_create 356
#elif defined(__x86_64__)
-#define SYS_memfd_create 319
+#define SYZ_memfd_create 319
#elif defined(__arm__)
-#define SYS_memfd_create 385
+#define SYZ_memfd_create 385
#elif defined(__aarch64__)
-#define SYS_memfd_create 279
+#define SYZ_memfd_create 279
#elif defined(__ppc64__) || defined(__PPC64__) || defined(__powerpc64__)
-#define SYS_memfd_create 360
-#endif
+#define SYZ_memfd_create 360
#endif
static uintptr_t syz_mount_image(uintptr_t fs, uintptr_t dir, uintptr_t size, uintptr_t nsegs, uintptr_t segments, uintptr_t flags, uintptr_t opts)
@@ -967,7 +965,7 @@ static uintptr_t syz_mount_image(uintptr_t fs, uintptr_t dir, uintptr_t size, ui
}
if (size > IMAGE_MAX_SIZE)
size = IMAGE_MAX_SIZE;
- int memfd = syscall(SYS_memfd_create, "syz_mount_image", 0);
+ int memfd = syscall(SYZ_memfd_create, "syz_mount_image", 0);
if (memfd == -1) {
err = errno;
goto error;
@@ -978,7 +976,7 @@ static uintptr_t syz_mount_image(uintptr_t fs, uintptr_t dir, uintptr_t size, ui
}
for (i = 0; i < nsegs; i++) {
if (pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset) < 0) {
- debug("syz_mount_image: pwrite[%lu] failed: %d\n", i, errno);
+ debug("syz_mount_image: pwrite[%u] failed: %d\n", (int)i, errno);
}
}
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
@@ -2085,17 +2083,13 @@ static void sandbox_common()
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
-#ifndef CLONE_NEWCGROUP
-#define CLONE_NEWCGROUP 0x02000000
-#endif
-
if (unshare(CLONE_NEWNS)) {
debug("unshare(CLONE_NEWNS): %d\n", errno);
}
if (unshare(CLONE_NEWIPC)) {
debug("unshare(CLONE_NEWIPC): %d\n", errno);
}
- if (unshare(CLONE_NEWCGROUP)) {
+ if (unshare(0x02000000)) {
debug("unshare(CLONE_NEWCGROUP): %d\n", errno);
}
if (unshare(CLONE_NEWUTS)) {