diff options
author | Kees Cook <keescook@chromium.org> | 2024-04-29 12:43:40 -0700 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2024-04-30 10:34:29 -0700 |
commit | 091f79e8de44736a1e677701d67334bba5b749e3 (patch) | |
tree | a1842aa70977a3a9e554dac82fae597bb6f1717e /lib/fortify_kunit.c | |
parent | a0d6677ec3f1da894cad9df6a962821429828917 (diff) |
kunit/fortify: Do not spam logs with fortify WARNs
When running KUnit fortify tests, we're already doing precise tracking
of which warnings are getting hit. Don't fill the logs with WARNs unless
we've been explicitly built with DEBUG enabled.
Link: https://lore.kernel.org/r/20240429194342.2421639-2-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'lib/fortify_kunit.c')
-rw-r--r-- | lib/fortify_kunit.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c index 5d706529c464..601fa327c5b7 100644 --- a/lib/fortify_kunit.c +++ b/lib/fortify_kunit.c @@ -15,10 +15,17 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +/* We don't need to fill dmesg with the fortify WARNs during testing. */ +#ifdef DEBUG +# define FORTIFY_REPORT_KUNIT(x...) __fortify_report(x) +#else +# define FORTIFY_REPORT_KUNIT(x...) do { } while (0) +#endif + /* Redefine fortify_panic() to track failures. */ void fortify_add_kunit_error(int write); #define fortify_panic(func, write, avail, size, retfail) do { \ - __fortify_report(FORTIFY_REASON(func, write), avail, size); \ + FORTIFY_REPORT_KUNIT(FORTIFY_REASON(func, write), avail, size); \ fortify_add_kunit_error(write); \ return (retfail); \ } while (0) |