linux/tools/testing/selftests
Muhammad Usama Anjum 80eb449f80 selftests: secretmem: floor the memory size to the multiple of page_size
[ Upstream commit 0aac13add2 ]

The "locked-in-memory size" limit per process can be non-multiple of
page_size.  The mmap() fails if we try to allocate locked-in-memory with
same size as the allowed limit if it isn't multiple of the page_size
because mmap() rounds off the memory size to be allocated to next multiple
of page_size.

Fix this by flooring the length to be allocated with mmap() to the
previous multiple of the page_size.

This was getting triggered on KernelCI regularly because of different
ulimit settings which wasn't multiple of the page_size.  Find logs
here: https://linux.kernelci.org/test/plan/id/657654bd8e81e654fae13532/
The bug in was present from the time test was first added.

Link: https://lkml.kernel.org/r/20231214101931.1155586-1-usama.anjum@collabora.com
Fixes: 76fe17ef58 ("secretmem: test: add basic selftest for memfd_secret(2)")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Closes: https://linux.kernelci.org/test/plan/id/657654bd8e81e654fae13532/
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-01-15 18:51:21 +01:00
..
arm64 kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT 2022-10-26 12:35:44 +02:00
bpf selftests/bpf: Correct map_fd to data_fd in tailcalls 2023-11-20 11:08:14 +01:00
breakpoints selftests: breakpoints: Use correct error messages in breakpoint_test_arm64.c 2021-02-08 17:04:41 -07:00
capabilities .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
cgroup kseltest/cgroup: Make test_stress.sh work if run interactively 2022-06-09 10:23:30 +02: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 selftests: cpu-hotplug: fix case where CPUs offline > CPUs present 2019-01-25 14:57:45 -07:00
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 dma-mapping: benchmark: Add support for multi-pages map/unmap 2021-04-02 16:41:08 +02:00
dmabuf-heaps kselftests: dmabuf-heaps: Add extra checking that allocated buffers are zeroed 2021-02-08 16:25:53 -07:00
drivers sefltests: netdevsim: wait for devlink instance after netns removal 2023-03-10 09:39:19 +01:00
efivarfs selftests/efivarfs: create-read: fix a resource leak 2023-11-28 16:56:17 +00:00
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 selftests/fpu: Add an FPU selftest 2020-06-29 10:02:23 +02:00
ftrace selftests/ftrace: Add new test case which checks non unique symbol 2023-10-25 11:59:03 +02:00
futex selftests/futex: Order calls to futex_lock_pi 2023-09-19 12:22:31 +02:00
gpio selftests: gpio: fix gpio compiling error 2021-11-25 09:48:34 +01:00
ia64 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
intel_pstate selftests/intel_pstate: fix build for ARCH=x86_64 2022-11-26 09:24:30 +01:00
ipc selftests/ipc: remove unneeded semicolon 2021-02-08 16:32:43 -07:00
ir .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
kcmp .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
kexec sefltest/ima: support appended signatures (modsig) 2019-08-29 12:45:30 -04:00
kmod selftests: kmod: use variable NAME in kmod_test_0001() 2020-08-12 10:58:01 -07:00
kselftest kselftest/runner.sh: Propagate SIGTERM to runner child 2023-09-19 12:23:03 +02:00
kvm selftests: kvm: Fix a compile error in selftests/kvm/rseq_test.c 2023-01-18 11:48:47 +01:00
landlock selftests/landlock: Test ptrace as much as possible with Yama 2023-03-10 09:39:59 +01:00
lib selftests: lib: Add wrapper script for test_scanf 2021-05-19 15:05:11 +02:00
livepatch selftests/livepatch: Do not check order when using "comm" for dmesg checking 2020-08-27 15:27:24 +02:00
lkdtm selftest/lkdtm: Skip stack-entropy test if lkdtm is not available 2023-02-22 12:57:07 +01:00
locking selftests: locking: return Kselftest Skip code for skipped tests 2018-05-30 15:29:06 -06:00
media_tests .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
membarrier .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
memfd selftests/memfd: Fix unknown type name build failure 2023-05-30 13:55:30 +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 selftests: mount: add nosymfollow tests 2020-08-27 16:06:47 -04:00
mount_setattr selftests/mount_setattr: fix redefine struct mount_attr build error 2023-06-28 10:29:41 +02:00
move_mount_set_group tests: add move_mount(MOVE_MOUNT_SET_GROUP) selftest 2021-07-26 14:45:19 +02:00
mqueue testing/selftests/mqueue: Fix mq_perf_tests to free the allocated cpu set 2022-04-20 09:34:12 +02:00
nci selftests: nci: replace unsigned int with int 2021-09-16 13:55:51 +01:00
net selftests/net: ipsec: fix constant out of range 2023-12-08 08:48:03 +01:00
netfilter selftests: nft_nat: ensuring the listening side is up before starting the client 2023-03-17 08:48:54 +01:00
nsfs tools/testing: Replace zero-length array with flexible-array 2020-05-08 09:42:14 -06:00
ntb NTB: ntb_test: Fix bug when counting remote files 2020-06-05 20:02:09 -04:00
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 selftests: Remove unneeded selftest API headers 2020-07-06 15:59:07 -06:00
pidfd selftests/pidfd: Fix ksft print formats 2023-11-20 11:08:22 +01:00
powerpc selftests/powerpc: Fix resource leaks 2022-12-31 13:14:35 +01:00
prctl .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
proc proc: fixup uptime selftest 2022-12-31 13:14:02 +01:00
pstore pstore/platform: Use backend name for console registration 2020-05-30 10:34:02 -07:00
ptp selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET 2023-06-21 15:59:18 +02:00
ptrace selftests: Add missing gitignore entries 2020-09-23 10:19:25 -06:00
rcutorture rcutorture: Correct name of use_softirq module parameter 2023-07-23 13:46:46 +02:00
resctrl selftests/resctrl: Move _GNU_SOURCE define into Makefile 2023-12-08 08:48:04 +01:00
rlimits kselftests: Add test to check for rlimit changes in different user namespaces 2021-04-30 14:14:03 -05:00
rseq selftests/rseq: Fix build with undefined __weak 2023-08-16 18:22:00 +02:00
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 compile warning when CC=clang 2022-08-17 14:23:14 +02:00
sgx selftests/sgx: Treat CC as one argument 2022-04-08 14:23:06 +02:00
sigaltstack selftests: sigaltstack: fix -Wuninitialized 2023-04-26 13:51:50 +02:00
size .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
sparc64 .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
splice selftests: splice: Adjust for handler fallback removal 2021-06-07 18:39:43 -06:00
static_keys treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
sync selftests/sync: Remove the deprecated config SYNC 2021-08-31 10:58:00 -06:00
syscall_user_dispatch entry: Use different define for selector variable in SUD 2021-02-06 00:21:42 +01:00
sysctl linux-kselftest-5.8-rc1 2020-06-09 10:03:12 -07:00
tc-testing selftests: tc: add ConnTrack procfs kconfig 2023-07-27 08:46:55 +02:00
timens selftests/timens: Fix gettime_perf to work on powerpc 2021-04-21 22:52:32 +10:00
timers selftests: timers: clocksource-switch: fix passing errors from child 2022-08-17 14:23:30 +02:00
tmpfs .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
tpm2 selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle 2022-10-26 12:35:29 +02:00
uevent selftests: Remove unneeded selftest API headers 2020-07-06 15:59:07 -06:00
user treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
vDSO kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined 2023-07-23 13:46:47 +02:00
vm selftests: secretmem: floor the memory size to the multiple of page_size 2024-01-15 18:51:21 +01:00
watchdog .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
wireguard wireguard: netlink: send staged packets when setting initial private key 2023-07-23 13:47:37 +02:00
x86 selftests, x86: fix how check_cc.sh is being invoked 2022-04-08 14:23:11 +02:00
zram selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-02-23 12:03:05 +01:00
.gitignore SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
gen_kselftest_tar.sh selftests: introduce gen_tar Makefile target 2020-05-19 16:11:46 -06:00
kselftest.h selftests: Provide local define of __cpuid_count() 2023-02-06 07:59:01 +01:00
kselftest_deps.sh selftests: fix dependency checker script 2023-10-06 13:18:16 +02:00
kselftest_harness.h selftests/harness: Actually report SKIP for signal tests 2023-09-19 12:22:30 +02:00
kselftest_install.sh selftests: gen_kselftest_tar.sh: Do not clobber kselftest/ 2019-11-07 14:43:27 -07:00
kselftest_module.h kselftest: add support for skipped tests 2021-02-15 11:07:42 +01:00
lib.mk selftests: Use optional USERCFLAGS and USERLDFLAGS 2023-01-12 11:58:51 +01:00
Makefile selftests/resctrl: Make resctrl_tests run using kselftest framework 2023-09-19 12:22:31 +02:00
run_kselftest.sh selftests/run_kselftest.sh: fix dry-run typo 2020-11-10 14:51:39 -07:00