linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	syzbot
	<bot+2797c18fc195e3e240c3c3e7837a14130e157fb0@syzkaller.appspotmail.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	dave.jiang@intel.com, LKML <linux-kernel@vger.kernel.org>,
	syzkaller-bugs@googlegroups.com,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-block@vger.kernel.org
Subject: Re: WARNING in kmalloc_slab (3)
Date: Tue, 12 Dec 2017 13:22:48 -0800	[thread overview]
Message-ID: <20171212212248.GD185376@gmail.com> (raw)
In-Reply-To: <20171204092632.mh772rjaqahgslvp@mwanda>

On Mon, Dec 04, 2017 at 12:26:32PM +0300, Dan Carpenter wrote:
> 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@oracle.com> 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.

WARN_ON() should only be used for kernel bugs.  printk can be a different story.
If it's a "userspace shouldn't do this" kind of thing, then if there is any
message at all it should be a rate-limited printk that actually explains what
the problem is, not a random WARN_ON() that can only be interpreted by kernel
developers.

And yes, the fact that anyone with read access to any block device, even e.g. a
loop device, can cause the kernel to do an unbounded kmalloc *is* a bug.  It
needs to have a reasonable limit.  It is not a problem on all systems, but on
some systems "the admin" might give users read access to some block devices.

Eric

  parent reply	other threads:[~2017-12-12 21:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f403043d11ccfea019055f705d18@google.com>
2017-12-03 20:16 ` WARNING in kmalloc_slab (3) Eric Biggers
2017-12-04  8:14   ` Dan Carpenter
2017-12-04  8:18     ` Dmitry Vyukov
2017-12-04  9:26       ` Dan Carpenter
2017-12-12 15:50         ` Dmitry Vyukov
2017-12-12 21:22         ` Eric Biggers [this message]
2018-02-07  4:58           ` Dmitry Vyukov

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=20171212212248.GD185376@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bot+2797c18fc195e3e240c3c3e7837a14130e157fb0@syzkaller.appspotmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dave.jiang@intel.com \
    --cc=dvyukov@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).