lkml.org 
[lkml]   [2016]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 262/346] alpha: fix copy_from_user()
    3.16.39-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Al Viro <viro@zeniv.linux.org.uk>

    commit 2561d309dfd1555e781484af757ed0115035ddb3 upstream.

    it should clear the destination even when access_ok() fails.

    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    arch/alpha/include/asm/uaccess.h | 19 ++++++++-----------
    1 file changed, 8 insertions(+), 11 deletions(-)

    --- a/arch/alpha/include/asm/uaccess.h
    +++ b/arch/alpha/include/asm/uaccess.h
    @@ -371,14 +371,6 @@ __copy_tofrom_user_nocheck(void *to, con
    return __cu_len;
    }

    -extern inline long
    -__copy_tofrom_user(void *to, const void *from, long len, const void __user *validate)
    -{
    - if (__access_ok((unsigned long)validate, len, get_fs()))
    - len = __copy_tofrom_user_nocheck(to, from, len);
    - return len;
    -}
    -
    #define __copy_to_user(to,from,n) \
    ({ \
    __chk_user_ptr(to); \
    @@ -393,17 +385,22 @@ __copy_tofrom_user(void *to, const void
    #define __copy_to_user_inatomic __copy_to_user
    #define __copy_from_user_inatomic __copy_from_user

    -
    extern inline long
    copy_to_user(void __user *to, const void *from, long n)
    {
    - return __copy_tofrom_user((__force void *)to, from, n, to);
    + if (likely(__access_ok((unsigned long)to, n, get_fs())))
    + n = __copy_tofrom_user_nocheck((__force void *)to, from, n);
    + return n;
    }

    extern inline long
    copy_from_user(void *to, const void __user *from, long n)
    {
    - return __copy_tofrom_user(to, (__force void *)from, n, from);
    + if (likely(__access_ok((unsigned long)from, n, get_fs())))
    + n = __copy_tofrom_user_nocheck(to, (__force void *)from, n);
    + else
    + memset(to, 0, n);
    + return n;
    }

    extern void __do_clear_user(void);
    \
     
     \ /
      Last update: 2016-11-14 04:25    [W:3.831 / U:0.128 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site