]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
powerpc: Simplify access_ok()
authorChristophe Leroy (CS GROUP) <chleroy@kernel.org>
Wed, 3 Jun 2026 10:20:14 +0000 (12:20 +0200)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 8 Jun 2026 10:29:02 +0000 (15:59 +0530)
commit90b45dbf59d50e32c4f86072545ff44bec9cb28e
treeac080b983e435f16066e9616f177c2dfa1a16e8a
parent334f3f6d7a1660fd65597bad9960bfa33a716d35
powerpc: Simplify access_ok()

With the implementation of masked user access, we always have a memory
gap between user memory space and kernel memory space, so use it to
simplify access_ok() by relying on access fault in case of an access
in the gap.

Most of the time the size is known at build time.

On powerpc64, the kernel space starts at 0x8000000000000000 which is
always more than two times TASK_USER_MAX so when the size is known at
build time and lower than TASK_USER_MAX, only the address needs to be
verified. If not, a binary or of address and size must be lower than
TASK_USER_MAX. As TASK_USER_MAX is a power of 2, just check that
there is no bit set outside of TASK_USER_MAX - 1 mask.

On powerpc32, there is a garanteed gap of 128KB so when the size is
known at build time and not greater than 128KB, just check that the
address is below TASK_SIZE. Otherwise use the original formula.

Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/f496ba4f309a2fb9fd0d8811e941bbcaf5d196cf.1780482002.git.chleroy@kernel.org
arch/powerpc/include/asm/uaccess.h