Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/futex: Switch to user_access block

Use user_access_begin() instead of the access_ok/allow_access sequence.

This brings the missing might_fault() check.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/6cd202cdc4f939d47822e4ddd3c0856210431a58.1615398498.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
870779f4 164dc6ce

+5 -7
+5 -7
arch/powerpc/include/asm/futex.h
··· 33 33 { 34 34 int oldval = 0, ret; 35 35 36 - if (!access_ok(uaddr, sizeof(u32))) 36 + if (!user_access_begin(uaddr, sizeof(u32))) 37 37 return -EFAULT; 38 - allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); 39 38 40 39 switch (op) { 41 40 case FUTEX_OP_SET: ··· 55 56 default: 56 57 ret = -ENOSYS; 57 58 } 59 + user_access_end(); 58 60 59 61 *oval = oldval; 60 62 61 - prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); 62 63 return ret; 63 64 } 64 65 ··· 69 70 int ret = 0; 70 71 u32 prev; 71 72 72 - if (!access_ok(uaddr, sizeof(u32))) 73 + if (!user_access_begin(uaddr, sizeof(u32))) 73 74 return -EFAULT; 74 - 75 - allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); 76 75 77 76 __asm__ __volatile__ ( 78 77 PPC_ATOMIC_ENTRY_BARRIER ··· 90 93 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) 91 94 : "cc", "memory"); 92 95 96 + user_access_end(); 97 + 93 98 *uval = prev; 94 - prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); 95 99 96 100 return ret; 97 101 }