lkml.org 
[lkml]   [2021]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] futex: Fix fault_in_user_writeable()
    Date
    fault_in_user_writeable() should verify R/W access but only verify W. In
    most archs W implies R, but not true in MIPS and LoongArch, so fix it.

    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
    ---
    kernel/futex.c | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/kernel/futex.c b/kernel/futex.c
    index 2ecb07575055..c3b68be31bf3 100644
    --- a/kernel/futex.c
    +++ b/kernel/futex.c
    @@ -672,10 +672,15 @@ static int get_futex_key(u32 __user *uaddr, bool fshared, union futex_key *key,
    */
    static int fault_in_user_writeable(u32 __user *uaddr)
    {
    - struct mm_struct *mm = current->mm;
    int ret;
    + struct mm_struct *mm = current->mm;
    + struct vm_area_struct *vma;

    mmap_read_lock(mm);
    + vma = find_vma(mm, (unsigned long)uaddr);
    + if (!(vma->vm_flags & VM_READ))
    + ret = -EFAULT;
    +
    ret = fixup_user_fault(mm, (unsigned long)uaddr,
    FAULT_FLAG_WRITE, NULL);
    mmap_read_unlock(mm);
    --
    2.27.0
    \
     
     \ /
      Last update: 2021-08-16 08:55    [W:5.190 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site