linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@gmail.com>
To: cl@linux.com, penberg@kernel.org, akpm@linux-foundation.org,
	rientjes@google.com, iamjoonsoo.kim@lge.com
Cc: Dmitry Vyukov <dvyukov@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mm: don't warn about large allocations for slab
Date: Thu, 27 Sep 2018 15:07:07 +0200	[thread overview]
Message-ID: <20180927130707.151239-1-dvyukov@gmail.com> (raw)

From: Dmitry Vyukov <dvyukov@google.com>

This warning does not seem to be useful. Most of the time it fires when
allocation size depends on syscall arguments. We could add __GFP_NOWARN
to these allocation sites, but having a warning only to suppress it
does not make lots of sense. Moreover, this warnings never fires for
constant-size allocations and never for slub, because there are
additional checks and fallback to kmalloc_large() for large allocations
and kmalloc_large() does not warn. So the warning only fires for
non-constant allocations and only with slab, which is odd to begin with.
The warning leads to episodic unuseful syzbot reports. Remote it.

While we are here also fix the check. We should check against
KMALLOC_MAX_CACHE_SIZE rather than KMALLOC_MAX_SIZE. It all kinda
worked because for slab the constants are the same, and slub always
checks the size against KMALLOC_MAX_CACHE_SIZE before kmalloc_slab().
But if we get there with size > KMALLOC_MAX_CACHE_SIZE anyhow
bad things will happen.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Reported-by: syzbot+87829a10073277282ad1@syzkaller.appspotmail.com
Reported-by: syzbot+ef4e8fc3a06e9019bb40@syzkaller.appspotmail.com
Reported-by: syzbot+6e438f4036df52cbb863@syzkaller.appspotmail.com
Reported-by: syzbot+8574471d8734457d98aa@syzkaller.appspotmail.com
Reported-by: syzbot+af1504df0807a083dbd9@syzkaller.appspotmail.com
---
 mm/slab_common.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 1f903589980f9..2733bddcfdc0c 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1023,10 +1023,8 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
 {
 	unsigned int index;
 
-	if (unlikely(size > KMALLOC_MAX_SIZE)) {
-		WARN_ON_ONCE(!(flags & __GFP_NOWARN));
+	if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
 		return NULL;
-	}
 
 	if (size <= 192) {
 		if (!size)
-- 
2.19.0.605.g01d371f741-goog

             reply	other threads:[~2018-09-27 13:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 13:07 Dmitry Vyukov [this message]
2018-09-27 15:51 ` [PATCH] mm: don't warn about large allocations for slab Christopher Lameter
2018-09-27 17:17   ` 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=20180927130707.151239-1-dvyukov@gmail.com \
    --to=dvyukov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dvyukov@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.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 NNTP newsgroup(s).