Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2009032imm; Thu, 27 Sep 2018 06:08:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV63rrcEaSYWeZn54bZfI/jzJ8nNfzhJeUY1b+KwCH8CU2A03d4WdRro0xNev42BIotXt53FD X-Received: by 2002:a17:902:6843:: with SMTP id f3-v6mr804505pln.64.1538053720236; Thu, 27 Sep 2018 06:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538053720; cv=none; d=google.com; s=arc-20160816; b=KR21xohFfdNTtlJ8pouQ2zgbaknDa5RHTIHfllPL8TKwv8P024ZpkzL200wTlaiviv G/5O82kfKl44O1PkouVNkotkjgPSha8CH1cxk7opxwmjnewuE6fx1QpgTTbvHYb1SZDF OvOj7g6saNMacZ4PKN0lePDX0oKdFVjF9r0CEkRgo47OtftewxWJcItoqmxQgF1FDzks 5/6FjkhLdiIRk1GCzJjUnF8smqA5O3Rvcg2Iaq5k3nvfmIHxDkJksoJzeHUVLFmrkg/Z n4aulGlFkdFV5jJVMFs8uvXoDyvxUmSRtOHyckRJW29GHHOyttDT1XnK6UD0WeUTyf8D ZMZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rNjo57d9FwBVh5nb9Zg8J/24nH2FEt/6+d3R0LK5y5I=; b=Hu9osp6gzVt8ZpQtBkK2TIOAmLmyTz01xAORg8gPh7DGl5KwcEj1jaFYSUdZ21Y6QH iXaub3dv/rbpXggoNKPu6T84B28NN+HGS7TG7sIHZWvKzx/vYkGPbdeyMj2bJdwkiGF8 88JuIKXJ3GBjHnC/A4KF4jN601Sr3ibvXtTIGmBaFyhiYHlToYlPtQ0OHybuW4thIhmN joRf3oPsVN//rI4jaICX/6SENvYYvBuN2yi/8h7fn1j1ps2O1/eHwUH7MgwhHh3pkz8x dHkai73l6mheHDJTvqhd+RmtRd8jZYlmLMK4jdzig/BFUkZTHKksEPFx0qcRtidd5alg 8LHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="EtiKl/PZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l185-v6si1964552pgl.270.2018.09.27.06.08.23; Thu, 27 Sep 2018 06:08:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="EtiKl/PZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbeI0TZX (ORCPT + 99 others); Thu, 27 Sep 2018 15:25:23 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43195 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbeI0TZX (ORCPT ); Thu, 27 Sep 2018 15:25:23 -0400 Received: by mail-wr1-f67.google.com with SMTP id z14-v6so2517374wrs.10 for ; Thu, 27 Sep 2018 06:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rNjo57d9FwBVh5nb9Zg8J/24nH2FEt/6+d3R0LK5y5I=; b=EtiKl/PZVmN0v9z4Dwqe0q2Xko7xXqpZg3gfKNmpwiVLS65h8ZWvlKr6rUkWRH99DE 031hjscZ+4e03o6WGnbk4uw8Bei3HJm2yW0yYRBYxdVi6Gef/JypEFzmPo77TUbevvXM AXthcdhr0BmCNt8eOGMGsu26+CeTFX3M1xEn3qzD5SoVs63k3cn0OIozhF/ACXMhc0H+ U1qT7iKr3LEBBcmswco4CeUOEKwpBhcy0UlxE9vK6NlUPPbGfpbdQp4PWZpp99Td+dRD wC+ooh0LPrY1O31ZGP2+QP1zpQ6j4+dcY/fgvWGzkxmGhmReul5JflgdrcMSEl+Pbb1L J+tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rNjo57d9FwBVh5nb9Zg8J/24nH2FEt/6+d3R0LK5y5I=; b=Wb4xXWrHTHlMIMqUyBu6PIRgNmj6ZyjeXetq260CA+q75OnIUO0EeHvkDkFn8+pDBP ZbwGLFCN3MBQUoAg1j65XsBYxQYWGUj1qj1WfmtU7KkltPvpCxDC8nZcM5hZecIfoDJD B5Q9OczENMhwJqhbawPxMUhpyeQIqy+ApS7GfonSxQhFjR5rF3Uq8E/vCmw3jZ6yRR6D Vcxl/fPrf1q5kAyd2A8AYQjuoMs7B+SjJH85m68j/eAlx9+2vyxeIbjB75HZfzsHZaMf 1rC1misWWNzlVFy/3ZMzHmIU5mVMf6lmmAiclGYZ9yohNI1p/G/4h4DMWsDiXhgtwmYz uLPA== X-Gm-Message-State: ABuFfojf+kSsCMPsWKgMoWL3RSDAFleXn+2SN0D1HM4T8+tLtUIT6xPG +GKC09uqnSLbc+GfwyeC210= X-Received: by 2002:a05:6000:100f:: with SMTP id a15mr8578557wrx.271.1538053630992; Thu, 27 Sep 2018 06:07:10 -0700 (PDT) Received: from dvyukov-z840.muc.corp.google.com ([2a00:79e0:15:10:8971:4ae9:dd1c:10e]) by smtp.gmail.com with ESMTPSA id b124-v6sm1602760wmg.47.2018.09.27.06.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 06:07:09 -0700 (PDT) From: Dmitry Vyukov To: cl@linux.com, penberg@kernel.org, akpm@linux-foundation.org, rientjes@google.com, iamjoonsoo.kim@lge.com Cc: Dmitry Vyukov , 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 Message-Id: <20180927130707.151239-1-dvyukov@gmail.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Vyukov 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 Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton 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