LKML Archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Peter Hurley <peter@hurleysoftware.com>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH] tty: use __GFP_NOWARN for user-controlled kmalloc
Date: Fri, 5 Feb 2016 02:32:00 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1602050227580.10138@chino.kir.corp.google.com> (raw)
In-Reply-To: <CACT4Y+Zj29ZmsUZCR7FhkxMz_kdV51qhp3SwJ31Sj40y=A7W0w@mail.gmail.com>

On Fri, 5 Feb 2016, Dmitry Vyukov wrote:

> On Thu, Feb 4, 2016 at 11:11 PM, David Rientjes <rientjes@google.com> wrote:
> > On Thu, 4 Feb 2016, Dmitry Vyukov wrote:
> >
> >> Size of kmalloc() in vc_do_resize() is controlled by user.
> >> Too large kmalloc() size triggers WARNING message on console.
> >>
> >> Use __GFP_NOWARN for this kmalloc() to not scare admins.
> >>
> >
> > Hmm, this is hitting the WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)) for
> > order >= MAX_ORDER.
> >
> > vc_do_resize() has
> >
> >         if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
> >                 return -EINVAL;
> >
> > so the appropriate fix would seem to be to reject sizes that would exceed
> > the page allocator's ability to return contiguous memory (MAX_ORDER)
> > rather than ever trying the allocation in the first place.
> 
> Hi David,
> 
> Please see Alan response to original report here:
> https://groups.google.com/d/msg/syzkaller/ufjvr5j0URo/lTlpYP0DBQAJ
> I can't say that I fully understand it.
> 

vc_do_resize() might not know a stricter limit, but we know the limit that 
the page allocator can provide, and that's MAX_ORDER-1.  kmalloc() with a 
size >= (1 << (PAGE_SHIFT + MAX_ORDER)) will always fail, so if that is 
really the upper limit, then so be it.  We should return -EINVAL 
appropriately and not -ENOMEM.

I'm thinking that the actual limit would actually be 
(1 << (PAGE_SHIFT + pageblock_order)) since even memory compaction isn't 
going to be able to defragment more than that, but the absolute max would 
always be MAX_ORDER-1.

  reply	other threads:[~2016-02-05 10:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 15:55 [PATCH] tty: use __GFP_NOWARN for user-controlled kmalloc() Dmitry Vyukov
2016-02-04 17:49 ` Peter Hurley
2016-02-04 18:28   ` [PATCH] tty: use __GFP_NOWARN for user-controlled kmalloc Dmitry Vyukov
2016-02-04 22:11     ` David Rientjes
2016-02-05  7:06       ` Dmitry Vyukov
2016-02-05 10:32         ` David Rientjes [this message]
2016-02-05 10:35         ` One Thousand Gnomes

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=alpine.DEB.2.10.1602050227580.10138@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=kcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=syzkaller@googlegroups.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).