[LTP] [PATCH] shmget02: reduce the shmmax test value in compat mode
Li Wang
liwang@redhat.com
Tue May 30 11:30:12 CEST 2023
As Arnd Bergmann pointed out that SHMMAX being defined as
(ULONG_MAX - (1UL << 24)), so the kernel would likely use
a large 64-bit value, while the 32-bit user space uses a
much smaller limit.
It finally results in ENOMEM failure:
shmget02.c:95: TFAIL: shmget(1644199826, 4278190080, 1536)
expected EINVAL: ENOMEM (12)
With suggest by Manfred Spraul we could reduce the value
of '/proc/sys/kernel/shmmax' in compat mode and only test
the overflow behavior with default+1.
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Manfred Spraul <manfred@colorfullife.com>
---
testcases/kernel/syscalls/ipc/shmget/shmget02.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget02.c b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
index 7989ef33e..faf633ad4 100644
--- a/testcases/kernel/syscalls/ipc/shmget/shmget02.c
+++ b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
@@ -56,7 +56,11 @@ static struct tcase {
{&shmkey1, SHM_SIZE, IPC_EXCL, 0, 0, ENOENT},
{&shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL, 0, 0, EEXIST},
{&shmkey1, SHMMIN - 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
+#ifdef TST_ABI32
+ {&shmkey1, 8192 + 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
+#else
{&shmkey1, SHMMAX + 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
+#endif
{&shmkey, SHM_SIZE * 2, IPC_EXCL, 0, 0, EINVAL},
{&shmkey, SHM_SIZE, SHM_RD, 1, 0, EACCES},
{&shmkey1, SHM_SIZE, IPC_CREAT | SHM_HUGETLB, 0, 1, EPERM},
@@ -149,4 +153,10 @@ static struct tst_test test = {
.test = do_test,
.tcnt = ARRAY_SIZE(tcases),
.hugepages = {TST_NO_HUGEPAGES},
+#ifdef TST_ABI32
+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/kernel/shmmax", "8192", TST_SR_TBROK},
+ {}
+ },
+#endif
};
--
2.40.1
More information about the ltp
mailing list