From nobody Wed Dec 17 09:26:38 2025 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A28A3101DC; Thu, 6 Nov 2025 11:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762429805; cv=none; b=XSEOHY1D3xP3j0aiVM+K+8yI6/ZDgPRTMZTcBGjgKgODGJ3gElcNATPbtU7EvMwCgZdfVo3+zkjqESVFzSrChwjkrbejJtnzEjIejNnVIOAbr/6L9aqGovNIgW9Ib2DOC/6CooMjvsLS2NGdDlA1P2axw3iM0odPaDqR1P1D0Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762429805; c=relaxed/simple; bh=fcju2KL6HfO0NoLFgdd2flZ1YHYvh2/fvlhLhAc9ihw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gA7o1EfuqscgPnvgr+l1D4zGyhE9JCKadCkySXYgcrTA0/3ft0lhCYPvMu534ZbFvQCYlGqH2W5JgXjaOoEsgtb8WsSLawOqRFz5WuMBmGD93c3ZpMssAEieuOfnQixfiGH7B/xjT7glZoDS8K+7vOLeZidc8q3aI63cFMiJXf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub4.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4d2KmR2KScz9sSq; Thu, 6 Nov 2025 12:32:23 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dbnuwnZTfd4H; Thu, 6 Nov 2025 12:32:23 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4d2KmK2sQ3z9sSj; Thu, 6 Nov 2025 12:32:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 49CEC8B77B; Thu, 6 Nov 2025 12:32:17 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id NxNpllOkh-J7; Thu, 6 Nov 2025 12:32:17 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 740078B78F; Thu, 6 Nov 2025 12:32:16 +0100 (CET) From: Christophe Leroy To: Alexander Viro , Christian Brauner , Jan Kara , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , "Andre Almeida" , Andrew Morton , Eric Dumazet , Kuniyuki Iwashima , Paolo Abeni , Willem de Bruijn , "David S. Miller" , Jakub Kicinski , Simon Horman , Daniel Borkmann , Dave Hansen , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v4 06/10] powerpc/uaccess: Remove {allow/prevent}_{read/write/read_write}_{from/to/}_user() Date: Thu, 6 Nov 2025 12:31:24 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5385; i=christophe.leroy@csgroup.eu; h=from:subject:message-id; bh=fcju2KL6HfO0NoLFgdd2flZ1YHYvh2/fvlhLhAc9ihw=; b=owGbwMvMwCV2d0KB2p7V54MZT6slMWTytGvJqyis8VimY+Bl2hUyL/T7hr5VeYvuX8gLN3Y2r GmIP+bcUcrCIMbFICumyHL8P/euGV1fUvOn7tKHmcPKBDKEgYtTACaiU8rIsGvavIyK6M3XFY50 LpoTeGfdwblrL67i+X5kQ7FNxU9zXR+Gv9JGZYXrxO8ozzmprXDyxryFat7l558s+HRhr1F4+oe pzHwA X-Developer-Key: i=christophe.leroy@csgroup.eu; a=openpgp; fpr=10FFE6F8B390DE17ACC2632368A92FEB01B8DD78 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The six following functions have become simple single-line fonctions that do not have much added value anymore: - allow_read_from_user() - allow_write_to_user() - allow_read_write_user() - prevent_read_from_user() - prevent_write_to_user() - prevent_read_write_user() Directly call allow_user_access() and prevent_user_access(), it doesn't reduce the readability and it removes unnecessary middle functions. Signed-off-by: Christophe Leroy --- v2: New --- arch/powerpc/include/asm/kup.h | 47 ------------------------------ arch/powerpc/include/asm/uaccess.h | 30 +++++++++---------- 2 files changed, 15 insertions(+), 62 deletions(-) diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h index 3963584ac1cf1..4a4145a244f29 100644 --- a/arch/powerpc/include/asm/kup.h +++ b/arch/powerpc/include/asm/kup.h @@ -131,53 +131,6 @@ static __always_inline void kuap_assert_locked(void) kuap_get_and_assert_locked(); } =20 -static __always_inline void allow_read_from_user(const void __user *from, = unsigned long size) -{ - allow_user_access(NULL, KUAP_READ); -} - -static __always_inline void allow_write_to_user(void __user *to, unsigned = long size) -{ - allow_user_access(to, KUAP_WRITE); -} - -static __always_inline void allow_read_write_user(void __user *to, const v= oid __user *from, - unsigned long size) -{ - allow_user_access(to, KUAP_READ_WRITE); -} - -static __always_inline void prevent_read_from_user(const void __user *from= , unsigned long size) -{ - prevent_user_access(KUAP_READ); -} - -static __always_inline void prevent_write_to_user(void __user *to, unsigne= d long size) -{ - prevent_user_access(KUAP_WRITE); -} - -static __always_inline void prevent_read_write_user(void __user *to, const= void __user *from, - unsigned long size) -{ - prevent_user_access(KUAP_READ_WRITE); -} - -static __always_inline void prevent_current_access_user(void) -{ - prevent_user_access(KUAP_READ_WRITE); -} - -static __always_inline void prevent_current_read_from_user(void) -{ - prevent_user_access(KUAP_READ); -} - -static __always_inline void prevent_current_write_to_user(void) -{ - prevent_user_access(KUAP_WRITE); -} - #endif /* !__ASSEMBLER__ */ =20 #endif /* _ASM_POWERPC_KUAP_H_ */ diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/= uaccess.h index 3e622e647d622..7846ee59e3747 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -45,14 +45,14 @@ do { \ __label__ __pu_failed; \ \ - allow_write_to_user(__pu_addr, __pu_size); \ + allow_user_access(__pu_addr, KUAP_WRITE); \ __put_user_size_goto(__pu_val, __pu_addr, __pu_size, __pu_failed); \ - prevent_write_to_user(__pu_addr, __pu_size); \ + prevent_user_access(KUAP_WRITE); \ __pu_err =3D 0; \ break; \ \ __pu_failed: \ - prevent_write_to_user(__pu_addr, __pu_size); \ + prevent_user_access(KUAP_WRITE); \ __pu_err =3D -EFAULT; \ } while (0); \ \ @@ -302,9 +302,9 @@ do { \ \ might_fault(); \ barrier_nospec(); \ - allow_read_from_user(__gu_addr, __gu_size); \ + allow_user_access(NULL, KUAP_READ); \ __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ - prevent_read_from_user(__gu_addr, __gu_size); \ + prevent_user_access(KUAP_READ); \ (x) =3D (__typeof__(*(ptr)))__gu_val; \ \ __gu_err; \ @@ -331,9 +331,9 @@ raw_copy_in_user(void __user *to, const void __user *fr= om, unsigned long n) unsigned long ret; =20 barrier_nospec(); - allow_read_write_user(to, from, n); + allow_user_access(to, KUAP_READ_WRITE); ret =3D __copy_tofrom_user(to, from, n); - prevent_read_write_user(to, from, n); + prevent_user_access(KUAP_READ_WRITE); return ret; } #endif /* __powerpc64__ */ @@ -343,9 +343,9 @@ static inline unsigned long raw_copy_from_user(void *to, { unsigned long ret; =20 - allow_read_from_user(from, n); + allow_user_access(NULL, KUAP_READ); ret =3D __copy_tofrom_user((__force void __user *)to, from, n); - prevent_read_from_user(from, n); + prevent_user_access(KUAP_READ); return ret; } =20 @@ -354,9 +354,9 @@ raw_copy_to_user(void __user *to, const void *from, uns= igned long n) { unsigned long ret; =20 - allow_write_to_user(to, n); + allow_user_access(to, KUAP_WRITE); ret =3D __copy_tofrom_user(to, (__force const void __user *)from, n); - prevent_write_to_user(to, n); + prevent_user_access(KUAP_WRITE); return ret; } =20 @@ -367,9 +367,9 @@ static inline unsigned long __clear_user(void __user *a= ddr, unsigned long size) unsigned long ret; =20 might_fault(); - allow_write_to_user(addr, size); + allow_user_access(addr, KUAP_WRITE); ret =3D __arch_clear_user(addr, size); - prevent_write_to_user(addr, size); + prevent_user_access(KUAP_WRITE); return ret; } =20 @@ -397,9 +397,9 @@ copy_mc_to_user(void __user *to, const void *from, unsi= gned long n) { if (check_copy_size(from, n, true)) { if (access_ok(to, n)) { - allow_write_to_user(to, n); + allow_user_access(to, KUAP_WRITE); n =3D copy_mc_generic((void __force *)to, from, n); - prevent_write_to_user(to, n); + prevent_user_access(KUAP_WRITE); } } =20 --=20 2.49.0