Messages in this thread | | | Subject | Re: [PATCH] powerpc/mm: Fix KUAP warning by providing copy_from_kernel_nofault_allowed() | From | Christophe Leroy <> | Date | Sat, 5 Dec 2020 13:38:49 +0100 |
| |
Le 05/12/2020 à 10:56, Christophe Leroy a écrit : > > > Le 05/12/2020 à 09:48, Christoph Hellwig a écrit : >> On Sat, Dec 05, 2020 at 08:43:06AM +0000, Christophe Leroy wrote: >>> Since commit c33165253492 ("powerpc: use non-set_fs based maccess >>> routines"), userspace access is not granted anymore when using >>> copy_from_kernel_nofault() >>> >>> However, kthread_probe_data() uses copy_from_kernel_nofault() >>> to check validity of pointers. When the pointer is NULL, >>> it points to userspace, leading to a KUAP fault and triggering >>> the following big hammer warning many times when you request >>> a sysrq "show task": >> >> >> >>> To avoid that, copy_from_kernel_nofault_allowed() is used to check >>> whether the address is a valid kernel address. But the default >>> version of it returns true for any address. >>> >>> Provide a powerpc version of copy_from_kernel_nofault_allowed() >>> that returns false when the address is below TASK_USER_MAX, >>> so that copy_from_kernel_nofault() will return -ERANGE. >> >> Looks good. I wonder if we should just default to the TASK_SIZE_MAX >> check in copy_from_kernel_nofault_allowed for architectures that select >> CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > Yes maybe that would be better. > > Can you cook a patch an get it into 5.10 ? >
In fact it doesn't seem so easy because only s390, powerpc and x86 have TASK_SIZE_MAX while CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE is selected by arm, arm64, powerpc and x86
So maybe for 5.10 we take the powerpc fix ?
Christophe
| |