Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1468111
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [kernel-hardening] Re: [PATCH v3 4/5] bug: Provide toggle for BUG on data corruption |
| Date | 2016-08-23 00:40 +0200 |
| Message-ID | <s962R-3Tc-9@gated-at.bofh.it> (permalink) |
| References | <s7gSJ-6Zu-3@gated-at.bofh.it> <s7gSK-6Zu-19@gated-at.bofh.it> <s8XiW-6LP-35@gated-at.bofh.it> <s91FU-WO-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Aug 22, 2016 at 10:53 AM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
> On Mon, Aug 22, 2016 at 03:15:35PM +0200, Arnd Bergmann wrote:
>> On Wednesday, August 17, 2016 2:42:11 PM CEST Kees Cook wrote:
>> > +
>> > +/*
>> > + * Since detected data corruption should stop operation on the affected
>> > + * structures, this returns false if the corruption condition is found.
>> > + */
>> > +#define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
>> > + do { \
>> > + if (unlikely(condition)) { \
>> > + if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
>> > + pr_err(fmt, ##__VA_ARGS__); \
>> > + BUG(); \
>> > + } else \
>> > + WARN(1, fmt, ##__VA_ARGS__); \
>> > + return false; \
>> > + } \
>> > + } while (0)
>> > +
>>
>> I think the "return false" inside of the macro makes it easy to misread
>> what is actually going on.
>>
>> How about making it a macro that returns the condition argument?
>>
>> #define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
>> ({ \
>> bool _condition = unlikely(condition); \
>> if (_condition) { \
>> ...
>> } \
>> _condition; \
>> })
>
> That does look better, now that you mention it. Kees, any objections?
That's fine with me; it'll require changing the callers of the macros
to test their results, but that should be clean change.
-Kees
--
Kees Cook
Nexus Security
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 0/5] bug: Provide toggle for BUG on data corruption Kees Cook <keescook@chromium.org> - 2016-08-17 23:50 +0200
[PATCH v3 4/5] bug: Provide toggle for BUG on data corruption Kees Cook <keescook@chromium.org> - 2016-08-17 23:50 +0200
Re: [PATCH v3 4/5] bug: Provide toggle for BUG on data corruption Arnd Bergmann <arnd@arndb.de> - 2016-08-22 15:20 +0200
Re: [PATCH v3 4/5] bug: Provide toggle for BUG on data corruption "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-08-22 20:00 +0200
Re: [kernel-hardening] Re: [PATCH v3 4/5] bug: Provide toggle for BUG on data corruption Kees Cook <keescook@chromium.org> - 2016-08-23 00:40 +0200
Re: [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption Steven Rostedt <rostedt@goodmis.org> - 2016-08-18 15:50 +0200
Re: [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-08-19 03:10 +0200
Re: [kernel-hardening] [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption Rik van Riel <riel@redhat.com> - 2016-08-19 03:00 +0200
Re: [kernel-hardening] [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-08-19 03:30 +0200
Re: [kernel-hardening] [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption Rik van Riel <riel@redhat.com> - 2016-08-19 05:00 +0200
Re: [kernel-hardening] [PATCH v3 0/5] bug: Provide toggle for BUG on data corruption "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-08-19 19:50 +0200
csiph-web