Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4691214rwe; Tue, 30 Aug 2022 15:12:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5drl4CQ1Mja6uCqiTMcDnAqMZwgelTfGHhRdCLZeE58LpE7NoQbFrie4osEcN+eEiLSjVl X-Received: by 2002:a17:907:2d1e:b0:73e:7c1f:b47d with SMTP id gs30-20020a1709072d1e00b0073e7c1fb47dmr14256431ejc.681.1661897521081; Tue, 30 Aug 2022 15:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661897521; cv=none; d=google.com; s=arc-20160816; b=UOtiYIr6sgrjoi6PTIlIU8CglJlmvKjOOf3fvtSfpvH2kwosDf3m6iDiUlLGRjHekj NHQjPC3emZLNif1gK60Z3xN3MWhguK1OknwmSj+sq0ZiTCXfm2Xb4WlpYtvir45vQikc pS4tX8gSu/CfNiSnIVnX6Kn6nLp0iiePl+fcGsRk9gPOGTnSY5103NPuTL/8b1vZlc2U WXCgoArMk7t+LCbUmUHedvFEMryobpMpI6P2Ot6gv/4JaiqwIIANh72xAVDPV4u/MIjB Iua3+zyIEGywJANSpq2XaAXURAFoJ4YAKaRKx35vSk6hkm7PlyUXfBaIXQEmDWdR+n4D 2fyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=gY+PdoFf3bNnEB0W9Vd0woPoFdt9hhtegjhiPtTj+AE=; b=RJ074YiNPs0A1i6LpM9I0dgfv3JvqBJRlnVxttuCFzeu5UVngJli8Xe7A4Tr5KcMS7 31puOk4qYJ4Rb5T2S9iz8bhRnjrOuh1uanzg9ZAjTbT2h1Cxl35DLDkPHAHBo5hH8vEi rS4Y2qh8ZQCdrhFAvzFVOmyi1oAMzM4MzIwD7XrwoxL3RRpkmTlsvWarZHo4rDdy+fFS AaKDHsxxjgkguezmH7DH1Sv7xGZmWWzIvsLIVnf9QdVLUfK5rN8epAKkeCnAYpKLukyI nvyl+G90xmGYGx4s6uFIGHGS+DgyWP41wdHukrEU2QSvDs1wWjKKV37FFrup/WO1Ilap ueTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pP4c3oP+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb41-20020a170907162900b00730a134ccfasi8374976ejc.572.2022.08.30.15.11.11; Tue, 30 Aug 2022 15:12:01 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=pP4c3oP+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232058AbiH3VwH (ORCPT + 99 others); Tue, 30 Aug 2022 17:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbiH3VvW (ORCPT ); Tue, 30 Aug 2022 17:51:22 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB6311A071 for ; Tue, 30 Aug 2022 14:50:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j11-20020a05690212cb00b006454988d225so723217ybu.10 for ; Tue, 30 Aug 2022 14:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc; bh=gY+PdoFf3bNnEB0W9Vd0woPoFdt9hhtegjhiPtTj+AE=; b=pP4c3oP+YdesowZgNPs4eE1Xp1hWxAr9Ov2IDGBfglQ7uK9BWLrmzhDJ/utRpkPDJK tLMoERW1+3/smlLhO5G46VfqVywVDMABKHAv9jnhzz9ZshpBvX9ODCL7lsQaaZS0MLOk moKmQwwsOGjNod+M4t/tjA/+LNyP1VXOc5752+/a3Um/WwaPBzNEpe5l2cE7BDo787CF /PWmu6igP2xWBoiVtEHlimVT5AWdWMQxPlHvsqYO1szpGDqcGUPThIrLg/hGXqOCKmhM XRoOlsQx66oUshjUnxZWYY0qi/lYffvprIXZMUGryr7KjlXRCtsueZ1FZIWTKefulhTk stEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc; bh=gY+PdoFf3bNnEB0W9Vd0woPoFdt9hhtegjhiPtTj+AE=; b=QgWy+rcLic8bDP+LdEmrlsF/rF2Ugwtf0Vqx/7W0GE8scoL1P7xXD9Y3dQJCs1exg0 O66BR1+FFylj2Ksklj5dC2hr5Z2HHalA3ftH2qtGnr00otSYtuNNBSm0FvDJjcolYqxu 2Jx5vtAidEuRiLhhE+60kJ0X02MNPaqp00LoPo8GXEdBilQdxbIahferG473EQFb2Qy1 WeqGD6ZOQhtB4CjfYHP++iKWfhLwJeGfqOVR+o0W/Y5BEqrC8uw7wy0fnv3qJOyhBw// 5Me9/YRXJFFJRvJDOaHjG+4LnimvXKV27o8L7YnmJ2OCDXUfp1OvuVinyS13+F0o9OVi VFvg== X-Gm-Message-State: ACgBeo0eAlYyxIYH3horu932G2/RCeKk2Ob6gEFQS6ccIPDJ6IqsS0L+ ORjlUCcDDfr/YbJxx+5u8TfVp1ufEy0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:a005:55b3:6c26:b3e4]) (user=surenb job=sendgmr) by 2002:a25:ba91:0:b0:683:ebc2:7114 with SMTP id s17-20020a25ba91000000b00683ebc27114mr13866830ybg.319.1661896200808; Tue, 30 Aug 2022 14:50:00 -0700 (PDT) Date: Tue, 30 Aug 2022 14:49:03 -0700 In-Reply-To: <20220830214919.53220-1-surenb@google.com> Mime-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220830214919.53220-15-surenb@google.com> Subject: [RFC PATCH 14/30] mm: prevent slabobj_ext allocations for slabobj_ext and kmem_cache objects From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, arnd@arndb.de, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@google.com, kernel-team@android.com, linux-mm@kvack.org, iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Use __GFP_NO_OBJ_EXT to prevent recursions when allocating slabobj_ext objects. Also prevent slabobj_ext allocations for kmem_cache objects. Signed-off-by: Suren Baghdasaryan --- mm/memcontrol.c | 2 ++ mm/slab.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3f407ef2f3f1..dabb451dc364 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2809,6 +2809,8 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, void *vec; gfp &= ~OBJCGS_CLEAR_MASK; + /* Prevent recursive extension vector allocation */ + gfp |= __GFP_NO_OBJ_EXT; vec = kcalloc_node(objects, sizeof(struct slabobj_ext), gfp, slab_nid(slab)); if (!vec) diff --git a/mm/slab.h b/mm/slab.h index c767ce3f0fe2..d93b22b8bbe2 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -475,6 +475,12 @@ static inline void prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, if (is_kmem_only_obj_ext()) return; + if (s->flags & SLAB_NO_OBJ_EXT) + return; + + if (flags & __GFP_NO_OBJ_EXT) + return; + slab = virt_to_slab(p); if (!slab_obj_exts(slab)) WARN(alloc_slab_obj_exts(slab, s, flags, false), -- 2.37.2.672.g94769d06f0-goog