lkml.org 
[lkml]   [2020]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 01/13] fs/userfaultfd: fix wrong error code on WP & !VM_MAYWRITE
    Date
    From: Nadav Amit <namit@vmware.com>

    It is possible to get an EINVAL error instead of EPERM if the following
    test vm_flags have VM_UFFD_WP but do not have VM_MAYWRITE, as "ret" is
    overwritten since commit cab350afcbc9 ("userfaultfd: hugetlbfs: allow
    registration of ranges containing huge pages").

    Fix it.

    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: io-uring@vger.kernel.org
    Cc: linux-fsdevel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mm@kvack.org
    Fixes: cab350afcbc9 ("userfaultfd: hugetlbfs: allow registration of ranges containing huge pages")
    Signed-off-by: Nadav Amit <namit@vmware.com>
    ---
    fs/userfaultfd.c | 1 +
    1 file changed, 1 insertion(+)

    diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
    index 000b457ad087..c8ed4320370e 100644
    --- a/fs/userfaultfd.c
    +++ b/fs/userfaultfd.c
    @@ -1364,6 +1364,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
    if (end & (vma_hpagesize - 1))
    goto out_unlock;
    }
    + ret = -EPERM;
    if ((vm_flags & VM_UFFD_WP) && !(cur->vm_flags & VM_MAYWRITE))
    goto out_unlock;

    --
    2.25.1
    \
     
     \ /
      Last update: 2020-11-29 01:50    [W:3.095 / U:0.124 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site