From patchwork Mon May 1 16:54:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13227647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDB0FC77B61 for ; Mon, 1 May 2023 16:55:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 702DC90000E; Mon, 1 May 2023 12:55:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BD4A900002; Mon, 1 May 2023 12:55:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52D2F90000E; Mon, 1 May 2023 12:55:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3C5B9900002 for ; Mon, 1 May 2023 12:55:36 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1312DADA56 for ; Mon, 1 May 2023 16:55:36 +0000 (UTC) X-FDA: 80742287472.13.133794C Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf28.hostedemail.com (Postfix) with ESMTP id 4E647C001C for ; Mon, 1 May 2023 16:55:34 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=tJm7WR8A; spf=pass (imf28.hostedemail.com: domain of 3Be9PZAYKCEw685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3Be9PZAYKCEw685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682960134; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AxHF9zQp9trScXtaAl0tt4NG3XQrBAxJQ/ayq1tkXak=; b=m16Dm6GwR6USZeffpRWpQCf/Bdm7415sFJHwA+PteJqcWsl6GGFXlf92JN1Ea+Ve9zYhHO A3B3TTZfGTY4bIm7p9URraVMMXm1AyK6xg1fooxqS+G/C81PdT4RxDoVPYu7s3HHHjTi8Y yfcOUpuviSKlVmLhAmViWF40HHIdBLE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=tJm7WR8A; spf=pass (imf28.hostedemail.com: domain of 3Be9PZAYKCEw685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3Be9PZAYKCEw685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682960134; a=rsa-sha256; cv=none; b=JqPtGn/ChRUkEfJjZ7+YZEsE/ya4MXhW6z4vAXnqDqT0iOztzN0XnMpa0UOfdGuY+iYbaV Ek9FHXr+9zUn+9q58lxLiolUjw0mUU5cV7QH/tFe18uMX18p+Mx9VHv81cETXetrMjIJu2 FrPIxdl8JHfgqT1pu6OS6H8yPk8d+6Q= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1aafc4aa1c6so5947875ad.1 for ; Mon, 01 May 2023 09:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682960133; x=1685552133; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AxHF9zQp9trScXtaAl0tt4NG3XQrBAxJQ/ayq1tkXak=; b=tJm7WR8AdSF6O5qWHaKU1D/ysKeRzFc3FiZT54ezTvTsHezyhXNB2hdIvEgmyHbI2P coE7FK11G2KLLdp82iDrBRtaK1XJdqiYBBu7Bzgc0CjbScOB1xMrdceY1iUR8li4Lunu QxqPry7kkIxD8xjnoCiSp2i1c6RgrlFShVMk73jBCUlai0Pj6tzx2wQKCiGt42ycRlUY Q6iiOWoraxytw320styP6cKZ8CPR54fhZHUXwBTe18PxhhkTB2K2EgrVvGyA9dqorw8v 3z+UXLp0f4HuyIt3egDvW6I8g1tJRbXw06CphA32uVzlUNPHB3VM7B/5KkyjlKHh6bO/ vApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682960133; x=1685552133; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AxHF9zQp9trScXtaAl0tt4NG3XQrBAxJQ/ayq1tkXak=; b=AQndvSYQqfVZcaj9fezGhyTzkWDxup+ErTEv01Zk0/rmMwLS8tQFvvfpFSz2+MOUOu RjnQUu4HeB/4nGy4Lv6QToTwP+UBvaOgKsCwrkSL3MN4HlkJbtL/NerCmGaYacvhVi+J lHbNtobRzgrtH9W+uII46nvL1HfgIQeWJAKY30Z2+LA1eq7OHonzh15VN6MpSFKvFTg4 rbfK/jyBIKVcsAywZQQt8F2tV76paBYrbpEQuAetXhd/kEYdyVK65IPWWQKVdAX4l6TQ oijUISrdLqIU4M4N6I3dSPFL9CzgWuV9iyPgoLCEKZhqvRm/9u1JlIfO3MB03D+1Glp4 vh8w== X-Gm-Message-State: AC+VfDzBR0407M5R7Xqgbl4jxwui9otATgoaGDyq6tu+z8+7GSV1ELd9 Bu+dj7buy05sM8GbBEaKGIogyN+/20A= X-Google-Smtp-Source: ACHHUZ40vYgpSBKgnsqUKG4z7dBiWLR/NY4OPgzSeG2TkOgPzabfXY1XoiHkCzsuVnUnxnzRXGzvUa1mMg8= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:6d24:3efd:facc:7ac4]) (user=surenb job=sendgmr) by 2002:a17:902:ecc5:b0:1a6:6bdb:b542 with SMTP id a5-20020a170902ecc500b001a66bdbb542mr4742101plh.9.1682960133566; Mon, 01 May 2023 09:55:33 -0700 (PDT) Date: Mon, 1 May 2023 09:54:21 -0700 In-Reply-To: <20230501165450.15352-1-surenb@google.com> Mime-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230501165450.15352-12-surenb@google.com> Subject: [PATCH 11/40] 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, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.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, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4E647C001C X-Rspam-User: X-Stat-Signature: bdgt39e848nxr4dydwih6x8u6snwph9g X-HE-Tag: 1682960134-585161 X-HE-Meta: U2FsdGVkX19wbCLqWFdsPRAWAXasZRxH9iT53eIPNI7c2iELGy0yXZc4z5fEnoDmGYcDal5srJpP5VzXf0yuKBsOQstrKpRWgYH+t52cAfaUus+tQKl2AEGRY8acDDjuMlvr1WeEw8mHUR1vmAE1Do1jYA7ICjsZILWTyHNDh0+XeVceAaEJxt1zow9Cr9rxp6VkDFuJMLTA96fDmFXbpbVaeuD2sCfRN//iXOG4oBwmFkLluuLBDSE+IQh9ZcpLF/BhgPO1hrSMrKQ1d5hj+tNrEfpS8H/FC1K1cuPhss+ABz9yqNFthPaYnkz6LRVAqsJxZwOgIYbLXM4gn0G3u9d2hhheFREa52jQvpYQIjBpQfuIKnx8R6KFPSs+Gr3xWxyoN8j/QRnltApi4xzedUhwSA3y9ywPdZG3vbjksotObAF0Ow4ZnwJtQ8ulzHDg5wDCy0fNh1kcdDOPfequfIGKO86qKPk8StE+gwW6nosUSfgR8X8mLw3Dfw1LFYkC8YHkgjds5tI1K7BpX8mBKLxh5Sd/wfeCPbaQywqGZg5Vodz5nKnrX3EKDc5AherSoIaulTxTdSTMY/U+z+tRpFMbaWX5UWXn8yv2ayCm+TWlG4OymAuJKFMMm9l3YSs0P5WpWaeYFEbwS6utL/I4hS+w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spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/slab.h | 6 ++++++ mm/slab_common.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mm/slab.h b/mm/slab.h index 25d14b3a7280..b1c22dc87047 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -450,6 +450,12 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p) if (!need_slab_obj_ext()) return NULL; + if (s->flags & SLAB_NO_OBJ_EXT) + return NULL; + + if (flags & __GFP_NO_OBJ_EXT) + return NULL; + slab = virt_to_slab(p); if (!slab_obj_exts(slab) && WARN(alloc_slab_obj_exts(slab, s, flags, false), diff --git a/mm/slab_common.c b/mm/slab_common.c index f11cc072b01e..42777d66d0e3 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -220,6 +220,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)