From: Linus Torvalds
> Sent: 22 November 2024 19:35
> 
> On Fri, 22 Nov 2024 at 11:13, Linus Torvalds
> <torva...@linux-foundation.org> wrote:
> >
> > I've only compiled it so far, about to actually boot into it.
> 
> Looks fine. Sent out a proper patch with commit message etc at
> 
>    
> https://lore.kernel.org/all/20241122193305.7316-1-torva...@linux-foundation.org/
> 
> because it looks good to me. Comments?

+static __always_inline int futex_read_inatomic(u32 *dest, u32 __user *from)
+{
+       u32 val;
+
+       if (can_do_masked_user_access())
+               from = masked_user_access_begin(from);
+       else if (!user_read_access_begin(from, sizeof(*from)))
+               return -EFAULT;
+       unsafe_get_user(val, from, Efault);
+       user_access_end();
+       *dest = val;
+       return 0;
+Efault:
+       user_access_end();
+       return -EFAULT;
+}
+
+static inline int futex_get_value_locked(u32 *dest, u32 __user *from)
+{
+       int ret;
+
+       pagefault_disable();
+       ret = futex_read_inatomic(dest, from);
+       pagefault_enable();
+
+       return ret;
+}

Is there an 'unsafe_get_user_nofault()' that uses a trap handler
that won't fault in a page?
That would save the inc/dec done by pagefault_en/disable().

I'd also have thought that the trap handler for unsafe_get_user()
would jump to the Efault label having already done user_access_end().
But maybe it doesn't work out that way?

        David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

Reply via email to