Re: [PATCH 1/2] netlink: Bounds-check nlmsg_len()

From
Eric Dumazet <hidden>
Date
2022-09-01 20:54:43
Also in
linux-hardening, lkml, netfilter-devel
Reply to
Jakub Kicinski, 2022-09-01
On Thu, Sep 1, 2022 at 12:49 PM Jakub Kicinski [off-list ref] wrote:
On Wed, 31 Aug 2022 23:27:08 -0700 Kees Cook wrote:
quoted
This would catch corrupted values...

Is the concern the growth in image size? The check_sub_overflow() isn't
large at all -- it's just adding a single overflow bit test. The WARNs
are heavier, but they're all out-of-line.
It turns the most obvious function into a noodle bar :(

Looking at this function in particular is quite useful, because
it clearly indicates that the nlmsg_len includes the header.

How about we throw in a

        WARN_ON_ONCE(nlh->nlmsg_len < NLMSG_HDRLEN ||
                     nlh->nlmsg_len > INT_MAX);

but leave the actual calculation human readable C?
This is inlined, and will add a lot of extra code. We are making the
kernel slower at each release.

What about letting fuzzers like syzbot find the potential issues ?

DEBUG_NET_WARN_ON_ONCE(...);
Thread (8 messages) 8 messages, 3 authors, last reply 2022-09-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help