No description
Find a file
Liu Shixin 45c3396675 mm: hugetlb: fix UAF in hugetlb_handle_userfault
commit 958f32ce83 upstream.

The vma_lock and hugetlb_fault_mutex are dropped before handling userfault
and reacquire them again after handle_userfault(), but reacquire the
vma_lock could lead to UAF[1,2] due to the following race,

hugetlb_fault
  hugetlb_no_page
    /*unlock vma_lock */
    hugetlb_handle_userfault
      handle_userfault
        /* unlock mm->mmap_lock*/
                                           vm_mmap_pgoff
                                             do_mmap
                                               mmap_region
                                                 munmap_vma_range
                                                   /* clean old vma */
        /* lock vma_lock again  <--- UAF */
    /* unlock vma_lock */

Since the vma_lock will unlock immediately after
hugetlb_handle_userfault(), let's drop the unneeded lock and unlock in
hugetlb_handle_userfault() to fix the issue.

[1] https://lore.kernel.org/linux-mm/000000000000d5e00a05e834962e@google.com/
[2] https://lore.kernel.org/linux-mm/20220921014457.1668-1-liuzixian4@huawei.com/
Link: https://lkml.kernel.org/r/20220923042113.137273-1-liushixin2@huawei.com
Fixes: 1a1aad8a9b ("userfaultfd: hugetlbfs: add userfaultfd hugetlb hook")
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reported-by: syzbot+193f9cee8638750b23cf@syzkaller.appspotmail.com
Reported-by: Liu Zixian <liuzixian4@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: <stable@vger.kernel.org>	[4.14+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:25:55 +02:00
arch arm64: topology: fix possible overflow in amu_fie_setup() 2022-10-26 13:25:55 +02:00
block blk-throttle: prevent overflow while calculating wait time 2022-10-26 13:25:53 +02:00
certs certs/blacklist_hashes.c: fix const confusion in certs blacklist 2022-06-22 14:13:17 +02:00
crypto crypto: akcipher - default implementation for setting a private key 2022-10-26 13:25:42 +02:00
Documentation iio: ABI: Fix wrong format of differential capacitance channel ABI. 2022-10-26 13:25:30 +02:00
drivers clk: bcm2835: Make peripheral PLLC critical 2022-10-26 13:25:54 +02:00
fs io_uring/af_unix: defer registered files gc to io_uring release 2022-10-26 13:25:55 +02:00
include io_uring/af_unix: defer registered files gc to io_uring release 2022-10-26 13:25:55 +02:00
init Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug 2022-06-09 10:21:25 +02:00
ipc ipc/mqueue: use get_tree_nodev() in mqueue_get_tree() 2022-06-09 10:21:17 +02:00
kernel rcu-tasks: Convert RCU_LOCKDEP_WARN() to WARN_ONCE() 2022-10-26 13:25:44 +02:00
lib dyndbg: drop EXPORTed dynamic_debug_exec_queries 2022-10-26 13:25:34 +02:00
LICENSES
mm mm: hugetlb: fix UAF in hugetlb_handle_userfault 2022-10-26 13:25:55 +02:00
net io_uring/af_unix: defer registered files gc to io_uring release 2022-10-26 13:25:55 +02:00
samples x86: Prepare inline-asm for straight-line-speculation 2022-07-25 11:26:29 +02:00
scripts kbuild: rpm-pkg: fix breakage when V=1 is used 2022-10-26 13:25:43 +02:00
security hardening: Remove Clang's enable flag for -ftrivial-auto-var-init=zero 2022-10-26 13:25:12 +02:00
sound ASoC: SOF: pci: Change DMI match info to support all Chrome platforms 2022-10-26 13:25:49 +02:00
tools perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc 2022-10-26 13:25:54 +02:00
usr usr/include/Makefile: add linux/nfc.h to the compile-test coverage 2022-02-01 17:25:48 +01:00
virt KVM: SEV: add cache flush to solve SEV cache incoherency issues 2022-09-28 11:10:28 +02:00
.clang-format RDMA 5.10 pull request 2020-10-17 11:18:18 -07:00
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore kbuild: generate Module.symvers only when vmlinux exists 2021-05-19 10:12:59 +02:00
.mailmap mailmap: add two more addresses of Uwe Kleine-König 2020-12-06 10:19:07 -08:00
COPYING
CREDITS MAINTAINERS: Move Jason Cooper to CREDITS 2020-11-30 10:20:34 +01:00
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: add Amir as xfs maintainer for 5.10.y 2022-07-02 16:39:22 +02:00
Makefile hardening: Remove Clang's enable flag for -ftrivial-auto-var-init=zero 2022-10-26 13:25:12 +02:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.