OSDN Git Service

userfaultfd: clear the vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails
authorAndrea Arcangeli <aarcange@redhat.com>
Fri, 5 Jan 2018 00:18:09 +0000 (16:18 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jan 2018 08:31:17 +0000 (09:31 +0100)
commit319122a71f306943a75217b3e78a9a0f8e9c1e95
tree1e91265fcb42d3e6df3aefd6415b73ca6c69c083
parentc86ee796feed73dfa8a895be48c146b018d14393
userfaultfd: clear the vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails

commit 0cbb4b4f4c44f54af268969b18d8deda63aded59 upstream.

The previous fix in commit 384632e67e08 ("userfaultfd: non-cooperative:
fix fork use after free") corrected the refcounting in case of
UFFD_EVENT_FORK failure for the fork userfault paths.

That still didn't clear the vma->vm_userfaultfd_ctx of the vmas that
were set to point to the aborted new uffd ctx earlier in
dup_userfaultfd.

Link: http://lkml.kernel.org/r/20171223002505.593-2-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Reviewed-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/userfaultfd.c