linux/Documentation
Ryan Roberts 7a2bc8b34e mm: fix race between __split_huge_pmd_locked() and GUP-fast
commit 3a5a8d343e upstream.

__split_huge_pmd_locked() can be called for a present THP, devmap or
(non-present) migration entry.  It calls pmdp_invalidate() unconditionally
on the pmdp and only determines if it is present or not based on the
returned old pmd.  This is a problem for the migration entry case because
pmd_mkinvalid(), called by pmdp_invalidate() must only be called for a
present pmd.

On arm64 at least, pmd_mkinvalid() will mark the pmd such that any future
call to pmd_present() will return true.  And therefore any lockless
pgtable walker could see the migration entry pmd in this state and start
interpretting the fields as if it were present, leading to BadThings (TM).
GUP-fast appears to be one such lockless pgtable walker.

x86 does not suffer the above problem, but instead pmd_mkinvalid() will
corrupt the offset field of the swap entry within the swap pte.  See link
below for discussion of that problem.

Fix all of this by only calling pmdp_invalidate() for a present pmd.  And
for good measure let's add a warning to all implementations of
pmdp_invalidate[_ad]().  I've manually reviewed all other
pmdp_invalidate[_ad]() call sites and believe all others to be conformant.

This is a theoretical bug found during code review.  I don't have any test
case to trigger it in practice.

Link: https://lkml.kernel.org/r/20240501143310.1381675-1-ryan.roberts@arm.com
Link: https://lore.kernel.org/all/0dd7827a-6334-439a-8fd0-43c98e6af22b@arm.com/
Fixes: 84c3fc4e9c ("mm: thp: check pmd migration entry in common path")
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2024-06-16 13:41:38 +02:00
..
ABI x86/rfds: Mitigate Register File Data Sampling (RFDS) 2024-03-15 10:48:21 -04:00
accounting sched/psi: Allow unprivileged polling of N*2s period 2023-07-27 08:50:38 +02:00
admin-guide admin-guide/hw-vuln/core-scheduling: fix return type of PR_SCHED_CORE_GET 2024-05-25 16:21:35 +02:00
arc docs: ARC: Improve readability 2021-12-10 14:28:01 -07:00
arm EFI updates for v6.1 2022-10-09 08:56:54 -07:00
arm64 arm64: Subscribe Microsoft Azure Cobalt 100 to ARM Neoverse N2 errata 2024-02-23 09:12:52 +01:00
block blk-crypto: don't use struct request_queue for public interfaces 2023-05-11 23:03:00 +09:00
bpf bpf, docs: Fix modulo zero, division by zero, overflow, and underflow 2023-03-10 09:33:50 +01:00
cdrom It was a moderately busy cycle for documentation; highlights include: 2022-05-25 11:17:41 -07:00
core-api overflow: Fix kern-doc markup for functions 2022-10-25 14:57:42 -07:00
cpu-freq cpufreq: Reintroduce ready() callback 2022-02-09 13:18:49 +05:30
crypto crypto: engine - Add KPP Support to Crypto Engine 2021-10-29 21:04:03 +08:00
dev-tools docs/scripts/gdb: add necessary make scripts_gdb step 2023-03-10 09:33:58 +01:00
devicetree dt-bindings: pinctrl: mediatek: mt7622: fix array properties 2024-06-12 11:03:39 +02:00
doc-guide Rust introduction for v6.1-rc1 2022-10-03 16:39:37 -07:00
driver-api fpga: region: add owner module and take its refcount 2024-06-12 11:03:39 +02:00
fault-injection lkdtm: replace ll_rw_block with submit_bh 2023-07-19 16:21:53 +02:00
fb Documentation: fb: udlfb: clean up text and formatting 2022-09-27 13:21:44 -06:00
features Xtensa updates for v5.20 2022-08-04 15:35:58 -07:00
filesystems rename(): fix the locking of subdirectories 2024-01-31 16:17:02 -08:00
firmware-guide Merge branches 'acpi-misc', 'acpi-tools' and 'acpi-docs' 2022-10-03 20:03:49 +02:00
firmware_class firmware: revamp firmware documentation 2017-01-11 09:42:59 +01:00
fpga Documentation: fpga: dfl: add link address of feature id table 2022-05-10 16:05:27 +08:00
gpu drm/vmwgfx: Remove vmwgfx_hashtab 2023-01-18 11:58:28 +01:00
hid Documentation: Add leading slash to some paths 2021-03-31 13:49:19 -06:00
hwmon hwmon: (ftsteutates) Fix scaling of measurements 2023-03-10 09:33:10 +01:00
i2c docs: i2c: slave-interface: return errno when handle I2C_SLAVE_WRITE_REQUESTED 2022-09-28 21:41:59 +02:00
ia64 docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
iio docs: iio: add documentation for BNO055 driver 2022-09-21 18:42:56 +01:00
images docs: add SVG version of the Linux logo 2022-06-01 09:32:45 -06:00
infiniband RDMA/core: Remove FMR device ops 2020-06-02 20:32:54 -03:00
input Merge branch 'next' into for-linus 2022-10-09 22:30:23 -07:00
isdn isdn: capi: dead code removal 2019-12-11 09:12:38 +01:00
kbuild Documentation: kbuild: Add description of git for reproducible builds 2022-10-28 00:16:29 +09:00
kernel-hacking Documentation: Fix spelling mistake in hacking.rst 2022-10-24 11:27:51 -06:00
leds leds: qcom-lpg: Require pattern to follow documentation 2022-05-24 22:08:10 +02:00
litmus-tests Documentation/litmus-tests: Add note on herd7 7.56 in atomic litmus test 2020-06-29 12:05:18 -07:00
livepatch doc: module: update file references 2022-07-01 14:50:01 -07:00
locking Remove duplicate words inside documentation 2022-09-27 13:21:43 -06:00
loongarch docs/LoongArch: Add booting description 2022-12-08 14:59:15 +08:00
m68k video: fbdev: atari: Fix inverse handling 2022-07-18 07:56:17 +02:00
maintainer Some late-arriving documentation improvements. This is mostly build-system 2022-03-31 12:10:42 -07:00
mhi docs: Add documentation for MHI bus 2020-03-19 07:41:04 +01:00
mips docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
misc-devices Documentation: Wire Oxford Semiconductor PCIe (Tornado) 950 2022-05-19 18:24:22 +02:00
mm mm: fix race between __split_huge_pmd_locked() and GUP-fast 2024-06-16 13:41:38 +02:00
netlabel docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
networking net: ena: Add dynamic recycling mechanism for rx buffers 2024-06-12 11:03:58 +02:00
nios2 docs: nios2: add missing ReST file 2020-12-07 08:35:21 -07:00
nvdimm nvdimm: fixes to maintainter-entry-profile 2020-05-25 10:19:19 -06:00
openrisc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
parisc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
PCI Fix of heap data and clang warnings, support for a new Intel NTB device, 2022-08-13 14:00:45 -07:00
pcmcia docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
peci docs: Add PECI documentation 2022-02-09 08:04:44 +01:00
power Merge branches 'pm-devfreq', 'pm-qos', 'pm-tools' and 'pm-docs' 2022-07-29 19:46:00 +02:00
powerpc powerpc/64s: update cpu selection options 2022-09-28 19:22:10 +10:00
process docs: Set minimal gtags / GNU GLOBAL version to 6.6.5 2023-07-05 18:27:38 +01:00
RCU There's not a huge amount of activity in the docs tree this time around, 2022-10-03 10:23:32 -07:00
riscv riscv: Move early dtb mapping into the fixmap region 2023-05-01 08:26:28 +09:00
rust x86: enable initial Rust support 2022-09-28 09:02:45 +02:00
s390 vfio/mdev: embedd struct mdev_parent in the parent data structure 2022-10-04 12:06:58 -06:00
scheduler docs: scheduler: Update new path for the sysctl knobs 2022-09-27 13:21:42 -06:00
scsi scsi: core: Fix the scsi_set_resid() documentation 2023-09-13 09:43:00 +02:00
security KEYS: encrypted: fix key instantiation with user-provided data 2022-12-21 17:48:11 +01:00
sh docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
sound ASoC: doc: Fix undefined SND_SOC_DAPM_NOPM argument 2024-02-05 20:12:54 +00:00
sparc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
sphinx docs: kernel_include.py: Cope with docutils 0.21 2024-05-25 16:21:35 +02:00
sphinx-static docs: add support for RTD dark mode 2021-12-10 14:05:55 -07:00
spi spi: pxa2xx_spi: Convert to use GPIO descriptors 2022-01-31 15:17:27 +00:00
staging docs: put atomic*.txt and memory-barriers.txt into the core-api book 2022-09-29 12:55:06 -06:00
target tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
timers rcu: Remove the RCU_FAST_NO_HZ Kconfig option 2021-11-30 17:24:47 -08:00
tools A handful of relatively simple documentation fixes, plus a set of patches 2022-10-13 10:58:32 -07:00
trace tracing/probes: Add symstr type for dynamic events 2023-08-03 10:23:54 +02:00
translations docs/zh_CN: Add LoongArch booting description's translation 2022-12-08 15:03:14 +08:00
usb usbip: add USBIP_URB_* URB transfer flags 2022-08-31 09:07:53 +02:00
userspace-api media: mc: Expand MUST_CONNECT flag to always require an enabled link 2024-04-03 15:19:25 +02:00
virt x86/sev: Change snp_guest_issue_request()'s fw_err argument 2023-11-20 11:52:13 +01:00
w1 Documentation: W1: minor typo corrections 2022-09-27 13:21:44 -06:00
watchdog watchdog/pseries-wdt: initial support for H_WATCHDOG-based watchdog timers 2022-07-20 21:57:39 +10:00
x86 x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT 2024-04-03 15:19:47 +02:00
xtensa A much quieter cycle for documentation (happily), with, one hopes, the bulk 2020-12-14 16:55:54 -08:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
arch.rst Documentation: LoongArch: Add basic documentations 2022-06-03 20:09:27 +08:00
atomic_bitops.txt wait_on_bit: add an acquire memory barrier 2022-08-26 09:30:25 -07:00
atomic_t.txt Documentation/atomic_t: Document forward progress expectations 2021-08-04 15:16:47 +02:00
Changes docs: add back 'Documentation/Changes' file (as symlink) 2016-12-14 16:30:12 -08:00
CodingStyle doc: re-add CodingStyle and SubmittingPatches 2016-10-24 08:12:35 -02:00
conf.py There's not a huge amount of activity in the docs tree this time around, 2022-10-03 10:23:32 -07:00
docutils.conf doc-rst: Add missing newline at end of file 2019-06-20 14:16:56 -06:00
dontdiff randstruct: Move seed generation into scripts/basic/ 2022-05-08 01:33:07 -07:00
index.rst Rust introduction for v6.1-rc1 2022-10-03 16:39:37 -07:00
Kconfig docs: Kconfig: Fix help text indentation 2022-06-13 11:33:43 -06:00
Makefile docs: Makefile: Add -no-shell-escape option to LATEXOPTS 2022-02-14 12:50:17 -07:00
memory-barriers.txt docs/memory-barriers.txt: Fixup long lines 2022-08-31 05:15:31 -07:00
SubmittingPatches doc: re-add CodingStyle and SubmittingPatches 2016-10-24 08:12:35 -02:00
subsystem-apis.rst docs: Rewrite the front page 2022-09-29 12:55:06 -06:00