[PATCH v2 3/7] bug: Use WARN_ONCE() for CHECK_DATA_CORRUPTION()

From: Kees Cook
Date: Tue Apr 04 2017 - 18:13:42 EST


Since users of CHECK_DATA_CORRUPTION() should be failing safe, the
condition that triggers a WARN() may recur. This would mean a logging
DoS of the system, so switch to WARN_ONCE() instead. (Those wanting
per-instance notifications should already be building with
CONFIG_BUG_ON_DATA_CORRUPTION so there is no change in that case.)

Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
include/linux/bug.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bug.h b/include/linux/bug.h
index b6cfcb7f778f..c011438a7c6c 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -136,7 +136,7 @@ static inline __must_check bool check_data_corruption(bool v) { return v; }
pr_err(fmt, ##__VA_ARGS__); \
BUG(); \
} else \
- WARN(1, fmt, ##__VA_ARGS__); \
+ WARN_ONCE(1, fmt, ##__VA_ARGS__); \
} \
unlikely(corruption); \
}))
--
2.7.4