Re: WARNING in kmalloc_slab (3)

From: Dan Carpenter
Date: Mon Dec 04 2017 - 04:27:08 EST


On Mon, Dec 04, 2017 at 09:18:05AM +0100, Dmitry Vyukov wrote:
> On Mon, Dec 4, 2017 at 9:14 AM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> > On Sun, Dec 03, 2017 at 12:16:08PM -0800, Eric Biggers wrote:
> >> Looks like BLKTRACESETUP doesn't limit the '.buf_nr' parameter, allowing anyone
> >> who can open a block device to cause an extremely large kmalloc. Here's a
> >> simplified reproducer:
> >>
> >
> > There are lots of places which allow people to allocate as much as they
> > want. With Syzcaller, you might want to just hard code a __GFP_NOWARN
> > in to disable it.
>
> Hi,
>
> Hard code it where?

My idea was to just make warn_alloc() a no-op.

>
> User-controllable allocation are supposed to use __GFP_NOWARN.

No that's not right. What we don't want is unprivileged users to use
all the memory and we don't want unprivileged users to spam
/var/log/messages. But you have to have slightly elevated permissions
to open block devices right? The warning is helpful. Admins should
"don't do that" if they don't want the warning.

The kernel really isn't designed to work with Oops on Warn. I try to
tell people simple thinks like not printing a warning when
copy_from_user() fails because I don't want /var/log/messages to get
spammed. But there are lots and lots of places which generate warnings.

regards,
dan carpenter