2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 10:44:14 +08:00
linux-next/tools/testing/selftests
Axel Rasmussen 573a259336 userfaultfd: selftests: fix SIGSEGV if huge mmap fails
The error handling in hugetlb_allocate_area() was incorrect for the
hugetlb_shared test case.

Previously the behavior was:

- mmap a hugetlb area
  - If this fails, set the pointer to NULL, and carry on
- mmap an alias of the same hugetlb fd
  - If this fails, munmap the original area

If the original mmap failed, it's likely the second one did too.  If
both failed, we'd blindly try to munmap a NULL pointer, causing a
SIGSEGV.  Instead, "goto fail" so we return before trying to mmap the
alias.

This issue can be hit "in real life" by forgetting to set
/proc/sys/vm/nr_hugepages (leaving it at 0), and then trying to run the
hugetlb_shared test.

Another small improvement is, when the original mmap fails, don't just
print "it failed": perror(), so we can see *why*.  :)

Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Alan Gilbert <dgilbert@redhat.com>
Link: https://lkml.kernel.org/r/20201204203443.2714693-1-axelrasmussen@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-06 10:19:07 -08:00
..
android
arm64 kselftest/arm64: Fix check_user_mem test 2020-10-28 13:42:24 +00:00
bpf selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL 2020-11-19 11:58:15 -08:00
breakpoints selftests: breakpoints: do not use ksft_exit_skip after ksft_set_plan 2020-07-06 15:47:48 -06:00
capabilities
cgroup kselftests: cgroup: add perpcu memory accounting test 2020-08-12 10:57:55 -07:00
clone3 selftests: clone3: use SKIP instead of XFAIL 2020-11-05 10:08:15 -07:00
core selftests: core: use SKIP instead of XFAIL in close_range_test.c 2020-11-05 10:08:15 -07:00
cpu-hotplug
cpufreq
dmabuf-heaps
drivers selftests: net: mscc: ocelot: add test for VLAN modify action 2020-10-11 11:19:04 -07:00
efivarfs
exec tools/testing/selftests: add self-test for verifying load alignment 2020-10-16 11:11:21 -07:00
filesystems linux-kselftest-fixes-5.10-rc3 2020-11-06 15:42:42 -08:00
firmware linux-kselftest-next-5.10-rc1 2020-10-15 15:14:32 -07:00
fpu
ftrace selftests/ftrace: check for do_sys_openat2 in user-memory test 2020-10-27 16:45:51 -06:00
futex
gpio
ia64
intel_pstate
ipc
ir
kcmp
kexec
kmod selftests: kmod: use variable NAME in kmod_test_0001() 2020-08-12 10:58:01 -07:00
kselftest Driver core changes for 5.9-rc1 2020-08-05 11:52:17 -07:00
kvm KVM: selftests: allow two iterations of dirty_log_perf_test 2020-11-09 09:45:17 -05:00
lib
livepatch selftests/livepatch: Do not check order when using "comm" for dmesg checking 2020-08-27 15:27:24 +02:00
lkdtm Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-10-22 09:59:21 -07:00
locking
media_tests
membarrier
memfd
memory-hotplug
mincore selftests: add mincore() tests 2020-08-07 11:33:27 -07:00
mount selftests: mount: add nosymfollow tests 2020-08-27 16:06:47 -04:00
mqueue
net selftests: mptcp: depends on built-in IPv6 2020-10-21 20:39:58 -07:00
netfilter networking changes for the 5.10 merge window 2020-10-15 18:42:13 -07:00
nsfs
ntb
openat2
pid_namespace selftests: Remove unneeded selftest API headers 2020-07-06 15:59:07 -06:00
pidfd selftests: pidfd: drop needless linux/kcmp.h inclusion in pidfd_setns_test.c 2020-10-27 17:04:01 -06:00
powerpc selftests/powerpc: refactor entry and rfi_flush tests 2020-11-19 23:47:23 +11:00
prctl
proc selftests: proc: fix warning: _GNU_SOURCE redefined 2020-11-05 10:08:14 -07:00
pstore
ptp testptp: add new options for perout phase and pulse width 2020-07-20 18:04:59 -07:00
ptrace selftests: Add missing gitignore entries 2020-09-23 10:19:25 -06:00
rcutorture Merge branch 'scftorture.2020.08.24a' into HEAD 2020-09-03 09:47:01 -07:00
resctrl
rseq rseq/selftests: Test MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ 2020-09-25 14:23:27 +02:00
rtc
safesetid
seccomp selftests/seccomp: sh: Fix register names 2020-11-20 11:03:08 -08:00
sigaltstack selftests: sigaltstack: do not use ksft_exit_skip after ksft_set_plan 2020-07-06 15:57:15 -06:00
size
sparc64
splice selftests: splice: Check behavior of full and short splices 2020-08-07 10:50:11 -07:00
static_keys
sync selftests: sync_test: do not use ksft_exit_skip after ksft_set_plan 2020-07-06 15:57:28 -06:00
sysctl
tc-testing selftests: tc-testing: enable CONFIG_NET_SCH_RED as a module 2020-11-28 13:18:34 -08:00
timens selftests/timens: Add a test for futex() 2020-10-20 17:02:57 +02:00
timers selftests/timers: Turn off timeout setting 2020-08-20 15:49:28 -06:00
tmpfs
tpm2 selftests: tpm: upgrade TPM2 tests from Python 2 to Python 3 2020-07-06 14:20:35 -06:00
uevent selftests: Remove unneeded selftest API headers 2020-07-06 15:59:07 -06:00
user
vDSO
vm userfaultfd: selftests: fix SIGSEGV if huge mmap fails 2020-12-06 10:19:07 -08:00
watchdog
wireguard wireguard: selftests: check that route_me_harder packets use the right sk 2020-10-30 12:57:38 +01:00
x86 * Misc minor cleanups and corrections to the fsgsbase code and 2020-10-12 10:44:24 -07:00
zram
.gitignore
gen_kselftest_tar.sh
kselftest_deps.sh
kselftest_harness.h linux-kselftest-fixes-5.10-rc3 2020-11-06 15:42:42 -08:00
kselftest_install.sh
kselftest_module.h
kselftest.h linux-kselftest-5.9-rc1 2020-08-05 10:28:25 -07:00
lib.mk selftests: filter kselftest headers from command in lib.mk 2020-10-27 16:51:06 -06:00
Makefile selftests: Extract run_kselftest.sh and generate stand-alone test list 2020-10-07 07:58:54 -06:00
run_kselftest.sh selftests/run_kselftest.sh: Make each test individually selectable 2020-10-07 07:59:15 -06:00