From patchwork Tue Mar 5 10:10:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13581912 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 24015C54798 for ; Tue, 5 Mar 2024 10:10:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C071D6B0099; Tue, 5 Mar 2024 05:10:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B67B26B009C; Tue, 5 Mar 2024 05:10:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BB3F6B009A; Tue, 5 Mar 2024 05:10:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 822886B0095 for ; Tue, 5 Mar 2024 05:10:35 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5383040DEA for ; Tue, 5 Mar 2024 10:10:35 +0000 (UTC) X-FDA: 81862566030.07.50A82B2 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 56BFE80011 for ; Tue, 5 Mar 2024 10:10:33 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Z7F4AqBL; spf=pass (imf02.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709633433; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YqypDeuefMJmnQ8sf5GSNnN+8VJFJPXjvaUOYfHLyEk=; b=p0E22ATK92k7j5G/Xa4wAFE66HqrhNKnfVSJZaZXdtkmT8rkGPni/Y6/gCeufu16RlN1ls NDAlBL8Z2kERDO4VdnDjCP4gn5O3yGHbFg5mke4itVOnKKjTFkV0Fp+SfGjFbAeGuRaGIE Dez3ZgqDrYuKYKF1ZTA/D97jvlY/Bys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709633433; a=rsa-sha256; cv=none; b=1QOiKX0NrTM6dSdP31xmPS1d7eIsf0aYQJakhv+mVB1q4kIEUCQgOtR4nZ74Ly7UItY1KZ 6c49xRIj9u6enfvk1d7QyclhGQQ9SlFzRVpuu9Fn7hYt7enRkHd5NouZT0uL6jTTzfpHWA lBPKdEfwctfRiEd4gDil+j+mlgDEQS8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Z7F4AqBL; spf=pass (imf02.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-5c229dabbb6so374483a12.0 for ; Tue, 05 Mar 2024 02:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709633432; x=1710238232; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YqypDeuefMJmnQ8sf5GSNnN+8VJFJPXjvaUOYfHLyEk=; b=Z7F4AqBL+TqMLzt9CUsTOOGSjjgGQkUFpGbYl5ZQyp7cXTV/urTPQpVQ1SnNKA88t8 RayI9ozW+TTr/E1wTWk6vFRp+GXyY5DAXL6kZuNTfYWJiECVZcuMkTfgTcUUMIfsvGkj LPJancC5d94IfrIJJvInC7OeLLFnN+UBs0iAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709633432; x=1710238232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YqypDeuefMJmnQ8sf5GSNnN+8VJFJPXjvaUOYfHLyEk=; b=HLX5qLRS5RMy1Xyg1XFg9mPyHFVET8RFCOm0KqiCnYn4xgmMvec2RZTq31G5ERw6ox G1o+FgTlx/C39+KR4LahSu8JMUQRr9LM0irDXiHHQqSdhIBPdP/gJBkg2X2C1VKD0IGF gIYKLHEkTviJBiZdku/tp4AOyS2MOyuOWVh8EhvcFcnuWRgPAjQ6x+w29yKFotR15Jim S/LT9l4hqVHmchy+pPlSI7OuOaMwBTOb/H+boVtrdC4F+f26bx3ThOq6petzXDelltSA X1Lolt7MVTP8z+r3kDjOWokDfkf9bT0tf2IvwLavpzqYH3vyL1zQ3w7VWbkYOHtAOdd0 JzqQ== X-Forwarded-Encrypted: i=1; AJvYcCXXKl62MNWX5296aSyFcDPSCwwzhSc3NtrnPn4mmTLVsWi+CtWTcd1G655N6hnHtKjHReYwB6yGvvbFU7DweUejYKM= X-Gm-Message-State: AOJu0YxTRBFgMjzIxOcjfdA39fehMn9/l1DWY5NGYP+MGj76yydHcruM ggQFL7TIRriw41hJfdjmZqwsup+UOmpSHMCq8b8Mefise9HPGY0NPMdnzeVNug== X-Google-Smtp-Source: AGHT+IGeJZyVJ09gI9gdMeeZa2TNl9QqRwg39EBpS2gnYKvxtqTdu16IIH+Z1sVU6rZsLUOu3KxERg== X-Received: by 2002:a17:90a:2c8:b0:299:ecd0:483b with SMTP id d8-20020a17090a02c800b00299ecd0483bmr8668816pjd.10.1709633432154; Tue, 05 Mar 2024 02:10:32 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id h8-20020a17090a3d0800b00299be0e00c1sm12409317pjc.33.2024.03.05.02.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:10:30 -0800 (PST) From: Kees Cook To: Vlastimil Babka Cc: Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, "GONG, Ruiqi" , Xiu Jianfeng , Suren Baghdasaryan , Kent Overstreet , Jann Horn , Matteo Rizzo , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 5/9] slab: Introduce kmem_buckets_alloc() Date: Tue, 5 Mar 2024 02:10:21 -0800 Message-Id: <20240305101026.694758-5-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305100933.it.923-kees@kernel.org> References: <20240305100933.it.923-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1274; i=keescook@chromium.org; h=from:subject; bh=qg6+zLyXOvclDNk40orVz0UwK8KHs3WN88KHdjuAoYc=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBl5u+QePW1cikxrAkyTkNPDsM7P6WLLogreKw78 DkUscrwcj2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZebvkAAKCRCJcvTf3G3A JkIeD/9SGhc8L8n+b0l4YrTF1D9VoErEfn1Ca1UNFW/W0gggb8pmBG/YuAzR/noRa8vP/Obacdv xX/kz3RVVUNa5CYWF20lMDU/Lp8oLF05rVXs0+FZ7Y+Hj4NcwGb4ZDEcTwKpevYm7+jo9WEDQ5d zMSamVXJp/wkyr1XfGZ7cxjHlDRKSjdplhbJgG0UpihMCnecqlqWCXwJbsKgeaEq4Sl26MCcrlM K0ULjcAvpm6F3d4s636IjEqcvuIG1obEke1QFfbVJC5/dJduyyEKm1Lgraw5dGP56FR+aC56qjS 65EMTIxf1kNAW+Fy8bPuL7WDntcwNqNENqpozW05vn4+JPT/wOhqoVmXjQZ3DQfbw1ikOaWsuGR +wrVI1e9aMbAxyN+NV6Dk09hIjGge2x1xZ4ikVrEqfYiJl/PlZG1rZ3YtAjKzVhhHSlziq1EXO7 eLtSu666WzevVuCoqb7mheOeAM4BFhlrgwfm+ZnWU0YM/Ycmrv70Q8134urLdvFSqmvc8qAL1CF xi+VJmmdh42aZ/SeMDt4C3lJogV3xKZGfmixjPA3HWDF8q7OPo6tVZ0GK5r+TW9BmbGeL5G/Mz5 ehqYwoqpMNk2S8s4t7WPvdOakD8dz8vt+onslIuOlwmQgDswizHCZFv3m2uwtvVSPNlj7ZIDrUi W3INC3N8UCVkL0g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspamd-Queue-Id: 56BFE80011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gu8f8grcthsrify85wrdy8ink863w3nb X-HE-Tag: 1709633433-99752 X-HE-Meta: U2FsdGVkX188L0rLxYSakOHks2gMcV9oRKZ9/GTB+4zjJgL5BAnnDAVQhIfqh1BBfk64x2hy7WsVabZXllM4w7Mn6ZsejNjFA3I8mWhNo6dsqFwtWnWYfsEiFtZzKQeni9rjjv4/0BfG/EYuD/2JiQgNzTKBo7joGbj2jplwF0bpO3WlFovdaMh18wjTTjmcM9/Eyd4DQfxuXSQxTEcavNUc9w+3qHXsq8OWl/8HCYTIzYlbkNxbngI7vQ4pOzGqWtu39ZV8TYZrnVZwxRsxRaoNfR1mQuU4klhDLuOCRPhXTYXrT92EyRdG6w/D62zMPopBmcfQm5qq03ZOiA5Cw1Pwr05Hho7sc0FrnjiAmTfhEZ+0H+XEFh60vVKNdKm5nU4bH70lcMPzL2rOtGgwPfcqQsk/7uVJUVy06f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iUAfYdniuwWOEs562R1iBbH+6ZTWO53JMcrgzrN8A1F7QX/4dJHTwVT2Fh1Cwm5n1faCMqHf8cC5vrc13KO7vLC3p5D4rs87TgfX0e67VxzFc1uKV6lIp4hym1OktFj/8IV4NUn8bk3mjUeG3n5uZRNPNEZubNHKdmVEyBfu7VDKBELMi/TjGLMQj5PcEQbr38EZ3pAMKhLrWogBTj9EsGDREnavwGdcAsFAvcwoWIvhUpeJ12Vm0yOoeJuLfdSbDsE7tv+LB0AvLQSE3lR4tfXjoukLDBIhpUE8DVrRv178wQ0yf+jsehIxCqMTS1N/zxIUVOJGZ1KYkMtPT25eQasIPa9iUijma2YyFGP40ttH2nJl5KvI+flrf8Iy80= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To perform allocations with the buckets allocated with kmem_buckets_create(), introduce kmem_buckets_alloc() which behaves like kmem_cache_alloc(). Signed-off-by: Kees Cook --- Cc: Vlastimil Babka Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org --- include/linux/slab.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/slab.h b/include/linux/slab.h index 058d0e3cd181..08d248f9a1ba 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -600,6 +600,12 @@ static __always_inline __alloc_size(1) void *kmalloc(size_t size, gfp_t flags) return __kmalloc(size, flags); } +static __always_inline __alloc_size(2) +void *kmem_buckets_alloc(kmem_buckets *b, size_t size, gfp_t flags) +{ + return __kmalloc_node(b, size, flags, NUMA_NO_NODE); +} + static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) { if (__builtin_constant_p(size) && size) {