From nobody Fri Jun 12 23:47:48 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010000.outbound.protection.outlook.com [52.101.56.0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12F3B23B62B for ; Sat, 25 Apr 2026 02:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.0 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082951; cv=fail; b=dI0O7wCfHicZzmVj0SUE5wJ7VFE9DxZD+HijngPTbMpLCIjRU+JZsWZ40cHaZxKFsSV074FLeQ53c+DzdyFprvbhzL3wlPOyaLfWm73HoinmBsbDZm2oulZY4o1cdlLRsR96oRYON2Ioi11AKRWTjJ9Uc0qbCcVkqKLzjGgIdWw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082951; c=relaxed/simple; bh=GF99cym6BcsJzMqAC92rbRUApk1AHaNEpXyNsrKTr2Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=fD0ihykk3HAO9eQYMQhe3HvMPN5U3n3Vs1/5U7RluFANrd2y/2Y5BcwF4WeIPGhTK9jyYOPki5nq38SW9wA5eSguocUXxMC9KyHywnhjceDYG+Wo3ij8YZtjaBfNDcd1U8VJc6Mjx7tPFzcPI73AQhtpcF3WUYO8YQOCLsrRxBE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Z60s5VK9; arc=fail smtp.client-ip=52.101.56.0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Z60s5VK9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xDP0l43vSoSoVhID/dbnQEmHM66Bmu4f5x4/SN3q60Q/c3v/5/I92NOpJgWHCkQX2U7cD1xVl6sS9+r2pBH9wfXIrBJYnZ8Do7uPpbQcfdxLVv6kcB3YBB3eRM+Qb1AJKlRR8d864SEA8BTiE6hw2wPUsYePiY1t3j3tAAT5tdJwdMhmIdrlwYlT/Ai/sWH8xTCYivk2pp9PEys5TnjT+Ubuc/O1eJ0w3753ZMyV8ucnpQtv2cNR7wzvgiLo/+B7Zs/tI53eZoi5wEJrxjii7ndGnwTlxPoBWUDI1jfoqZrTe5Rb8yPrgSoJ7o3SpbhrXbOad68n6OVGB163wZNt0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zLs0PFiqxrBFaA5JzVMc7JnZbrtl6uGalInGywMifNo=; b=WiNugSzyYKpO742Tvh6xymmglpe429eUJ7timm7pfa89ghMbOY+7NYpW05IP8Y7WXN/Za96aV6oj20Q532d3QLLbaGBPMwSUXmjUskybAkV0fMgXiYFhsyNrO8L/wntUnWBl2IqAyqAD6wjSKiOaDmpz+uiN08qreUo+uXU4JI6kvbdc/HoKwO3ZntGHpKPj5yCMnBZmmtHBQggKCS+PpMh4j2xTNCb8wx9SUpReQWH3Ch0PFyO4G3iPCFKtGj/clCbVpf+NcujysW/jNCTfj9n8n6/1b79qk96tWf+JOeJ9gniqR99z4wYgY6/cY8SmLSFgzTAAydmr0f4uj1pFUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zLs0PFiqxrBFaA5JzVMc7JnZbrtl6uGalInGywMifNo=; b=Z60s5VK9QIkVjI7thsmtP7LpIkMRePArnx5jlUpyvLkC98PtVtKrxkQDF2Xex7vlqd0efT68t2Kl8cwbbuPI+mj7NqSCbQxew8DTEB34L5gTuFVIEANKULpwPvZUjBh43af9/GFktofSCAivKYhkEk/mkUM1WoIkwRCLxJx13FJ+yFhqqWg8z1fFps4v/5Buqi4D0RnI50W+uDDdNcZEtPsr7bhZbJUERz4VZkDg05yxN2SQ/c+GYdfeiezipfYwvlTQUEjti4G/CHzxou4PoYRiZtfWolVoUJjsY84I2NFOTN09j1Pa4BQK3Z/wrzWCPj7gzJzHqwG2op/yCu6ykQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) by IA0PR12MB8227.namprd12.prod.outlook.com (2603:10b6:208:406::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.22; Sat, 25 Apr 2026 02:09:05 +0000 Received: from CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de]) by CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de%3]) with mapi id 15.20.9846.021; Sat, 25 Apr 2026 02:09:04 +0000 From: Yury Norov To: Andrew Morton , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , Alice Ryhl , Viktor Malik , Randy Dunlap , David Laight , linux-kernel@vger.kernel.org Cc: Yury Norov , "Christophe Leroy (CS GROUP)" , Yury Norov Subject: [PATCH v2 1/3] rust: uaccess: use INLINE_COPY_TO_USER to guard copy_to_user() Date: Fri, 24 Apr 2026 22:08:55 -0400 Message-ID: <20260425020857.356850-2-ynorov@nvidia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260425020857.356850-1-ynorov@nvidia.com> References: <20260425020857.356850-1-ynorov@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0067.namprd03.prod.outlook.com (2603:10b6:408:fc::12) To CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR12MB8300:EE_|IA0PR12MB8227:EE_ X-MS-Office365-Filtering-Correlation-Id: 1214a74a-30c3-4390-6cf3-08dea26fa047 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|10070799003|1800799024|7416014|376014|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: 0K1/f1u28ZyI9c9jTLaPxHcTClCuZeUhlvxqr1o4ax9AHzZlj8twi7zHr2xMakH0zC7oosVacd+cqZCRgOz89tDGiq9jCLtwnq2/aiT9+wTxe5GHB41kVAGahTGcNPVRWJIohKJJ+AK3jyg2TUXiK2toM3IWItdBu2GyfgBoERoQOCLf0LM3iFi3bc9KgugX1x2YlgSFizeEdk0zdmovpb7dQ9aXZdCe25CWtpmlC4EDSZnhUoHSUDpB8b5bJOPGH4+2tcBe3kBihgwrhmNbB3GyEPMMz6yA6F3QRkGBV5p13Eer36kZNGPVjobxYWLskExiL5o+CLXvUD6c/r9TZLgRuFmLY9GVUmRBPCfzzdCh+p1ouOdan6jrxtrxU/ynKO16y/Anp4M3ythtOomrDjoQs4fnaolakdCw49nD1XI5stTLurYQRvWgnLVWoBTJtChKypT8u22lZ8FiJPeL0NO8f394R5YzGn6mKZpsuFS6MMs4VK9XBdQCMUBhq84N8p14fWbDRoi1MuXgF5dX0ZZrO5z2XHK7BtUdYnpU5SJDh/se0Ha89+kR+jZYej+VhcG5n5A78IT9sIjJue8Ny2QrOE3r2vzfDsi9hxDscd5//508vdBYuak0grU5Snahr77USkdkemW8/MAd17W3onHADviiiC7Zl2QCpY5D8mZSTz8BAUOKcJ0eWALjSrevoZ73gYFsmNGWcw11OEyox1xRLlY5KTD9H4kGh/bn0kY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR12MB8300.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(1800799024)(7416014)(376014)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?W9rue8JL/TrkDf1unpE8TCs3tF7i4T4XRHTP+np/qZp7fg7AfeH2vPYH9bcM?= =?us-ascii?Q?fb0Elq9BeBxutw43FvLMrNWkQbjjFs2m3nNVhyUvwwsAmIhl4zS1KK2r2Hbs?= =?us-ascii?Q?RiPn6WXHz3GJUcxNcZ6IGGtyoTcJ65NQBmydVKoH1u4fhwcDW2C1lu0Z1YQB?= =?us-ascii?Q?9qvsLzHCOlazKNN+3gQScqOAX25ZGT2K81S8Fh03u/vLbqX2ufhwGd9JAhCs?= =?us-ascii?Q?LzrCxgFlSgZnUj2kXVrp/XE8yrvmTTg90EgKEEtRXnbxCTNZFKnrauccprrF?= =?us-ascii?Q?YLM3Klw5IH2tXvn/48sV0CmQmIY63C88v89uT+V0SO7o4Xlq/tRgYjjkqJ+l?= =?us-ascii?Q?3p04+YH5EWDAcCuL6DkBp2D/tfMLIHH/4LkdxFeI68+GJcBtTQXHrA75tExs?= =?us-ascii?Q?CwgN4kE5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gGrnp0TpYz96+bQOBzth?= =?us-ascii?Q?zt1mUHkjCJFIGkW5JSXfnPBH/U652dut5y7YQsNXcnYax2NrR0aPucM8JCqH?= =?us-ascii?Q?QpFlDI5qJmKthrAfMWUuYDIjai4tSMR9hDjISUpdYFjLNeohJiXwMn7gAjQG?= =?us-ascii?Q?DHn43NbELEBETGQ5F6rvM3eizs8/ooLR1Vy6hlNgzfg7UAJfiStCcdWz5VCo?= =?us-ascii?Q?7YAacTXZhzdtAYSjlaAo6dF8o8QNoufFroCfu7uGc9HDW4vtxtghZcfhjH3m?= =?us-ascii?Q?5pAWGqzWRfAY/jZKT++paGD3bJ8sX6SwAk17nW/4iRJ+1fpK/dHTj5M/34JF?= =?us-ascii?Q?8rlV2jHQi/t2WXTeZjf+tHQZ0gTntVVhX+5PimZCesxvfrr+kSkKE1P1jn62?= =?us-ascii?Q?wxOZfAphwv+GztX6hAjfB6Bxu1UO6+PQfg1Tdicm2yVnaq1uSluxKW/CrRYZ?= =?us-ascii?Q?vDH/IgFmG+OvlSc1GsNeqvS6b4j3I4bBKGhmAcac40rbi5phHSgt?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1214a74a-30c3-4390-6cf3-08dea26fa047 X-MS-Exchange-CrossTenant-AuthSource: CY8PR12MB8300.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2026 02:09:04.8725 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rpIdf8mljU878blguXknIzxHKhhjENTEnFjzaa2deu3CBUK4Vx2+5afy924INY8zXqZ0I/v1f50CIAsLftMWGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8227 Content-Type: text/plain; charset="utf-8" The copy_to_user() rust helper is only needed when the main kernel inlines the function. It is controlled by INLINE_COPY_TO_USER, but the rust helper is protected with INLINE_COPY_FROM_USER. Fix that. Reported-by: Christophe Leroy (CS GROUP) Closes: https://lore.kernel.org/all/746c9c50-20c4-4dc9-a539-bf1310ff9414@ke= rnel.org/ Fixes: d99dc586ca7c7 ("uaccess: decouple INLINE_COPY_FROM_USER and CONFIG_R= UST") Signed-off-by: Yury Norov Reviewed-by: Alice Ryhl --- rust/helpers/uaccess.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c index d9625b9ee046..aff22f16ab38 100644 --- a/rust/helpers/uaccess.c +++ b/rust/helpers/uaccess.c @@ -20,7 +20,9 @@ unsigned long rust_helper__copy_from_user(void *to, const= void __user *from, uns { return _inline_copy_from_user(to, from, n); } +#endif =20 +#ifdef INLINE_COPY_TO_USER __rust_helper unsigned long rust_helper__copy_to_user(void __user *to, const void *from,= unsigned long n) { --=20 2.51.0 From nobody Fri Jun 12 23:47:48 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010000.outbound.protection.outlook.com [52.101.56.0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BE77244692 for ; Sat, 25 Apr 2026 02:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.0 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082953; cv=fail; b=dgWdYAlLQ1Wp/oIMhzTlTjGWYCUSuXIcJ8oQ4OKfVlOUzv2eY9XxgMOyU0f5iXOElRLloy/qlPYHOCwn/411oMRDzOmXxG3N6wo2AY6lH5mt5x1+oxweXPbxgBOY67/gQBqTV+n98Rh8SsIyAfNrHUq+6sTzbXuOPJ5Yyo6Hqhs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082953; c=relaxed/simple; bh=9grEdu3QiI6YyIPLcUgByf6bEFrxXTl+Jg8PUb5MAek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=c9bw/VCQOJObG3zW1OI9/E3HZUsb5CouRNcvO8Q6lHjEItM1MM5xtuqttzZs63OtUJjb5F7sWae0Ff45rJPUSNp8sdC3Zx1ly0RdMnhNc8TfhneKIzDe1A6lnkyr6ha6WA/gWsWHLJyPCf0rgaIz2huVbwVRJ4SnsDbsK8Mxk5w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YU6r/YCX; arc=fail smtp.client-ip=52.101.56.0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YU6r/YCX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xJ2wbFax6s0NoVQt2/YxyVwQNXUdKcu6KzZ8S+4XFhYVWqRm57UKTCczA1AZcFCdQCW0wf0FA5lNFFJKirXDZr7WMviSiurMiuPJBjz+B0UaNAeg97fgijs3G0sH+LSLMboTQSlfPR4Llw4Z+et8Z2XV6sMDcsSPPBirCHtuN/A/ToD+Qa3g67/lDhdyeoBbJ9AYAk5qV6WN58fv4/+bE7NQVuE+VFhTP17PHWHqvdh3DcR+QuCCAAhh1eunTzWxeXhumtIiJun+YfJn9IxW76nMrB9wKUQlEWaexebTSV3UAlSiD56MVLhtVuxE34YO57ASciMiKDptySbke0TPhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZyTkozxEOneAnSInOqRH06ehMR7Clfi/JxUxS14jLXM=; b=RNKZn7JOhtMM3HzAdLNxxSOTtM1CMFsA+eiRvmbcuTwxpWRtdtw7OdkyhzY/QMBQYYJIEhfdKCBNgeFSntExZUjSBqrnJOKxUMGDRgUvBB65L86IWPEKruEuwjVzYIJkAlFUU0cKJlMYdGoXBoEDjRpp8ahOFI9XcVlGPkraIt8N2RY9IZlkCgDb/fVGrn0ntwHgaY7/U4mL4KWs/SrsDTpOsarNyGccedXLNqGINdDXNQGQywQ6Yjscagf1d6EPO1fU3b9QizPUpF52NRxs+9dikbRove/Qt1lOqpmBHd0Ajp6uV1ivq1lLeMqLG3C4lntu5FyKznWGYxxN3yHOLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZyTkozxEOneAnSInOqRH06ehMR7Clfi/JxUxS14jLXM=; b=YU6r/YCXYkLMGPOSA6LFl5QRrONOcaViTJpV65BZGHKf5Thw7i0jyYZNj8YpfhP64GMZhHvPfKP9bRxFqTH+AUIF5sAPm+NS1zlasDhngUJxyot3rcX6DeGyZpglrtfOnC5/0wC7bIwfJeBnDilLnyPmrqF8yOZf9mWshjlQlW9KIgjy3AJIS0/gCdCGA11sxcAeYNg9NWIzVX0X0q+Mwf2LGD0M5XCRAlZCPzHA4O5tYWAVkVgstfgzytqFfzJMKjNhbwT5IO+tltzB4zE5ywk5MfhKOfWC6+Cb+e2nw9P1F+/u1Ov2kFdYQs1nYHEhaP+qn9UZz7PQinUIL4r+Ow== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) by IA0PR12MB8227.namprd12.prod.outlook.com (2603:10b6:208:406::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.22; Sat, 25 Apr 2026 02:09:07 +0000 Received: from CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de]) by CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de%3]) with mapi id 15.20.9846.021; Sat, 25 Apr 2026 02:09:07 +0000 From: Yury Norov To: Andrew Morton , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , Alice Ryhl , Viktor Malik , Randy Dunlap , David Laight , linux-kernel@vger.kernel.org Cc: Yury Norov , "Christophe Leroy (CS GROUP)" , Yury Norov Subject: [PATCH v2 2/3] uaccess: unify inline vs outline copy_{from,to}_user() selection Date: Fri, 24 Apr 2026 22:08:56 -0400 Message-ID: <20260425020857.356850-3-ynorov@nvidia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260425020857.356850-1-ynorov@nvidia.com> References: <20260425020857.356850-1-ynorov@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0127.namprd03.prod.outlook.com (2603:10b6:408:fe::12) To CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR12MB8300:EE_|IA0PR12MB8227:EE_ X-MS-Office365-Filtering-Correlation-Id: e2cdab32-3474-48cb-32b0-08dea26fa1b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|10070799003|1800799024|7416014|376014|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: zxBK6vXUw2ghwH/y+Q8ZyzQfXXfICgHoKf/lgLHJOQYemz9xgrZ2Np7+S7khySc//f86mdxpP1y+0Ukzn1xvPP0wAVRQMeVsyYN8IypEc54mbHnw++aqWo4pSBDgWhO6RJntH386YQg1Nekh/8ELMw0p9C87QySTJdKTZ/yiVEc435RIWBA+iNiYzkw5/Hp2JFo+wh7ZAN9NMsid/YDWaddnGOgQnP2xRIMotLuqYs7YxuyumNT/VLr+kCMfqp6CmlOy7eFEHKj6vLBUsK1uFtbvCK232v8VIsIcWe0WAtjDY5ARDw0T/+YIELWAwc7kKl40jaktBtbkyMGHiZFheGHrVm0Zb7PzR9MptHVSzsyn1jHJrwc7XCA+VFy4bIs3duCan5BodOo2cwEX23LJ+TPWsZ6J6LLEXPLErLt5X7Az/4JhqbgbT1jZa8cehj/LK+Z0jwckuI3sMyuIOstNkhtDskIcp5v9Pk35Juk4BqYVbhCmh9b/6wimlSlG+KK8iJh00phhmoHQ815+WU4MtG5kL7qowuMfVo+7EClr2IZeDp06fbeNPHCSiICX8yQ5/y0Rp55IIWmJRrZ4MuftlY2P9v/iqzLIPlzPBbvpdJRdOmq5srySeSMqfHhL4mFQ2DWhueJgowkqgtFo8S5JoXkAdeKuDWa9c5lv6kv7iinLSHPON8+B5k+EyBZh8VZL+64+jb4tHSBFK4rLqrBRqDqgg5Y7DtgF7O4Hur0GVj8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR12MB8300.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(1800799024)(7416014)(376014)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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HpAH5X4x2pddr2Gb7Q6LG?= =?us-ascii?Q?vtu/ZXb+0MdO7NoRddWNi2d2F+hkMHBgwpvJ/T9426heFRILaqjr?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2cdab32-3474-48cb-32b0-08dea26fa1b5 X-MS-Exchange-CrossTenant-AuthSource: CY8PR12MB8300.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2026 02:09:07.2832 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5ikif/LlqvwhFsZ+fxIJep4Y2vM5gKqosVq3iVOqZ/SU/wb9oeZ/2YBd+fauwTh4OPZvZO8noMFuEYuGliBbag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8227 Content-Type: text/plain; charset="utf-8" The kernel allows arches to select between inline and outline implementations of the copy_{from,to}_user() by defining individual INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER, correspondingly. However, all arches enable or disable them always together. Without the real use-case for one helper being inlined while the other outlined, having independent controls is excessive and error prone. Switch the codebase to the single unified INLINE_COPY_USER control. Tested-by: Alice Ryhl Signed-off-by: Yury Norov --- arch/arc/include/asm/uaccess.h | 3 +-- arch/arm/include/asm/uaccess.h | 3 +-- arch/arm64/include/asm/uaccess.h | 3 +-- arch/hexagon/include/asm/uaccess.h | 3 +-- arch/loongarch/include/asm/uaccess.h | 3 +-- arch/m68k/include/asm/uaccess.h | 3 +-- arch/microblaze/include/asm/uaccess.h | 3 +-- arch/mips/include/asm/uaccess.h | 3 +-- arch/nios2/include/asm/uaccess.h | 3 +-- arch/openrisc/include/asm/uaccess.h | 3 +-- arch/parisc/include/asm/uaccess.h | 3 +-- arch/s390/include/asm/uaccess.h | 3 +-- arch/sh/include/asm/uaccess.h | 3 +-- arch/sparc/include/asm/uaccess_32.h | 3 +-- arch/sparc/include/asm/uaccess_64.h | 3 +-- arch/um/include/asm/uaccess.h | 3 +-- arch/xtensa/include/asm/uaccess.h | 3 +-- include/asm-generic/uaccess.h | 3 +-- include/linux/uaccess.h | 12 ++++++------ lib/usercopy.c | 4 +--- rust/helpers/uaccess.c | 4 +--- 21 files changed, 26 insertions(+), 48 deletions(-) diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index 1e8809ea000a..6df2209541ac 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -628,8 +628,7 @@ static inline unsigned long __clear_user(void __user *t= o, unsigned long n) return res; } =20 -#define INLINE_COPY_TO_USER -#define INLINE_COPY_FROM_USER +#define INLINE_COPY_USER =20 #define __clear_user __clear_user =20 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index d6ae80b5df36..1593cf3b9800 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -616,8 +616,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) } #define __clear_user(addr, n) (memset((void __force *)addr, 0, n), 0) #endif -#define INLINE_COPY_TO_USER -#define INLINE_COPY_FROM_USER +#define INLINE_COPY_USER =20 static inline unsigned long __must_check clear_user(void __user *to, unsig= ned long n) { diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uacc= ess.h index b0c83a08dda9..9f5bd9c69c24 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -456,8 +456,7 @@ do { \ unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ } while (0) =20 -#define INLINE_COPY_TO_USER -#define INLINE_COPY_FROM_USER +#define INLINE_COPY_USER =20 extern unsigned long __must_check __arch_clear_user(void __user *to, unsig= ned long n); static inline unsigned long __must_check __clear_user(void __user *to, uns= igned long n) diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/= uaccess.h index bff77efc0d9a..1aecf60ec4f5 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -26,8 +26,7 @@ unsigned long raw_copy_from_user(void *to, const void __u= ser *from, unsigned long n); unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n); -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long coun= t); #define __clear_user(a, s) __clear_user_hexagon((a), (s)) diff --git a/arch/loongarch/include/asm/uaccess.h b/arch/loongarch/include/= asm/uaccess.h index 438269313e78..428f373feabf 100644 --- a/arch/loongarch/include/asm/uaccess.h +++ b/arch/loongarch/include/asm/uaccess.h @@ -292,8 +292,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) return __copy_user((__force void *)to, from, n); } =20 -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 /* * __clear_user: - Zero a block of memory in user space, with less checkin= g. diff --git a/arch/m68k/include/asm/uaccess.h b/arch/m68k/include/asm/uacces= s.h index 64914872a5c9..31d133faa45e 100644 --- a/arch/m68k/include/asm/uaccess.h +++ b/arch/m68k/include/asm/uaccess.h @@ -377,8 +377,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) return __constant_copy_to_user(to, from, n); return __generic_copy_to_user(to, from, n); } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 #define __get_kernel_nofault(dst, src, type, err_label) \ do { \ diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/includ= e/asm/uaccess.h index 3aab2f17e046..afa0dd8d013f 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h @@ -250,8 +250,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) { return __copy_tofrom_user(to, (__force const void __user *)from, n); } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 /* * Copy a null terminated string from userspace. diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uacces= s.h index c0cede273c7c..f00c36676b73 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h @@ -433,8 +433,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) return __cu_len_r; } =20 -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 extern __kernel_size_t __bzero(void __user *addr, __kernel_size_t size); =20 diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uacc= ess.h index 6ccc9a232c23..5e6e05cc6efc 100644 --- a/arch/nios2/include/asm/uaccess.h +++ b/arch/nios2/include/asm/uaccess.h @@ -57,8 +57,7 @@ extern unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n); extern unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n); -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 extern long strncpy_from_user(char *__to, const char __user *__from, long __len); diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/as= m/uaccess.h index d6500a374e18..db934ebc0069 100644 --- a/arch/openrisc/include/asm/uaccess.h +++ b/arch/openrisc/include/asm/uaccess.h @@ -218,8 +218,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long size) { return __copy_tofrom_user((__force void *)to, from, size); } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 extern unsigned long __clear_user(void __user *addr, unsigned long size); =20 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/ua= ccess.h index 6c531d2c847e..0d17f81c8b27 100644 --- a/arch/parisc/include/asm/uaccess.h +++ b/arch/parisc/include/asm/uaccess.h @@ -197,7 +197,6 @@ unsigned long __must_check raw_copy_to_user(void __user= *dst, const void *src, unsigned long len); unsigned long __must_check raw_copy_from_user(void *dst, const void __user= *src, unsigned long len); -#define INLINE_COPY_TO_USER -#define INLINE_COPY_FROM_USER +#define INLINE_COPY_USER =20 #endif /* __PARISC_UACCESS_H */ diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uacces= s.h index dff035372601..a9f32c53f699 100644 --- a/arch/s390/include/asm/uaccess.h +++ b/arch/s390/include/asm/uaccess.h @@ -30,8 +30,7 @@ void debug_user_asce(int exit); #define uaccess_kmsan_or_inline __always_inline #endif =20 -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 static uaccess_kmsan_or_inline __must_check unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long size) diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h index a79609eb14be..02e7a066538e 100644 --- a/arch/sh/include/asm/uaccess.h +++ b/arch/sh/include/asm/uaccess.h @@ -95,8 +95,7 @@ raw_copy_to_user(void __user *to, const void *from, unsig= ned long n) { return __copy_user((__force void *)to, from, n); } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 /* * Clear the area and return remaining number of bytes diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/u= access_32.h index 43284b6ec46a..5542d5b32994 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h @@ -190,8 +190,7 @@ static inline unsigned long raw_copy_from_user(void *to= , const void __user *from return __copy_user((__force void __user *) to, from, n); } =20 -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 static inline unsigned long __clear_user(void __user *addr, unsigned long = size) { diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/u= access_64.h index b825a5dd0210..e2989cfba626 100644 --- a/arch/sparc/include/asm/uaccess_64.h +++ b/arch/sparc/include/asm/uaccess_64.h @@ -231,8 +231,7 @@ unsigned long __must_check raw_copy_from_user(void *to, unsigned long __must_check raw_copy_to_user(void __user *to, const void *from, unsigned long size); -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 unsigned long __must_check raw_copy_in_user(void __user *to, const void __user *from, diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index 0df9ea4abda8..4417c8b1d37a 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h @@ -27,8 +27,7 @@ static inline int __access_ok(const void __user *ptr, uns= igned long size); #define __access_ok __access_ok #define __clear_user __clear_user =20 -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 #include =20 diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/ua= ccess.h index 56aec6d504fe..6538a29a2bbd 100644 --- a/arch/xtensa/include/asm/uaccess.h +++ b/arch/xtensa/include/asm/uaccess.h @@ -237,8 +237,7 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) prefetch(from); return __xtensa_copy_user((__force void *)to, from, n); } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER =20 /* * We need to return the number of bytes not cleared. Our memset() diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index b276f783494c..4569045e7139 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -91,8 +91,7 @@ raw_copy_to_user(void __user *to, const void *from, unsig= ned long n) memcpy((void __force *)to, from, n); return 0; } -#define INLINE_COPY_FROM_USER -#define INLINE_COPY_TO_USER +#define INLINE_COPY_USER #endif /* CONFIG_UACCESS_MEMCPY */ =20 /* diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 56328601218c..6100f1046546 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -84,7 +84,7 @@ * the 6 functions (copy_{to,from}_user(), __copy_{to,from}_user_inatomic(= )) * that are used instead. Out of those, __... ones are inlined. Plain * copy_{to,from}_user() might or might not be inlined. If you want them - * inlined, have asm/uaccess.h define INLINE_COPY_{TO,FROM}_USER. + * inlined, have asm/uaccess.h define INLINE_COPY_USER. * * NOTE: only copy_from_user() zero-pads the destination in case of short = copy. * Neither __copy_from_user() nor __copy_from_user_inatomic() zero anything @@ -157,7 +157,7 @@ __copy_to_user(void __user *to, const void *from, unsig= ned long n) } =20 /* - * Architectures that #define INLINE_COPY_TO_USER use this function + * Architectures that #define INLINE_COPY_USER use this function * directly in the normal copy_to/from_user(), the other ones go * through an extern _copy_to/from_user(), which expands the same code * here. @@ -190,7 +190,7 @@ _inline_copy_from_user(void *to, const void __user *fro= m, unsigned long n) memset(to + (n - res), 0, res); return res; } -#ifndef INLINE_COPY_FROM_USER +#ifndef INLINE_COPY_USER extern __must_check unsigned long _copy_from_user(void *, const void __user *, unsigned long); #endif @@ -207,7 +207,7 @@ _inline_copy_to_user(void __user *to, const void *from,= unsigned long n) } return n; } -#ifndef INLINE_COPY_TO_USER +#ifndef INLINE_COPY_USER extern __must_check unsigned long _copy_to_user(void __user *, const void *, unsigned long); #endif @@ -217,7 +217,7 @@ copy_from_user(void *to, const void __user *from, unsig= ned long n) { if (!check_copy_size(to, n, false)) return n; -#ifdef INLINE_COPY_FROM_USER +#ifdef INLINE_COPY_USER return _inline_copy_from_user(to, from, n); #else return _copy_from_user(to, from, n); @@ -230,7 +230,7 @@ copy_to_user(void __user *to, const void *from, unsigne= d long n) if (!check_copy_size(from, n, true)) return n; =20 -#ifdef INLINE_COPY_TO_USER +#ifdef INLINE_COPY_USER return _inline_copy_to_user(to, from, n); #else return _copy_to_user(to, from, n); diff --git a/lib/usercopy.c b/lib/usercopy.c index b00a3a957de6..e2f0bf104a59 100644 --- a/lib/usercopy.c +++ b/lib/usercopy.c @@ -12,15 +12,13 @@ =20 /* out-of-line parts */ =20 -#if !defined(INLINE_COPY_FROM_USER) +#if !defined(INLINE_COPY_USER) unsigned long _copy_from_user(void *to, const void __user *from, unsigned = long n) { return _inline_copy_from_user(to, from, n); } EXPORT_SYMBOL(_copy_from_user); -#endif =20 -#if !defined(INLINE_COPY_TO_USER) unsigned long _copy_to_user(void __user *to, const void *from, unsigned lo= ng n) { return _inline_copy_to_user(to, from, n); diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c index aff22f16ab38..6e59cc9c665c 100644 --- a/rust/helpers/uaccess.c +++ b/rust/helpers/uaccess.c @@ -14,15 +14,13 @@ rust_helper_copy_to_user(void __user *to, const void *f= rom, unsigned long n) return copy_to_user(to, from, n); } =20 -#ifdef INLINE_COPY_FROM_USER +#ifdef INLINE_COPY_USER __rust_helper unsigned long rust_helper__copy_from_user(void *to, const void __user *fro= m, unsigned long n) { return _inline_copy_from_user(to, from, n); } -#endif =20 -#ifdef INLINE_COPY_TO_USER __rust_helper unsigned long rust_helper__copy_to_user(void __user *to, const void *from,= unsigned long n) { --=20 2.51.0 From nobody Fri Jun 12 23:47:48 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010000.outbound.protection.outlook.com [52.101.56.0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F678248F73 for ; Sat, 25 Apr 2026 02:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.0 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082954; cv=fail; b=Clj+oHL/FnHA2j4q0mhwIPdFr03LLlbZ2AraF+/IOjru9U5jvzTHKN/fnNNd9jATva6Q/aIszzBoIP+RJizWhrngoERR4+NHbs/1c2p8GNEvLEfSnA18unl4okvmL7gFPNSME7OTrN4PUyZtmzIZVtSQotbTKnjs3GbexK7ZtYM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082954; c=relaxed/simple; bh=zAqHaUNpr3DLyQrWFZ9xty3t9GIRFH/6CtDBDozDqco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=DQHMZSJ0Q0USuRu9pFpcBMmNmGPyiKEd7G6uIcJHMzBnDViQtf9SkLi4fKyzhJQ5Gs/ZxSIHe6oHNjWiMfYl/AivxaQ5Uz8MPwZsq7w/jDrZ66MUu6uMTIBYWI+1D7co5Rf9O3hIYCP4lTuoOzVJynMdzYsE+yVazvMQm5VK3bk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=e5Jy94/Z; arc=fail smtp.client-ip=52.101.56.0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="e5Jy94/Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iPzjkhZqMTVgIcOyVxT+0HpEkX2naJZvJ6TrsJHHmF497XTzJgST1kLmmPgd8tmkrwv26Q877n2DTbeRzHLhvPU5y+cZouTceE4JSxNa55vrjoj27VCIL9HG8BRNLsJZOQWpIYip/XA/jMUp1M/j4SGuJZLfsgzalXK+AZqfn35fyJMyvtlcyPMtsscYhcxWbVFz9BJl1jk/1ktPMLY4Ln7Bgn/vuxXyhorJsCanjU1tYOYAwi38WgL5BF502pB7n4M2BJIwCmXpD+RSVJJKbULzgkLLffIRLXA8WnW40M2VjMR8/z+9SejaGTvvDuIa7ubZuX3BTy5Kg1+K4v519Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PRzR7TNsqtrYsbeOwxunIihaCLU3JScv9Wlyyv6wgcM=; b=tAMGMyWY4tF83UyvsuKPSn/azh4KDDbWx68BOMTfsQbgeXtTAwgrIsfMd3IEuGqLOFhpFAJwpL398VswQLS1J49x6ghsrNEUX1mmUNi9U51Eg10TUmu43J5rsmeOEj1+gYI28dUAEmfFc94RxPScdZM/rAQpZelUd2JfG2D0JuJK7EPigd/1pREgZ5G1+/X36Xrafj3lauEuarkTpVlG2S+lKcgCGtwhHFhlz0c+HHUkNeRqkL2uk0y1hM37rcypbJuLggey+NF/F+cfDC7eGlhxET7hNCPy6Q2ImsFFlHAdl+3xTHpyMoiZck/ttM1DSUV5Jfn4ArgiQ5ve2iPp/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PRzR7TNsqtrYsbeOwxunIihaCLU3JScv9Wlyyv6wgcM=; b=e5Jy94/ZTh2s8Fw+AzZxjRpWapkGg66Ezd5IFTpkfpS4+HR7y+ocRf6x69i0xlWIVoDeYsiIIqIYsw7YgoLBzfXBPcQBnczTalyxISoS31NtJVS/CnLOfWll+e7raYG1LTTp1ieRC3ttdiW7Y2r/BzlTHsMlRIUfhWYDOuCkaO/J1I/eccWfdHx7KENr52zh5jcPD/rGpBQzw/s6+awVKKaA0y+/GGEKQfWcWEjPrH+y3OxQgRxsQBmGFybbTEeJ3SRrhnspd5fCaTxhjnJyrkjmDB1LjShz/6T4AZkARBLI6ugsrK+YdOqigqyHA6yhLTsTeEtOTy9G3IbU2wTlRw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) by IA0PR12MB8227.namprd12.prod.outlook.com (2603:10b6:208:406::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.22; Sat, 25 Apr 2026 02:09:09 +0000 Received: from CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de]) by CY8PR12MB8300.namprd12.prod.outlook.com ([fe80::ce75:8187:3ac3:c5de%3]) with mapi id 15.20.9846.021; Sat, 25 Apr 2026 02:09:09 +0000 From: Yury Norov To: Andrew Morton , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , Alice Ryhl , Viktor Malik , Randy Dunlap , David Laight , linux-kernel@vger.kernel.org Cc: Yury Norov , "Christophe Leroy (CS GROUP)" , Yury Norov Subject: [PATCH v2 3/3] uaccess: minimize INLINE_COPY_USER-related ifdefery Date: Fri, 24 Apr 2026 22:08:57 -0400 Message-ID: <20260425020857.356850-4-ynorov@nvidia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260425020857.356850-1-ynorov@nvidia.com> References: <20260425020857.356850-1-ynorov@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0453.namprd03.prod.outlook.com (2603:10b6:408:139::8) To CY8PR12MB8300.namprd12.prod.outlook.com (2603:10b6:930:7d::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR12MB8300:EE_|IA0PR12MB8227:EE_ X-MS-Office365-Filtering-Correlation-Id: ac59bc74-43ce-437e-0195-08dea26fa2ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|10070799003|1800799024|7416014|376014|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: FH4DFZPRK9HyisD1/kFQCSOKz+B1vt5bRCOn6ismdIF2UKzLEtA9m8GJZ05+l1+EJuXvPGIDG0BBFtPpl5axWtn43awBrUnW4siJFOlHqXC9/rfFmx4HO2t9UuWkww8Hf5t0Qa6EoppFv9DOURg9NLQzzH6z773TddFMXENIct8bAA0y7xZxxKNS+ngVZTLLgWJdhuSVGLjNY06cLCDGRJ2/8A99xYNi/4Akblufc1Tv0yaJvhbiA8G6Lu6VvxeExjYQa9W/8jW2uldl81szR8ocdSb2jtMrTHmP+gi/KXyJlofx4/c/Cu9IeDi3XjeGO6iM7fpOzrKFmaHGOAstE2FAAjUHKtHXJuBTlcj2PS+5dFVexm7QUevETYS9HpmA8OdaXj3rDkCTqq7vXtf7cqbaUFj/+QdLCTZFRJBW6g/p2xfrldEuN53QeeVaawYqdGd+pUCuCB7XwAbp3shF3Kg1WEQmWeKwIFDOk51+NB2h9F/AQ8iafchhbwknCdywIjt5W0NGlmwHva3bXtbId+o9j6x7Ib2xmlp4sANCbi6aH1jxeeU/Tsl5fvdquBgrld0gQ2AXkYuJIMyvVitfSPZ2jC16L1t8O8rMT9BCYK+TKIhERvCRrcnj2tuS0T/fAkGLJ0AWXHsdUi01gaEcT0NAX7q3Vig89qtBxxeWY6ZZhT/MW0/oSfW2JqESdp+PLgNv5ldt2HWvaRZl2YasGpIFHUyRV34Qbrh0pJKqfww= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR12MB8300.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(1800799024)(7416014)(376014)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?G3+yzhLhg33pgBLrCwbyEef6kTzdqqpPEQpux0UtU5lTIjNGEk+BK8vGRJe6?= =?us-ascii?Q?5YHANkMpxiTqwpVLuI4KSxtob68A2aVqsxqm7rXaaRJqumF8E9pB8c1SxHav?= =?us-ascii?Q?H+zjHCHsql4bMF5KHoJD4dLGEz55zxrY3v6R7u6t9yIdyXCd1vJAmSZdhsnL?= =?us-ascii?Q?wjpYBTEJ4UJQPnTJXyr9IqzL4iasvMoLl64bW3u0tHJZ3qhArxr3O6pH9nGZ?= =?us-ascii?Q?kucJRwF16KLPB3znXshD2i9s/eGo0BZaLRMAkhsUEiyWvHtEViLptDMgcOAc?= =?us-ascii?Q?7xphx0Cha5nREnLRHOPBfqa8mI7t1pjghf8/6+HS16MAWqeTzQdFPAFzUmT7?= =?us-ascii?Q?7qvWIuzv2Ejcm7swIMVwheU7mBkD3XJa6q6y/VA/ai61E8y4dvskxv7BaNxZ?= =?us-ascii?Q?8AOA3+rzKNgdVc6DBLcwfEwmJ/BPhOv4Wk9B4IkRMGBLMDV0csg7+vMwp02n?= =?us-ascii?Q?q5NQBXvpELCG4u+3D92rcy/F4Q32Rl50v8pbZ6PYv1vfyR7figI5XvCaoaUD?= =?us-ascii?Q?LT2EYN9h0rvDP64pY6zwYvoMrVcTCNB2r0T0lMml7uZmbd7/IH/aQV/39qjX?= =?us-ascii?Q?T8r1HD3y2CeOrABahyQRT1eVpBrDxnWvuaHODY2SqH0deFBYNQAFEaoxFhf1?= =?us-ascii?Q?t17kTkRwip4YaHB13C8NFjQPXhExvz7+wQaifaVmEQ9TNmHFWL7O/RwJWa1P?= =?us-ascii?Q?FjJmLEEn0tS95jccXtBqCzT3DTiNhSWZTJ1ArElqMVSBcsr1coXTNiCC/rCt?= =?us-ascii?Q?JPeBr3nL/mxG8FGXcQvDAFnCMmAM7tDJQ0sm4fpfrmGRhgQGtGy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R0coQOpSS1fwQjV8Yz3o3Ds5H38i9Sboap?= =?us-ascii?Q?HYb++1ePxAAkE9tTlBsqFSx6/VnPJqjPbkX1nv4Dh/5lh/g/gw2g?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac59bc74-43ce-437e-0195-08dea26fa2ff X-MS-Exchange-CrossTenant-AuthSource: CY8PR12MB8300.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2026 02:09:09.3812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Lxbnp3njmbcuZkwVUDcYvD464G7TPwBTxo7PwffdtiL0k3ycrSPD28YfBwnTkFjIBAkPYw3vVYgjtemsJubpQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8227 Content-Type: text/plain; charset="utf-8" Now that we've got the same config selecting inline vs outline copy_to_user() and copy_from_user(), we can simplify the corresponding logic in the uaccess.h. Fixes: 1f9a8286bc0c ("uaccess: always export _copy_[from|to]_user with CONF= IG_RUST") Tested-by: Alice Ryhl Signed-off-by: Yury Norov --- include/linux/uaccess.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 6100f1046546..e0c3d6e29301 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -190,10 +190,6 @@ _inline_copy_from_user(void *to, const void __user *fr= om, unsigned long n) memset(to + (n - res), 0, res); return res; } -#ifndef INLINE_COPY_USER -extern __must_check unsigned long -_copy_from_user(void *, const void __user *, unsigned long); -#endif =20 static inline __must_check unsigned long _inline_copy_to_user(void __user *to, const void *from, unsigned long n) @@ -207,7 +203,13 @@ _inline_copy_to_user(void __user *to, const void *from= , unsigned long n) } return n; } -#ifndef INLINE_COPY_USER +#ifdef INLINE_COPY_USER +# define _copy_to_user _inline_copy_to_user +# define _copy_from_user _inline_copy_from_user +#else +extern __must_check unsigned long +_copy_from_user(void *, const void __user *, unsigned long); + extern __must_check unsigned long _copy_to_user(void __user *, const void *, unsigned long); #endif @@ -217,11 +219,7 @@ copy_from_user(void *to, const void __user *from, unsi= gned long n) { if (!check_copy_size(to, n, false)) return n; -#ifdef INLINE_COPY_USER - return _inline_copy_from_user(to, from, n); -#else return _copy_from_user(to, from, n); -#endif } =20 static __always_inline unsigned long __must_check @@ -229,12 +227,7 @@ copy_to_user(void __user *to, const void *from, unsign= ed long n) { if (!check_copy_size(from, n, true)) return n; - -#ifdef INLINE_COPY_USER - return _inline_copy_to_user(to, from, n); -#else return _copy_to_user(to, from, n); -#endif } =20 #ifndef copy_mc_to_kernel --=20 2.51.0