linux-stable/Documentation
Peter Collingbourne e71e2ace57 userfaultfd: do not untag user pointers
Patch series "userfaultfd: do not untag user pointers", v5.

If a user program uses userfaultfd on ranges of heap memory, it may end
up passing a tagged pointer to the kernel in the range.start field of
the UFFDIO_REGISTER ioctl.  This can happen when using an MTE-capable
allocator, or on Android if using the Tagged Pointers feature for MTE
readiness [1].

When a fault subsequently occurs, the tag is stripped from the fault
address returned to the application in the fault.address field of struct
uffd_msg.  However, from the application's perspective, the tagged
address *is* the memory address, so if the application is unaware of
memory tags, it may get confused by receiving an address that is, from
its point of view, outside of the bounds of the allocation.  We observed
this behavior in the kselftest for userfaultfd [2] but other
applications could have the same problem.

Address this by not untagging pointers passed to the userfaultfd ioctls.
Instead, let the system call fail.  Also change the kselftest to use
mmap so that it doesn't encounter this problem.

[1] https://source.android.com/devices/tech/debug/tagged-pointers
[2] tools/testing/selftests/vm/userfaultfd.c

This patch (of 2):

Do not untag pointers passed to the userfaultfd ioctls.  Instead, let
the system call fail.  This will provide an early indication of problems
with tag-unaware userspace code instead of letting the code get confused
later, and is consistent with how we decided to handle brk/mmap/mremap
in commit dcde237319 ("mm: Avoid creating virtual address aliases in
brk()/mmap()/mremap()"), as well as being consistent with the existing
tagged address ABI documentation relating to how ioctl arguments are
handled.

The code change is a revert of commit 7d0325749a ("userfaultfd: untag
user pointers") plus some fixups to some additional calls to
validate_range that have appeared since then.

[1] https://source.android.com/devices/tech/debug/tagged-pointers
[2] tools/testing/selftests/vm/userfaultfd.c

Link: https://lkml.kernel.org/r/20210714195437.118982-1-pcc@google.com
Link: https://lkml.kernel.org/r/20210714195437.118982-2-pcc@google.com
Link: https://linux-review.googlesource.com/id/I761aa9f0344454c482b83fcfcce547db0a25501b
Fixes: 63f0c60379 ("arm64: Introduce prctl() options to control the tagged user addresses ABI")
Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Alistair Delva <adelva@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Mitch Phillips <mitchp@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: William McVicker <willmcvicker@google.com>
Cc: <stable@vger.kernel.org>	[5.4]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-07-23 17:43:28 -07:00
..
ABI Networking fixes for 5.14-rc2, including fixes from bpf and netfilter. 2021-07-14 09:24:32 -07:00
accounting
admin-guide USB / Thunderbolt patches for 5.14-rc1 2021-07-05 14:16:22 -07:00
arm
arm64 userfaultfd: do not untag user pointers 2021-07-23 17:43:28 -07:00
block for-5.14/block-2021-06-29 2021-06-30 12:12:56 -07:00
bpf Networking changes for 5.14. 2021-06-30 15:51:09 -07:00
cdrom
core-api module: add printk formats to add module build ID to stacktraces 2021-07-08 11:48:22 -07:00
cpu-freq cpufreq: Remove ->resolve_freq() 2021-06-30 19:45:42 +02:00
crypto
dev-tools Documentation: kunit: drop obsolete note about uml_abort for coverage 2021-07-12 13:54:12 -06:00
devicetree sound fixes for 5.14-rc3 2021-07-23 09:58:23 -07:00
doc-guide docs: doc-guide: avoid using ReST :doc:foo markup 2021-06-17 13:24:37 -06:00
driver-api Documentation: Fix intiramfs script name 2021-07-18 23:48:14 +09:00
fault-injection docs: fault-injection: fix non-working usage of negative values 2021-06-14 15:58:22 -06:00
fb
features Documentation/features: Add THREAD_INFO_IN_TASK feature matrix 2021-07-15 06:33:44 -06:00
filesystems Documentation: Fix intiramfs script name 2021-07-18 23:48:14 +09:00
firmware-guide pwm: Changes for v5.14-rc1 2021-07-08 12:18:04 -07:00
firmware_class
fpga Documentation: fpga: dfl: change FPGA indirect article to an 2021-06-09 14:51:25 +02:00
gpu drm/amd/display: Add Freesync video documentation 2021-06-18 17:06:43 -04:00
hid
hwmon hwmon: (pmbus) Add driver for Delta DPS-920AB PSU 2021-06-17 04:21:46 -07:00
i2c Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-07-04 11:47:18 -07:00
ia64
ide
iio
infiniband
input
isdn
kbuild
kernel-hacking docs: kernel-hacking: hacking.rst: avoid using ReST :doc:foo markup 2021-06-17 13:24:38 -06:00
leds
litmus-tests
livepatch
locking
m68k
maintainer
mhi
mips
misc-devices
netlabel
networking tcp: disable TFO blackhole logic by default 2021-07-21 22:50:31 -07:00
nios2
nvdimm
openrisc
parisc
PCI pci-v5.14-changes 2021-07-08 12:06:20 -07:00
pcmcia
power PM: runtime: Clarify documentation when callbacks are unassigned 2021-06-11 19:04:07 +02:00
powerpc
process docs: process: submitting-patches.rst: avoid using ReST :doc:foo markup 2021-06-17 13:24:38 -06:00
RCU Merge branch 'core-rcu-2021.07.04' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu 2021-07-04 12:58:33 -07:00
riscv riscv: Ensure BPF_JIT_REGION_START aligned with PMD size 2021-06-18 21:10:05 -07:00
s390 vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE 2021-06-21 15:29:25 -06:00
scheduler This was a reasonably active cycle for documentation; this pull includes: 2021-06-28 16:53:05 -07:00
scsi
security This was a reasonably active cycle for documentation; this pull includes: 2021-06-28 16:53:05 -07:00
sh
sound ASoC: Updates for v5.14 2021-07-01 08:36:12 +02:00
sparc
sphinx
sphinx-static
spi
staging
target
timers
trace tracing/histogram: Rename "cpu" to "common_cpu" 2021-07-23 08:44:47 -04:00
translations docs/zh_CN: add a missing space character 2021-07-15 06:33:44 -06:00
usb USB / Thunderbolt patches for 5.14-rc1 2021-07-05 14:16:22 -07:00
userspace-api Char / Misc driver updates for 5.14-rc1 2021-07-05 13:42:16 -07:00
virt This was a reasonably active cycle for documentation; this pull includes: 2021-06-28 16:53:05 -07:00
vm Merge branch 'akpm' (patches from Andrew) 2021-07-02 12:08:10 -07:00
w1
watchdog
x86 Fixes and improvements for FPU handling on x86: 2021-07-07 11:12:01 -07:00
xtensa
.gitignore
arch.rst
asm-annotations.rst
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py docs: Take a little noise out of the build process 2021-06-17 13:49:18 -06:00
COPYING-logo
docutils.conf
dontdiff
index.rst
Kconfig
logo.gif
Makefile docs: Makefile: Use CONFIG_SHELL not SHELL 2021-06-18 11:26:08 -06:00
memory-barriers.txt
SubmittingPatches
watch_queue.rst