lkml.org 
[lkml]   [2014]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH v2 21/29] nios2: Futex operations
    Date
    On Thursday 17 July 2014 18:55:49 Ley Foon Tan wrote:
    > On Tue, Jul 15, 2014 at 6:03 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
    > > On Tue, 15 Jul 2014, Ley Foon Tan wrote:
    > > +static inline int atomic_futex_op_xchg_set(int oparg, u32 __user *uaddr,
    > >> + int *oldval)
    > >> +{
    > >> + unsigned long flags;
    > >> + int ret;
    > >> +
    > >> + local_irq_save(flags);
    > >> +
    > >> + ret = get_user(*oldval, uaddr);
    > >> + if (!ret)
    > >> + ret = put_user(oparg, uaddr);
    > >
    > > This is wrong as it gets. get_user() might fault and sleep.
    > >
    > > You need a proper implementation, which handles fault exceptions.
    > I have checked that we use nios2 specific get_user() in [1]. This
    > function will not sleep and it handles fault exception.
    > I think this should be fine.

    The get_user/put_user functions really need to be annotated might_fault(),
    because that's what they do.

    The whole point of get_user() is to access an unchecked user space
    pointer, which can do a number of things based on what the pointer
    points to:

    - access a user space variable that resides in memory
    - access a kernel pointer and fail because of the access_ok()
    check
    - access a user space pointer that is not mapped and return
    through the __ex_table fixup.
    - access a user space pointer that has a valid VMA but not PTE,
    causing a page fault to be resolved.

    It's the last case that breaks here.

    Arnd


    \
     
     \ /
      Last update: 2014-07-17 13:41    [W:4.293 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site