[PATCH 3/5] powerpc: Remove unused size parametre to KUAP enabling/disabling functions

Christophe Leroy
2025-06-22T10:20:48Z

Since commit 16132529cee5 ("powerpc/32s: Rework Kernel Userspace
Access Protection") the size parameter is unused on all platforms.

Remove it.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/book3s/32/kup.h | 2 +-
arch/powerpc/include/asm/book3s/64/kup.h | 4 +--
arch/powerpc/include/asm/kup.h | 22 ++++++------
arch/powerpc/include/asm/nohash/32/kup-8xx.h | 2 +-
arch/powerpc/include/asm/nohash/kup-booke.h | 2 +-
arch/powerpc/include/asm/uaccess.h | 36 ++++++++++----------
6 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h
index 4e14a5427a63..8ea68d136152 100644
--- a/arch/powerpc/include/asm/book3s/32/kup.h
+++ b/arch/powerpc/include/asm/book3s/32/kup.h
@@ -98,7 +98,7 @@ static __always_inline unsigned long __kuap_get_and_assert_locked(void)
#define __kuap_get_and_assert_locked __kuap_get_and_assert_locked

static __always_inline void allow_user_access(void __user *to, const void __user *from,
- u32 size, unsigned long dir)
+ unsigned long dir)
{
BUILD_BUG_ON(!__builtin_constant_p(dir));

diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 497a7bd31ecc..853fa2fb12be 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -354,7 +354,7 @@ __bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
}

static __always_inline void allow_user_access(void __user *to, const void __user *from,
- unsigned long size, unsigned long dir)
+ unsigned long dir)
{
unsigned long thread_amr = 0;

@@ -384,7 +384,7 @@ static __always_inline unsigned long get_kuap(void)
static __always_inline void set_kuap(unsigned long value) { }

static __always_inline void allow_user_access(void __user *to, const void __user *from,
- unsigned long size, unsigned long dir)
+ unsigned long dir)
{ }

#endif /* !CONFIG_PPC_KUAP */
diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h
index 2bb03d941e3e..4c70be11b99a 100644
--- a/arch/powerpc/include/asm/kup.h
+++ b/arch/powerpc/include/asm/kup.h
@@ -73,7 +73,7 @@ static __always_inline void __kuap_kernel_restore(struct pt_regs *regs, unsigned
*/
#ifndef CONFIG_PPC_BOOK3S_64
static __always_inline void allow_user_access(void __user *to, const void __user *from,
- unsigned long size, unsigned long dir) { }
+ unsigned long dir) { }
static __always_inline void prevent_user_access(unsigned long dir) { }
static __always_inline unsigned long prevent_user_access_return(void) { return 0UL; }
static __always_inline void restore_user_access(unsigned long flags) { }
@@ -132,36 +132,34 @@ static __always_inline void kuap_assert_locked(void)
kuap_get_and_assert_locked();
}

-static __always_inline void allow_read_from_user(const void __user *from, unsigned long size)
+static __always_inline void allow_read_from_user(const void __user *from)
{
barrier_nospec();
- allow_user_access(NULL, from, size, KUAP_READ);
+ allow_user_access(NULL, from, KUAP_READ);
}

-static __always_inline void allow_write_to_user(void __user *to, unsigned long size)
+static __always_inline void allow_write_to_user(void __user *to)
{
- allow_user_access(to, NULL, size, KUAP_WRITE);
+ allow_user_access(to, NULL, KUAP_WRITE);
}

-static __always_inline void allow_read_write_user(void __user *to, const void __user *from,
- unsigned long size)
+static __always_inline void allow_read_write_user(void __user *to, const void __user *from)
{
barrier_nospec();
- allow_user_access(to, from, size, KUAP_READ_WRITE);
+ allow_user_access(to, from, KUAP_READ_WRITE);
}

-static __always_inline void prevent_read_from_user(const void __user *from, unsigned long size)
+static __always_inline void prevent_read_from_user(const void __user *from)
{
prevent_user_access(KUAP_READ);
}

-static __always_inline void prevent_write_to_user(void __user *to, unsigned long size)
+static __always_inline void prevent_write_to_user(void __user *to)
{
prevent_user_access(KUAP_WRITE);
}

-static __always_inline void prevent_read_write_user(void __user *to, const void __user *from,
- unsigned long size)
+static __always_inline void prevent_read_write_user(void __user *to, const void __user *from)
{
prevent_user_access(KUAP_READ_WRITE);
}
diff --git a/arch/powerpc/include/asm/nohash/32/kup-8xx.h b/arch/powerpc/include/asm/nohash/32/kup-8xx.h
index 46bc5925e5fd..c2b32b392d41 100644
--- a/arch/powerpc/include/asm/nohash/32/kup-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/kup-8xx.h
@@ -50,7 +50,7 @@ static __always_inline void uaccess_end_8xx(void)
}

static __always_inline void allow_user_access(void __user *to, const void __user *from,
- unsigned long size, unsigned long dir)
+ unsigned long dir)
{
uaccess_begin_8xx(MD_APG_INIT);
}
diff --git a/arch/powerpc/include/asm/nohash/kup-booke.h b/arch/powerpc/include/asm/nohash/kup-booke.h
index 0c7c3258134c..6035d51af3cd 100644
--- a/arch/powerpc/include/asm/nohash/kup-booke.h
+++ b/arch/powerpc/include/asm/nohash/kup-booke.h
@@ -74,7 +74,7 @@ static __always_inline void uaccess_end_booke(void)
}

static __always_inline void allow_user_access(void __user *to, const void __user *from,
- unsigned long size, unsigned long dir)
+ unsigned long dir)
{
uaccess_begin_booke(current->thread.pid);
}
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 4f5a46a77fa2..dd5cf325ecde 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_write_to_user(__pu_addr); \
__put_user_size_goto(__pu_val, __pu_addr, __pu_size, __pu_failed); \
- prevent_write_to_user(__pu_addr, __pu_size); \
+ prevent_write_to_user(__pu_addr); \
__pu_err = 0; \
break; \
\
__pu_failed: \
- prevent_write_to_user(__pu_addr, __pu_size); \
+ prevent_write_to_user(__pu_addr); \
__pu_err = -EFAULT; \
} while (0); \
\
@@ -301,9 +301,9 @@ do { \
__typeof__(sizeof(*(ptr))) __gu_size = sizeof(*(ptr)); \
\
might_fault(); \
- allow_read_from_user(__gu_addr, __gu_size); \
+ allow_read_from_user(__gu_addr); \
__get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \
- prevent_read_from_user(__gu_addr, __gu_size); \
+ prevent_read_from_user(__gu_addr); \
(x) = (__typeof__(*(ptr)))__gu_val; \
\
__gu_err; \
@@ -329,9 +329,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
{
unsigned long ret;

- allow_read_write_user(to, from, n);
+ allow_read_write_user(to, from);
ret = __copy_tofrom_user(to, from, n);
- prevent_read_write_user(to, from, n);
+ prevent_read_write_user(to, from);
return ret;
}
#endif /* __powerpc64__ */
@@ -341,9 +341,9 @@ static inline unsigned long raw_copy_from_user(void *to,
{
unsigned long ret;

- allow_read_from_user(from, n);
+ allow_read_from_user(from);
ret = __copy_tofrom_user((__force void __user *)to, from, n);
- prevent_read_from_user(from, n);
+ prevent_read_from_user(from);
return ret;
}

@@ -352,9 +352,9 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
unsigned long ret;

- allow_write_to_user(to, n);
+ allow_write_to_user(to);
ret = __copy_tofrom_user(to, (__force const void __user *)from, n);
- prevent_write_to_user(to, n);
+ prevent_write_to_user(to);
return ret;
}

@@ -365,9 +365,9 @@ static inline unsigned long __clear_user(void __user *addr, unsigned long size)
unsigned long ret;

might_fault();
- allow_write_to_user(addr, size);
+ allow_write_to_user(addr);
ret = __arch_clear_user(addr, size);
- prevent_write_to_user(addr, size);
+ prevent_write_to_user(addr);
return ret;
}

@@ -395,9 +395,9 @@ copy_mc_to_user(void __user *to, const void *from, unsigned long n)
{
if (check_copy_size(from, n, true)) {
if (access_ok(to, n)) {
- allow_write_to_user(to, n);
+ allow_write_to_user(to);
n = copy_mc_generic((void __force *)to, from, n);
- prevent_write_to_user(to, n);
+ prevent_write_to_user(to);
}
}

@@ -415,7 +415,7 @@ static __must_check __always_inline bool user_access_begin(const void __user *pt

might_fault();

- allow_read_write_user((void __user *)ptr, ptr, len);
+ allow_read_write_user((void __user *)ptr, ptr);
return true;
}
#define user_access_begin user_access_begin
@@ -431,7 +431,7 @@ user_read_access_begin(const void __user *ptr, size_t len)

might_fault();

- allow_read_from_user(ptr, len);
+ allow_read_from_user(ptr);
return true;
}
#define user_read_access_begin user_read_access_begin
@@ -445,7 +445,7 @@ user_write_access_begin(const void __user *ptr, size_t len)

might_fault();

- allow_write_to_user((void __user *)ptr, len);
+ allow_write_to_user((void __user *)ptr);
return true;
}
#define user_write_access_begin user_write_access_begin
--
2.49.0