Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755016AbdDDWNj (ORCPT ); Tue, 4 Apr 2017 18:13:39 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:34533 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932297AbdDDWM0 (ORCPT ); Tue, 4 Apr 2017 18:12:26 -0400 From: Kees Cook To: Ingo Molnar Cc: Kees Cook , Peter Zijlstra , "Paul E. McKenney" , Kalle Valo , Andrew Morton , Rik van Riel , Jakub Kicinski , Viresh Kumar , Andy Shevchenko , Geert Uytterhoeven , Olof Johansson , Chris Wilson , George Spelvin , Thomas Gleixner , Josh Poimboeuf , David Windsor , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 3/7] bug: Use WARN_ONCE() for CHECK_DATA_CORRUPTION() Date: Tue, 4 Apr 2017 15:12:14 -0700 Message-Id: <1491343938-75336-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491343938-75336-1-git-send-email-keescook@chromium.org> References: <1491343938-75336-1-git-send-email-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 921 Lines: 26 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 --- 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