From 44270612b458144e4c3e881bac376d32bb395ee8 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 21 Mar 2019 13:17:23 +0100 Subject: executor: prevent non-null expected warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The added test triggers warnings like these: : In function ‘syz_mount_image.constprop’: :298:3: error: argument 1 null where non-null expected [-Werror=nonnull] In file included from :26:0: /usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here extern int mkdir (const char *__path, __mode_t __mode) ^~~~~ cc1: all warnings being treated as errors : In function ‘syz_open_procfs.constprop’: :530:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] :85:110: note: in definition of macro ‘NONFAILING’ :532:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] :85:110: note: in definition of macro ‘NONFAILING’ :534:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] :85:110: note: in definition of macro ‘NONFAILING’ Use volatile for all arguments of syz_ functions to prevent compiler from treating the arguments as constants in reproducers. Popped up during bisection that used a repro that previously worked. Update #501 --- executor/common_test.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'executor/common_test.h') diff --git a/executor/common_test.h b/executor/common_test.h index 826d2c8d8..428ea2ce1 100644 --- a/executor/common_test.h +++ b/executor/common_test.h @@ -10,7 +10,7 @@ #include // syz_mmap(addr vma, len len[addr]) -static long syz_mmap(long a0, long a1) +static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } @@ -20,7 +20,7 @@ static long syz_mmap(long a0, long a1) #include // syz_errno(v int32) -static long syz_errno(long v) +static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; @@ -29,7 +29,7 @@ static long syz_errno(long v) #if SYZ_EXECUTOR || __NR_syz_exit // syz_exit(status int32) -static long syz_exit(long status) +static long syz_exit(volatile long status) { _exit(status); return 0; @@ -41,7 +41,7 @@ static long syz_exit(long status) #include // syz_compare(want ptr[in, string], want_len len[want], got ptr[in, compare_data], got_len len[got]) -static long syz_compare(long want, long want_len, long got, long got_len) +static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { debug("syz_compare: want_len=%lu got_len=%lu\n", want_len, got_len); @@ -65,7 +65,7 @@ static long syz_compare(long want, long want_len, long got, long got_len) #include // syz_compare_int$4(n const[2], v0 intptr, v1 intptr, v2 intptr, v3 intptr) -static long syz_compare_int(long n, ...) +static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); -- cgit mrf-deployment