From 8fbce0e4423f701145e111531f6f41cc02e086cf Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 30 Mar 2018 20:04:20 +0200 Subject: 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. --- executor/common_linux.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'executor') diff --git a/executor/common_linux.h b/executor/common_linux.h index dbe75f10f..ef4c5ce1a 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -814,18 +814,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 //syz_mount_image(fs ptr[in, string[disk_filesystems]], dir ptr[in, filename], size intptr, nsegs len[segments], segments ptr[in, array[fs_image_segment]], flags flags[mount_flags], opts ptr[in, fs_options[vfat_options]]) @@ -858,7 +856,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; @@ -869,7 +867,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); @@ -1024,10 +1022,6 @@ static void sandbox_common() rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); -#ifndef CLONE_NEWCGROUP -#define CLONE_NEWCGROUP 0x02000000 -#endif - // CLONE_NEWNS/NEWCGROUP cause EINVAL on some systems, // so we do them separately of clone in do_sandbox_namespace. if (unshare(CLONE_NEWNS)) { @@ -1036,7 +1030,7 @@ static void sandbox_common() 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)) { -- cgit mrf-deployment