From patchwork Thu Sep 5 07:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13791891 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 22139CD4F5B for ; Thu, 5 Sep 2024 07:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A72E36B0281; Thu, 5 Sep 2024 03:57:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A207B6B0283; Thu, 5 Sep 2024 03:57:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C1CC6B0284; Thu, 5 Sep 2024 03:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6CA676B0281 for ; Thu, 5 Sep 2024 03:57:50 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DD33980F76 for ; Thu, 5 Sep 2024 07:57:49 +0000 (UTC) X-FDA: 82529930658.28.9F1B927 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 2B1C01A0005 for ; Thu, 5 Sep 2024 07:57:48 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IV4vVsui; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725522939; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=78WvKHtyeiLYAwLH+95slKbH/rNgHFKK4/5wlAaE8fc=; b=5DR2Ismem+gaXiA4JStopL8rMzQehay634cJo4/YH1SSlD7bPhZqhYqBbNkrlAOV18INWW 7793gsKvp8zM5dOpqWqe8M4y/RANUPYOpaNM63eOD3/1yI44W7vmiWRG6S0kNrzyAOiToH X2UBqHUkQs7crlhlxg/rTyZs2cMgIlI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IV4vVsui; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725522939; a=rsa-sha256; cv=none; b=hbIt9gBEZ8rhQnQwIbmK9fq0cK7uqv+0cM3NsPMZU2//LfRYAl5EwqkUgC18jNNDAgbyFL PysMSu9tzKIGf5RNGovKaLsmgQBHJ2jzSsAy7K6JuBgPzeqtvHJYzhSitoRbkaqNXtkViP FXUAfYm86LAeptG4pdalxjwvx9Zt2X4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F367B5C3A53; Thu, 5 Sep 2024 07:57:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D250C4CECB; Thu, 5 Sep 2024 07:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725523067; bh=TRtSxtRqOM5QvqM+zpubd3lGKKoppNfgu7eGyWI4SSc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IV4vVsuiF90rCnPrP9+D3fjrKdB7nkiU71sfUPuDqDHt7Nt84djcBwn0SvpdezNkT s8NRunt/BRsUKMWxfeqJdGZ5sAM/JrbGl0ilv7KFyPEyhaUi5sd5nRZ4cPW+cQJq73 JJkYqO2Mtk26MOvw28Lmx3oy5lZvOmIoJXIiEMF5tqIBS/DTl7f9F7xs6Z3We7/Upo D5loFUNGZEKdB5hKGPQnbYAUUhJXpd09ZCRWVf29oPY3USCLy09Cxm/mcjcHrbJ1fB O5KIxLW1Q0Djvh+7P7Aqw1aef+KotOa5TUewsPpw/5bgrWZoF0vpC5ZDwaPZXB/kG1 GYM2dMWIdk11Q== From: Christian Brauner Date: Thu, 05 Sep 2024 09:56:54 +0200 Subject: [PATCH v4 11/17] slab: port KMEM_CACHE_USERCOPY() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240905-work-kmem_cache_args-v4-11-ed45d5380679@kernel.org> References: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> In-Reply-To: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport 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, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1473; i=brauner@kernel.org; h=from:subject:message-id; bh=TRtSxtRqOM5QvqM+zpubd3lGKKoppNfgu7eGyWI4SSc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdTPF+IvJk4uvP0VEreI5OXvLo5XUJHsXH71v3RZ+fs yVSb5OmSEcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBE/PkYGV59mvLjgeraKQv/ f/+7OO7NgfUHju9nC2DMN3MzPGZndGIew/+UV9sDP31frXnR7BW7xOSZJduq1dj8zRNWWcZGH/6 fY8kPAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2B1C01A0005 X-Stat-Signature: 1dt7ax7dm8hdzu5986se84xg6he77q1a X-Rspam-User: X-HE-Tag: 1725523068-479878 X-HE-Meta: U2FsdGVkX1/6z12iichPE5Pb1qJMz1s4Xty8WbDX+4rrext6oat9ldqdYXRvHXRRTEFjXw80m4AVebB7eKun/sponPSIql2Fi9bO6tFd3KJudykvQSreYdFYLFK/cx4qv7BryBcT5sIibPcbXKGyaVRZmDc0/G58MjUiCOMIqqVipw1WgGjdtviFmqQeFaSVPR5gVrkauZPag6sDbBSP7R5pI135bratLfLzUd2wQoHHmAU3Hzlf705yF7XENg92ckyeZo8H3fY851M2u7KgSuHpXBBF9COLugbQ8ip66ZTSqkcGPFAZUIBQu+N1NxbapbJ+plfF5TFqU5mQwI5qQeD0vvjoFYJvAOhEU0QYoRXCP7ioeZQ7jQuzGRg/6VhcoIDe8GYV9xrSvgSJfOwJYF17jHwgBnztdxe3tETlNoLQggW2KVoN45UEvwYb0SieQk07bViMP+OD4lSmUSGddzwDKe95Dg0kzzBTdvL9vYLnUasH2D60EB38TeWfPBQNWii6t6ENG+Q5AqJ7cLthM5J6z+HYqgAxc5ulMjD2WEERh3da5ApKW/RpB+8N0ZmQAWwbK4CkE1pQ+pkXEc6QFTb01y0aQQvvrOFG4z9MzxQjKXjei0S34tf8qXE0KZ+gkGwxX7IzAOUJiG6B9y4CEs5TmYdJ3xJynqpRdVUjXsv+6BYOerpabb/oF7VfmQmVCID1O3xgANPuDpQDL3GviAe24DVv5V8iBZ4TdtCfbbDyFAmQAA1mYFZn9FUdevcjYdMDvX69L3bdD+dA4f9jQjxCHAYxdF/RUqAMPukOjSovvXhCrl5SYO5L+WleozMlHSe+goHpNDED+11vM9H0oFfjOHWfe7JZ0NIZgpZYb6g28d+Ee+RJ//nKEY57BYyn+lElhvefDzaC1qB6pPfZ9I5qRPwZImgwNo6Q4Gw0In0PuEBEeqa+uRrNz+dy+2Z8y/m5zaSlZUxfWGJrz96 /2gd4v9T CWbrPb7EMPZiV3c8AZrYB57f2Hnhk4uBS62U7irHr2XJ2iis+YRkEoo8/Vzk9JkjoSRCcJAF+0hRd87MUbIrZi0tsj+0eiwWPfXBeXz+PcfyvdKZtL9JYejagTQOseypgqlhW1ZtuRWDsr41HG38U/9Xkjce+zhvcXC+RNwKIVowxaD29nfFg4Z7nhow9E9e8V8lRodQSLgS3B98J2S7EfXiVbFEXHdBRhY9S9B+osDsx0TjGa2M/4MIZGSYv5CLy8jFWsM/dKC/kDgewdHez68shefzw2VsBh4Ffh50Pzc/zjWe8LQU9E4MjnSdPZ8XezSWgyDEaUbl5sV/OqAmCXsbt+1BOHte4o5DUZDO5EDfJDHAZ7Fzdx3uPSt2am3faH/53/0eSOlclqPg= 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: Make KMEM_CACHE_USERCOPY() use struct kmem_cache_args. Reviewed-by: Kees Cook Reviewed-by: Jens Axboe Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner Reviewed-by: Roman Gushchin --- include/linux/slab.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 97117a2fcf34..cb264dded324 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -293,12 +293,13 @@ int kmem_cache_shrink(struct kmem_cache *s); * To whitelist a single field for copying to/from usercopy, use this * macro instead for KMEM_CACHE() above. */ -#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ - kmem_cache_create_usercopy(#__struct, \ - sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), \ - offsetof(struct __struct, __field), \ - sizeof_field(struct __struct, __field), NULL) +#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ + __kmem_cache_create_args(#__struct, sizeof(struct __struct), \ + &(struct kmem_cache_args) { \ + .align = __alignof__(struct __struct), \ + .useroffset = offsetof(struct __struct, __field), \ + .usersize = sizeof_field(struct __struct, __field), \ + }, (__flags)) /* * Common kmalloc functions provided by all allocators