Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp139266rwb; Mon, 26 Sep 2022 10:15:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QuKX3teuy6s6YffkZfT0LbK0aRghLDSb+pIW2yN4m9ZoB+E168FWIA7HWyEjawv80kiE5 X-Received: by 2002:a17:906:730e:b0:783:87a1:b5db with SMTP id di14-20020a170906730e00b0078387a1b5dbmr5252583ejc.383.1664212554452; Mon, 26 Sep 2022 10:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664212554; cv=none; d=google.com; s=arc-20160816; b=GiyTHEEp7MEK9acnliofCs57ivtRj+YtvhAaU6K6IPKDonN63j/F9iEeBlDOJOvvOM 03D+catK2ebyh6DwfK8cQ4p/eGvWDxj8bRlMqQENZJZTtjb5VwMorvvopOBe2J8FhDMM I3kHHSC7eKIdR9vFkZk44DH1FXJTGno882WhUUYbntsw0wXfTOJauzKjZ4hT/qr+htSM uQE07adUyJzls7pGyjt5fFk5TI9mcu+rZgddL87D+JyBVjSPIlZeMNRdruduk8GdXBbb BykY5dyjUPYqJEQTJOhkCknF+nGnfLuTYFV8jo1NWC4/Xb5pSLcJnLA4+pUccKUuz0cH NddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XvdXKGreLfPjFMsKtqVeaQFZhIGfsMLQ/IOxXrRCaZs=; b=rZ4ha/168E7YMwrtnM0Kt3uXFtOiKEQ/ltFiY5fKvIwLCtKFxPs3COhsXmCKqxIvv8 kUAld9TkvRV8s6+dTZVIOjTc/eEmnoaCgjj+Ml5jPLhbmuRdt/v76hQVjRAKlJWVanik lR7YGfDTgI496BSoT35py7FVlE54Qu7ES6QNXQt9J8bQrNH4spoF4xYQMmynW+ZAwvrS dqX27zM0Te4N+FHfTpaP1a/3IWJRoF3c5YBLS2h1rgsrIhjeF/tkn9tznna0bL7714nm pc2WNQt4viOsunALGhxs6UVbanI267NBAfxrlANaGlAG4V40dFHh1zZCveAcABh5bWD6 QRlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eo10-20020a056402530a00b004523826ed6dsi14650314edb.554.2022.09.26.10.15.28; Mon, 26 Sep 2022 10:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbiIZQ26 (ORCPT + 99 others); Mon, 26 Sep 2022 12:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiIZQ2i (ORCPT ); Mon, 26 Sep 2022 12:28:38 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA9710CA70 for ; Mon, 26 Sep 2022 08:17:39 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1ocprT-0006De-Tm; Mon, 26 Sep 2022 17:17:35 +0200 From: Florian Westphal To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, urezki@gmail.com, linux-kernel@vger.kernel.org, Florian Westphal , Martin Zaharinov Subject: [PATCH v2 mm] mm: fix BUG splat with kvmalloc + GFP_ATOMIC Date: Mon, 26 Sep 2022 17:16:50 +0200 Message-Id: <20220926151650.15293-1-fw@strlen.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Martin Zaharinov reports BUG with 5.19.10 kernel: kernel BUG at mm/vmalloc.c:2437! invalid opcode: 0000 [#1] SMP CPU: 28 PID: 0 Comm: swapper/28 Tainted: G W O 5.19.9 #1 [..] RIP: 0010:__get_vm_area_node+0x120/0x130 __vmalloc_node_range+0x96/0x1e0 kvmalloc_node+0x92/0xb0 bucket_table_alloc.isra.0+0x47/0x140 rhashtable_try_insert+0x3a4/0x440 rhashtable_insert_slow+0x1b/0x30 [..] bucket_table_alloc uses kvzalloc(GPF_ATOMIC). If kmalloc fails, this now falls through to vmalloc and hits code paths that assume GFP_KERNEL. Reported-by: Martin Zaharinov Fixes: a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc") Suggested-by: Michal Hocko Link: https://lore.kernel.org/linux-mm/Yy3MS2uhSgjF47dy@pc636/T/#t Signed-off-by: Florian Westphal --- mm/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/util.c b/mm/util.c index c9439c66d8cf..346e40177bc6 100644 --- a/mm/util.c +++ b/mm/util.c @@ -619,6 +619,10 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) if (ret || size <= PAGE_SIZE) return ret; + /* non-sleeping allocations are not supported by vmalloc */ + if (!gfpflags_allow_blocking(flags)) + return NULL; + /* Don't even allow crazy sizes */ if (unlikely(size > INT_MAX)) { WARN_ON_ONCE(!(flags & __GFP_NOWARN)); -- 2.35.1