linux/tools/testing/selftests
Mike Kravetz 5c23725142 selftests/memfd: clean up mapping in mfd_fail_write
[ Upstream commit fda153c89a ]

Running the memfd script ./run_hugetlbfs_test.sh will often end in error
as follows:

    memfd-hugetlb: CREATE
    memfd-hugetlb: BASIC
    memfd-hugetlb: SEAL-WRITE
    memfd-hugetlb: SEAL-FUTURE-WRITE
    memfd-hugetlb: SEAL-SHRINK
    fallocate(ALLOC) failed: No space left on device
    ./run_hugetlbfs_test.sh: line 60: 166855 Aborted                 (core dumped) ./memfd_test hugetlbfs
    opening: ./mnt/memfd
    fuse: DONE

If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will
allocate 'just enough' pages to run the test.  In the SEAL-FUTURE-WRITE
test the mfd_fail_write routine maps the file, but does not unmap.  As a
result, two hugetlb pages remain reserved for the mapping.  When the
fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb
pages, it is short by the two reserved pages.

Fix by making sure to unmap in mfd_fail_write.

Link: https://lkml.kernel.org/r/20220219004340.56478-1-mike.kravetz@oracle.com
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-16 14:23:42 +01:00
..
arm64 kselftest/arm64: signal: Skip tests if required features are missing 2021-09-21 18:12:03 +01:00
bpf selftests/bpf: Add test for bpf_timer overwriting crash 2022-03-16 14:23:40 +01:00
breakpoints
capabilities
cgroup tests/cgroup: test cgroup.kill 2021-05-10 10:41:11 -04:00
clone3 selftests: fixup build warnings in pidfd / clone3 tests 2022-02-23 12:03:18 +01:00
core selftests/core: fix conflicting types compile error for close_range() 2021-11-18 19:16:21 +01:00
cpu-hotplug
cpufreq selftests/cpufreq: Rename DEBUG_PI_LIST to DEBUG_PLIST 2021-08-31 11:00:02 -06:00
damon selftests/damon: test debugfs file reads/writes with huge count 2021-12-22 09:32:51 +01:00
dma
dmabuf-heaps
drivers selftests: mlxsw: resource_scale: Fix return value 2022-03-08 19:12:52 +01:00
efivarfs
exec selftests/exec: Add non-regular to TEST_GEN_PROGS 2022-02-23 12:03:13 +01:00
filesystems selftests/binderfs: add test for feature files 2021-07-21 13:46:36 +02:00
firmware selftests: firmware: Fix ignored return val of asprintf() warn 2021-07-21 16:11:42 +02:00
fpu
ftrace selftests/ftrace: Do not trace do_softirq because of PREEMPT_RT 2022-03-08 19:12:31 +01:00
futex selftests: futex: Use variable MAKE instead of make 2022-02-08 18:34:12 +01:00
gpio selftests: gpio: fix gpio compiling error 2021-11-25 09:48:34 +01:00
ia64
intel_pstate
ipc
ir
kcmp
kexec
kmod
kselftest
kvm KVM: selftests: Don't skip L2's VMCALL in SMM test for SVM guest 2022-02-01 17:27:14 +01:00
landlock
lib selftests: lib: Add wrapper script for test_scanf 2021-05-19 15:05:11 +02:00
livepatch
lkdtm lkdtm/fortify: Consolidate FORTIFY_SOURCE tests 2021-08-18 22:28:51 +02:00
locking
media_tests
membarrier
memfd selftests/memfd: clean up mapping in mfd_fail_write 2022-03-16 14:23:42 +01:00
memory-hotplug selftests: memory-hotplug: avoid spamming logs with dump_page(), ratio limit hot-remove error test 2021-07-12 14:20:01 -06:00
mincore selftests: skip mincore.check_file_mmap when fs lacks needed support 2022-02-23 12:03:05 +01:00
mount
mount_setattr tests: fix idmapped mount_setattr test 2022-02-23 12:03:21 +01:00
move_mount_set_group tests: add move_mount(MOVE_MOUNT_SET_GROUP) selftest 2021-07-26 14:45:19 +02:00
mqueue
nci selftests: nci: replace unsigned int with int 2021-09-16 13:55:51 +01:00
net selftests: pmtu.sh: Kill nettest processes launched in subshell. 2022-03-16 14:23:39 +01:00
netfilter selftests: netfilter: disable rp_filter on router 2022-02-23 12:03:10 +01:00
nsfs
ntb
openat2 selftests: openat2: Skip testcases that fail with EOPNOTSUPP 2022-02-23 12:03:05 +01:00
perf_events signal: Deliver all of the siginfo perf data in _perf 2021-05-18 16:20:54 -05:00
pid_namespace
pidfd selftests: fixup build warnings in pidfd / clone3 tests 2022-02-23 12:03:18 +01:00
powerpc selftests/powerpc: Add a test of sigreturning to the kernel 2022-01-27 11:05:03 +01:00
prctl
proc proc: add .gitignore for proc-subset-pid selftest 2021-06-05 08:58:11 -07:00
pstore
ptp
ptrace
rcutorture torture: Make kvm-test-1-run-qemu.sh check for reboot loops 2021-07-27 11:41:33 -07:00
resctrl selftests/resctrl: Fix incorrect parsing of option "-t" 2021-06-07 18:38:58 -06:00
rlimits
rseq
rtc selftests: rtc: Increase test timeout so that all tests run 2022-02-23 12:03:04 +01:00
safesetid selftests: safesetid: Fix spelling mistake "cant" -> "can't" 2021-08-26 15:15:24 -06:00
sched kselftests/sched: cleanup the child processes 2021-11-18 19:16:14 +01:00
seccomp selftests/seccomp: Fix seccomp failure by adding missing headers 2022-03-08 19:12:30 +01:00
sgx selftests/sgx: Fix Q1 and Q2 calculation in sigstruct.c 2021-07-30 17:20:01 -06:00
sigaltstack selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available 2021-05-19 12:38:17 +02:00
size
sparc64
splice selftests: splice: Adjust for handler fallback removal 2021-06-07 18:39:43 -06:00
static_keys
sync selftests/sync: Remove the deprecated config SYNC 2021-08-31 10:58:00 -06:00
syscall_user_dispatch
sysctl
tc-testing tc-testing: Add control-plane selftests for sch_mq 2021-08-04 12:42:27 +01:00
timens
timers selftests: timers: rtcpie: skip test if default RTC device does not exist 2021-06-07 19:18:52 -06:00
tmpfs
tpm2
uevent
user
vDSO kselftest: Fix vdso_test_abi return status 2022-02-23 12:03:06 +01:00
vm selftest/vm: fix map_fixed_noreplace test failure 2022-03-16 14:23:42 +01:00
watchdog
wireguard wireguard: device: reset peer src endpoint when netns exits 2021-12-08 09:04:46 +01:00
x86 selftests: x86: fix [-Wstringop-overread] warn in test_process_vm_readv() 2022-01-11 15:35:12 +01:00
zram selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-02-23 12:03:05 +01:00
.gitignore
gen_kselftest_tar.sh
kselftest_deps.sh
kselftest_harness.h kselftest: signal all child processes 2022-02-23 12:03:04 +01:00
kselftest_install.sh
kselftest_module.h
kselftest.h
lib.mk selftests: be sure to make khdr before other targets 2021-09-15 10:34:21 -06:00
Makefile Core: 2021-08-31 16:43:06 -07:00
run_kselftest.sh