android_kernel_xiaomi_sm8350/Documentation
Lokesh Gidra a04582fb0f
UPSTREAM: userfaultfd: add user-mode only option to unprivileged_userfaultfd sysctl knob
With this change, when the knob is set to 0, it allows unprivileged users
to call userfaultfd, like when it is set to 1, but with the restriction
that page faults from only user-mode can be handled.  In this mode, an
unprivileged user (without SYS_CAP_PTRACE capability) must pass
UFFD_USER_MODE_ONLY to userfaultd or the API will fail with EPERM.

This enables administrators to reduce the likelihood that an attacker with
access to userfaultfd can delay faulting kernel code to widen timing
windows for other exploits.

The default value of this knob is changed to 0.  This is required for
correct functioning of pipe mutex.  However, this will fail postcopy live
migration, which will be unnoticeable to the VM guests.  To avoid this,
set 'vm.userfault = 1' in /sys/sysctl.conf.

The main reason this change is desirable as in the short term is that the
Android userland will behave as with the sysctl set to zero.  So without
this commit, any Linux binary using userfaultfd to manage its memory would
behave differently if run within the Android userland.  For more details,
refer to Andrea's reply [1].

[1] https://lore.kernel.org/lkml/20200904033438.GI9411@redhat.com/

Link: https://lkml.kernel.org/r/20201120030411.2690816-3-lokeshgidra@google.com
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Peter Xu <peterx@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Daniel Colascione <dancol@dancol.org>
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: <calin@google.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Nitin Gupta <nigupta@nvidia.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Daniel Colascione <dancol@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit d0d4730ac2e404a5b0da9a87ef38c73e51cb1664)
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Bug: 160737021
Bug: 169683130
Change-Id: Ic46c0be47d6394d25bd3443ff524936fa568ab85
2025-02-20 04:17:45 +02:00
..
ABI Merge tag 'ASB-2025-02-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2025-02-06 22:53:05 +02:00
accounting psi: Fix uaf issue when psi trigger is destroyed while being polled 2022-02-05 12:35:36 +01:00
admin-guide UPSTREAM: userfaultfd: add user-mode only option to unprivileged_userfaultfd sysctl knob 2025-02-20 04:17:45 +02:00
arm
arm64 This is the 5.4.285 stable release 2024-11-09 11:29:17 +00:00
block
bpf
cdrom
core-api
cpu-freq
crypto
dev-tools This is the 5.4.235 stable release 2023-03-12 15:42:52 +00:00
device-mapper
devicetree Merge 5.4.287 into android11-5.4-lts 2024-12-16 10:50:16 +00:00
doc-guide
driver-api Merge tag 'ASB-2023-04-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2023-04-06 14:17:05 +03:00
EDID
fault-injection debugfs: fix error when writing negative value to atomic_t debugfs file 2023-01-18 11:40:56 +01:00
fb
features
filesystems Merge tag 'ASB-2024-06-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-06-22 17:58:09 +03:00
firmware-guide Documentation: ACPI: EINJ: Fix obsolete example 2022-08-25 11:18:21 +02:00
firmware_class
fpga
gpu
hid
hwmon Revert "hwmon: Make chip parameter for with_info API mandatory" 2022-06-25 12:44:36 +02:00
i2c
ia64
ide
iio
infiniband
input Input: iforce - add support for Boeder Force Feedback Wheel 2022-09-20 12:27:59 +02:00
ioctl Merge 5.4.248 into android11-5.4-lts 2023-06-22 16:16:24 +00:00
isdn
kbuild BACKPORT: scripts/Makefile.clang: default to LLVM_IAS=1 2022-11-14 19:50:35 +02:00
kernel-hacking
leds UPSTREAM: leds: multicolor: Introduce a multicolor class definition 2022-12-21 16:28:02 +00:00
livepatch
locking
m68k
maintainer
media Revert "media: rename VFL_TYPE_GRABBER to _VIDEO" 2024-04-17 16:49:02 +00:00
mic
mips
misc-devices
netlabel
networking This is the 5.4.251 stable release 2023-08-03 10:56:28 +00:00
nios2
openrisc
parisc
PCI
pcmcia
power PM: runtime: Add pm_runtime_get_if_active() 2023-08-30 16:27:12 +02:00
powerpc
process Merge tag 'ASB-2024-10-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-10-09 18:08:17 +00:00
RCU
riscv
s390
scheduler
scsi
security
sh
sound Merge tag 'ASB-2024-06-05_11-5.4' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2024-06-22 17:58:09 +03:00
sparc
sphinx docs: kernel_include.py: Cope with docutils 0.21 2024-05-25 16:17:18 +02:00
sphinx-static
spi
target
timers
trace tracing/histogram: Update document for KEYS_MAX size 2022-11-10 17:57:55 +01:00
translations Revert "media: rename VFL_TYPE_GRABBER to _VIDEO" 2024-04-17 16:49:02 +00:00
usb
userspace-api
virt KVM: s390: disable migration mode when dirty tracking is disabled 2023-03-11 16:44:01 +01:00
virtual
vm arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL 2022-05-15 19:54:46 +02:00
w1
watchdog
x86
xtensa
.gitignore
asm-annotations.rst
atomic_bitops.txt locking/atomic: Make test_and_*_bit() ordered on failure 2022-08-25 11:18:31 +02:00
atomic_t.txt
bus-virt-phys-mapping.txt
Changes
CodingStyle
conf.py docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0 2022-06-14 18:11:49 +02:00
COPYING-logo
crc32.txt
debugging-modules.txt
debugging-via-ohci1394.txt
digsig.txt
DMA-API-HOWTO.txt
DMA-API.txt
DMA-attributes.txt Reinstate some of "swiotlb: rework "fix info leak with DMA_FROM_DEVICE"" 2022-05-25 09:14:38 +02:00
DMA-ISA-LPC.txt
docutils.conf
dontdiff
futex-requeue-pi.txt
hwspinlock.txt
index.rst
io-mapping.txt
io_ordering.txt
IPMI.txt ipmi: docs: don't advertise deprecated sysfs entries 2024-11-08 16:20:29 +01:00
IRQ-affinity.txt
IRQ-domain.txt
IRQ.txt
irqflags-tracing.txt
Kconfig
kobject.txt
kprobes.txt
kref.txt
logo.gif
lzo.txt
mailbox.txt
Makefile
memory-barriers.txt
mhi.txt
nommu-mmap.txt
padata.txt
percpu-rw-semaphore.txt
pi-futex.txt
preempt-locking.txt
rbtree.txt
remoteproc.txt
robust-futex-ABI.txt
robust-futexes.txt
rpmsg.txt
speculation.txt
static-keys.txt
SubmittingPatches
tee.txt
this_cpu_ops.txt
unaligned-memory-access.txt
xz.txt