Skip to content

Commit 091f79e

Browse files
committed
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>
1 parent a0d6677 commit 091f79e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/fortify_kunit.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
*/
1616
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1717

18+
/* We don't need to fill dmesg with the fortify WARNs during testing. */
19+
#ifdef DEBUG
20+
# define FORTIFY_REPORT_KUNIT(x...) __fortify_report(x)
21+
#else
22+
# define FORTIFY_REPORT_KUNIT(x...) do { } while (0)
23+
#endif
24+
1825
/* Redefine fortify_panic() to track failures. */
1926
void fortify_add_kunit_error(int write);
2027
#define fortify_panic(func, write, avail, size, retfail) do { \
21-
__fortify_report(FORTIFY_REASON(func, write), avail, size); \
28+
FORTIFY_REPORT_KUNIT(FORTIFY_REASON(func, write), avail, size); \
2229
fortify_add_kunit_error(write); \
2330
return (retfail); \
2431
} while (0)

0 commit comments

Comments
 (0)