No description
Find a file
Jann Horn 023f47a825 mm/khugepaged: fix ->anon_vma race
If an ->anon_vma is attached to the VMA, collapse_and_free_pmd() requires
it to be locked.

Page table traversal is allowed under any one of the mmap lock, the
anon_vma lock (if the VMA is associated with an anon_vma), and the
mapping lock (if the VMA is associated with a mapping); and so to be
able to remove page tables, we must hold all three of them. 
retract_page_tables() bails out if an ->anon_vma is attached, but does
this check before holding the mmap lock (as the comment above the check
explains).

If we racily merged an existing ->anon_vma (shared with a child
process) from a neighboring VMA, subsequent rmap traversals on pages
belonging to the child will be able to see the page tables that we are
concurrently removing while assuming that nothing else can access them.

Repeat the ->anon_vma check once we hold the mmap lock to ensure that
there really is no concurrent page table access.

Hitting this bug causes a lockdep warning in collapse_and_free_pmd(),
in the line "lockdep_assert_held_write(&vma->anon_vma->root->rwsem)". 
It can also lead to use-after-free access.

Link: https://lore.kernel.org/linux-mm/CAG48ez3434wZBKFFbdx4M9j6eUwSUVPd4dxhzW_k_POneSDF+A@mail.gmail.com/
Link: https://lkml.kernel.org/r/20230111133351.807024-1-jannh@google.com
Fixes: f3f0e1d215 ("khugepaged: add support of collapse for tmpfs/shmem pages")
Signed-off-by: Jann Horn <jannh@google.com>
Reported-by: Zach O'Keefe <zokeefe@google.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@intel.linux.com>
Reviewed-by: Yang Shi <shy828301@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-01-31 16:44:07 -08:00
arch - Make sure the poking PGD is pinned for Xen PV as it requires it this way 2023-01-15 07:17:44 -06:00
block block-6.2-2023-01-13 2023-01-13 17:41:19 -06:00
certs
crypto
Documentation Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
drivers - Fix the EDAC device's confusion in the polling setting units 2023-01-15 07:12:58 -06:00
fs Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
include Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
init Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
io_uring io_uring: lock overflowing for IOPOLL 2023-01-13 07:32:46 -07:00
ipc
kernel modules-6.2-rc4 2023-01-14 08:17:27 -06:00
lib maple_tree: fix mas_empty_area_rev() lower bound validation 2023-01-31 16:44:07 -08:00
LICENSES
mm mm/khugepaged: fix ->anon_vma race 2023-01-31 16:44:07 -08:00
net Including fixes from rxrpc. 2023-01-12 18:20:44 -06:00
rust
samples
scripts kernel hardening fixes for v6.2-rc4 2023-01-14 10:04:00 -06:00
security
sound sound fixes for 6.2-rc4 2023-01-13 08:20:29 -06:00
tools selftests/filesystems: grant executable permission to run_fat_tests.sh 2023-01-19 17:27:25 -08:00
usr
virt KVM: Ensure lockdep knows about kvm->lock vs. vcpu->mutex ordering rule 2023-01-11 13:32:21 -05:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore .gitignore: ignore *.rpm 2022-12-30 17:22:14 +09:00
.mailmap Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS Sync with v6.2-rc4 2023-01-18 16:52:20 -08:00
Makefile Linux 6.2-rc4 2023-01-15 09:22:43 -06: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.