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 --- pkg/csource/csource_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index ce2db21c0..773ff2ed8 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -67,9 +67,16 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { rs := rand.NewSource(seed) t.Logf("seed=%v", seed) p := target.Generate(rs, 10, nil) - p.Calls = append(p.Calls, target.GenerateAllSyzProg(rs).Calls...) + // Turns out that fully minimized program can trigger new interesting warnings, + // e.g. about NULL arguments for functions that require non-NULL arguments in syz_ functions. + // We could append both AllSyzProg as-is and a minimized version of it, + // but this makes the NULL argument warnings go away (they showed up in ".constprop" versions). + // Testing 2 programs takes too long since we have lots of options permutations and OS/arch. + // So we use the as-is in short tests and minimized version in full tests. + syzProg := target.GenerateAllSyzProg(rs) var opts []Options if !full || testing.Short() { + p.Calls = append(p.Calls, syzProg.Calls...) opts = allOptionsSingle(target.OS) // This is the main configuration used by executor, // so we want to test it as well. @@ -83,6 +90,10 @@ func testTarget(t *testing.T, target *prog.Target, full bool) { UseTmpDir: true, }) } else { + minimized, _ := prog.Minimize(syzProg, -1, false, func(p *prog.Prog, call int) bool { + return len(p.Calls) == len(syzProg.Calls) + }) + p.Calls = append(p.Calls, minimized.Calls...) opts = allOptionsPermutations(target.OS) } for opti, opts := range opts { -- cgit mrf-deployment