Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697393

Re: [PATCH] fortify: Use WARN instead of BUG for now

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: [PATCH] fortify: Use WARN instead of BUG for now
Date 2017-07-26 19:20 +0200
Message-ID <u7y8y-3b6-31@gated-at.bofh.it> (permalink)
References <u7lEm-3wP-3@gated-at.bofh.it> <u7y8y-3b6-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jul 26, 2017 at 10:10 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Tue, Jul 25, 2017 at 8:50 PM, Kees Cook <keescook@chromium.org> wrote:
>> +
>> +void fortify_read_overflow(const char *func)
>>  {
>> -       pr_emerg("detected buffer overflow in %s\n", name);
>> -       BUG();
>> +       WARN(1, "detected read beyond size of object passed as 1st parameter in %s\n", func);
>>  }
>
> Side note: have you actually checked the code generation of this all?
>
> In particular, do you have any reason to use the out-of-line
> functions? Our WARN() code isn't horrible, and isn't likely to be
> noticeably worse than your own explicit out-of-lining. And you'd get
> the "unlikely()" for free, so you'll possibly get smaller code that
> runs better too.
>
> And it would even *look* better. This:
>
>         if (p_size < size)
>                fortify_read_overflow(__func__);
>
> would become
>
>        WARN(p_size < size, "kmemdup size overflow");
>
> or something.

I did, yeah. It's actually slightly smaller code size to out-of-line these:

$ size vmlinux.fortify*
   text    data     bss     dec     hex filename
10903767        5605009 13930496        30439272        1d07768
vmlinux.fortify-off
10944795        5617801 13930496        30493092        1d149a4 vmlinux.fortify
10950117        5626725 13930496        30507338        1d1814a
vmlinux.fortify-inline

If the readability improvement is preferred over the growth in size, I
can certainly respin it.

-Kees

-- 
Kees Cook
Pixel Security

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] fortify: Use WARN instead of BUG for now Kees Cook <keescook@chromium.org> - 2017-07-26 06:00 +0200
  Re: [PATCH] fortify: Use WARN instead of BUG for now Daniel Micay <danielmicay@gmail.com> - 2017-07-26 15:00 +0200
    Re: [PATCH] fortify: Use WARN instead of BUG for now Kees Cook <keescook@chromium.org> - 2017-07-26 19:30 +0200
      Re: [PATCH] fortify: Use WARN instead of BUG for now Daniel Micay <danielmicay@gmail.com> - 2017-07-26 20:00 +0200
  Re: [PATCH] fortify: Use WARN instead of BUG for now Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-26 19:20 +0200
    Re: [PATCH] fortify: Use WARN instead of BUG for now Kees Cook <keescook@chromium.org> - 2017-07-26 19:20 +0200

csiph-web