[PATCH] powerpc: Fix __clear_user() with KUAP enabled
Andrew Donnellan
ajd at linux.ibm.com
Tue Dec 10 00:26:20 AEDT 2019
On 9/12/19 10:50 pm, Christophe Leroy wrote:
>> -extern unsigned long __clear_user(void __user *addr, unsigned long
>> size);
>> +extern unsigned long clear_user_asm(void __user *addr, unsigned long
>> size);
>> static inline unsigned long clear_user(void __user *addr, unsigned
>> long size)
>> {
>> @@ -409,12 +409,17 @@ static inline unsigned long clear_user(void
>> __user *addr, unsigned long size)
>> might_fault();
>> if (likely(access_ok(addr, size))) {
>> allow_write_to_user(addr, size);
>> - ret = __clear_user(addr, size);
>> + ret = clear_user_asm(addr, size);
>> prevent_write_to_user(addr, size);
>> }
>
> What about changing the above by the following ?
>
> if (likely(access_ok(addr, size))) ret =
> __clear_user(addr, size);
>
>> return ret;
>> }
>> +static inline unsigned long __clear_user(void __user *addr, unsigned
>> long size)
>> +{
>> + return clear_user(addr, size);
>> +}
>> +
>
> Then
>
> static inline unsigned long __clear_user(void __user *addr, unsigned
> long size)
> {
> allow_write_to_user(addr, size);
> ret = clear_user_asm(addr, size);
> prevent_write_to_user(addr, size);
>
> return ret;
> }
This is exactly the patch I initially wrote, I ran it past mpe privately
and he suggested aliasing clear_user() -> __clear_user() instead, as
there's not much point keeping a separate path around for a single user
for a basically non-existent performance gain.
--
Andrew Donnellan OzLabs, ADL Canberra
ajd at linux.ibm.com IBM Australia Limited
More information about the Linuxppc-dev
mailing list