From: Kees Cook <keescook@chromium.org>
To: kernel-hardening@lists.openwall.com
Cc: Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Rik van Riel <riel@redhat.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Dmitry Vyukov <dvyukov@google.com>,
Olof Johansson <olof@lixom.net>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] bug: Improve unlikely() in data corruption check
Date: Mon, 6 Mar 2017 11:09:42 -0800 [thread overview]
Message-ID: <1488827386-87193-3-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1488827386-87193-1-git-send-email-keescook@chromium.org>
This improves the compiler branch-hinting used in CHECK_DATA_CORRUPTION(),
similar to how it is done in WARN_ON() and friends.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
include/linux/bug.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/bug.h b/include/linux/bug.h
index 5828489309bb..5ef65dc2ed8b 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -129,15 +129,15 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr,
static inline __must_check bool check_data_corruption(bool v) { return v; }
#define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
check_data_corruption(({ \
- bool corruption = unlikely(condition); \
- if (corruption) { \
+ bool corruption = !!(condition); \
+ if (unlikely(corruption)) { \
if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
pr_err(fmt, ##__VA_ARGS__); \
BUG(); \
} else \
WARN(1, fmt, ##__VA_ARGS__); \
} \
- corruption; \
+ unlikely(corruption); \
}))
#endif /* _LINUX_BUG_H */
--
2.7.4
next prev parent reply other threads:[~2017-03-06 19:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 19:09 [PATCH 0/6] bug: further enhance use of BUG_ON_DATA_CORRUPTION Kees Cook
2017-03-06 19:09 ` [PATCH 1/6] bug: Clarify help text for BUG_ON_DATA_CORRUPTION Kees Cook
2017-03-06 19:09 ` Kees Cook [this message]
2017-03-06 19:09 ` [PATCH 3/6] bug: Enable DEBUG_CREDENTIALS under BUG_ON_DATA_CORRUPTION Kees Cook
2017-03-06 19:09 ` [PATCH 4/6] bug: Enable DEBUG_SG " Kees Cook
2017-03-06 19:09 ` [PATCH 5/6] notifiers: Use CHECK_DATA_CORRUPTION() on checks Kees Cook
2017-03-22 19:29 ` Kees Cook
2017-03-22 19:32 ` Arjan van de Ven
2017-03-22 19:55 ` Kees Cook
2017-03-06 19:09 ` [PATCH 6/6] refcount: Check bad states with CHECK_DATA_CORRUPTION Kees Cook
2017-03-22 19:30 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488827386-87193-3-git-send-email-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=jakub.kicinski@netronome.com \
--cc=jpoimboe@redhat.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=olof@lixom.net \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®