linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Matthew Wilcox <willy@infradead.org>,
	Bagas Sanjaya <bagasdotme@gmail.com>
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Rudi Heitbaum <rudi@heitbaum.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Regressions <regressions@lists.linux.dev>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Linux Networking <netdev@vger.kernel.org>,
	Linux Wireless <linux-wireless@vger.kernel.org>
Subject: Re: Fwd: mm/page_alloc.c:4453 with cfg80211_wiphy_work [cfg80211]
Date: Mon, 17 Jul 2023 15:53:43 +0200	[thread overview]
Message-ID: <fe395b67-6cf8-7351-872c-a01c898a3798@suse.cz> (raw)
In-Reply-To: <ZLPUXlR30DjNaWqO@casper.infradead.org>

On 7/16/23 13:28, Matthew Wilcox wrote:
> On Sun, Jul 16, 2023 at 06:10:44PM +0700, Bagas Sanjaya wrote:
>> Hi,
>> 
>> I notice a regression report on Bugzilla [1]. Quoting from it:
> 
> Maybe you could try doing some work on this bug before just spamming
> people with it?
> 
>         if (WARN_ON_ONCE_GFP(order > MAX_ORDER, gfp))
>                 return NULL;
> 
> This is the page allocator telling the caller that they've asked for an
> unreasonably large allocation.
> 
> Now, this bug is actually interesting to the MM because the caller
> called kmalloc() with a ridiculous size.  Arguable kmalloc should
> protect callers from themselves (alloc_pages() is more low level
> and can presume its users know what they're doing).
> 
> Vlastimil, what do you think?  Something like ...

Hmm should be more robust to check size > KMALLOC_MAX_SIZE before even doing
get_order(size). Ultimately it checks the same limit.
But I'm unsure about just returning NULL. I think warn_on_once might be
useful even there - in case a bug is introduced/exposed, even a
inexperienced user will be easily able to report sufficient information wich
a WARN and its stacktrace, even if the callsite's alloc check doesn't
provide it in an obvious way?

> +++ b/mm/slab_common.c
> @@ -1119,6 +1119,8 @@ static void *__kmalloc_large_node(size_t size, gfp_t flags, int node)
>         void *ptr = NULL;
>         unsigned int order = get_order(size);
> 
> +       if (order > MAX_ORDER)
> +               return NULL;
>         if (unlikely(flags & GFP_SLAB_BUG_MASK))
>                 flags = kmalloc_fix_flags(flags);
> 
> 
> 



  reply	other threads:[~2023-07-17 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-16 11:10 Fwd: mm/page_alloc.c:4453 with cfg80211_wiphy_work [cfg80211] Bagas Sanjaya
2023-07-16 11:28 ` Matthew Wilcox
2023-07-17 13:53   ` Vlastimil Babka [this message]
2023-07-17 13:41 ` Peer, Ilan
2023-07-18  8:02   ` Rudi Heitbaum
2023-07-19  6:45     ` Peer, Ilan

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=fe395b67-6cf8-7351-872c-a01c898a3798@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bagasdotme@gmail.com \
    --cc=cl@linux.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=johannes@sipsolutions.net \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=penberg@kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rudi@heitbaum.com \
    --cc=willy@infradead.org \
    /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).