No description
Find a file
Peter Xu 0f56535189 mm/shmem: use page_mapping() to detect page cache for uffd continue
commit 93b0d91787 upstream.

mfill_atomic_install_pte() checks page->mapping to detect whether one page
is used in the page cache.  However as pointed out by Matthew, the page
can logically be a tail page rather than always the head in the case of
uffd minor mode with UFFDIO_CONTINUE.  It means we could wrongly install
one pte with shmem thp tail page assuming it's an anonymous page.

It's not that clear even for anonymous page, since normally anonymous
pages also have page->mapping being setup with the anon vma.  It's safe
here only because the only such caller to mfill_atomic_install_pte() is
always passing in a newly allocated page (mcopy_atomic_pte()), whose
page->mapping is not yet setup.  However that's not extremely obvious
either.

For either of above, use page_mapping() instead.

Link: https://lkml.kernel.org/r/Y2K+y7wnhC4vbnP2@x1n
Fixes: 153132571f ("userfaultfd/shmem: support UFFDIO_CONTINUE for shmem")
Signed-off-by: Peter Xu <peterx@redhat.com>
Reported-by: Matthew Wilcox <willy@infradead.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-19 17:56:14 +08:00
arch MIPS: jump_label: Fix compat branch range check 2023-04-19 17:56:12 +08:00
block
certs
crypto
Documentation
drivers mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI 2023-04-19 17:56:14 +08:00
fs udf: Fix a slab-out-of-bounds write bug in udf_find_entry() 2023-04-19 17:56:14 +08:00
include vmlinux.lds.h: Fix placement of '.data..decrypted' section 2023-04-19 17:56:13 +08:00
init
ipc
kernel
lib
LICENSES
mm mm/shmem: use page_mapping() to detect page cache for uffd continue 2023-04-19 17:56:14 +08:00
net mctp: Fix an error handling path in mctp_init() 2023-04-19 17:56:11 +08:00
samples
scripts
security
sound ALSA: usb-audio: Add DSD support for Accuphase DAC-60 2023-04-19 17:56:13 +08:00
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
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.