* [LTP] [PATCH v3 1/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode
2026-09-25 8:28 [LTP] [PATCH v3 0/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode Petr Vorel
@ 2026-09-25 8:28 ` Petr Vorel
2026-09-25 11:21 ` [LTP] " linuxtestproject.agent
2026-09-25 8:28 ` [LTP] [PATCH v3 2/2] shmctl03: Use test macros Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2026-09-25 8:28 UTC (permalink / raw)
To: ltp
Kernel clamped shmmax returned from shmctl(IPC_INFO) in 32bit compat
mode to INT_MAX due to a change in kernel v2.6.22 in commit
af7c693f14606 ("Cap shmmax at INT_MAX in compat shminfo").
Reflect that.
This fixes error:
shmctl03.c:33: TFAIL: /proc/sys/kernel/shmmax != 2147483647 got 4294967295
Reported-by: Wei Gao <wegao@suse.com>
Suggested-by: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/syscalls/shmctl/shmctl03.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/shmctl/shmctl03.c b/testcases/kernel/syscalls/shmctl/shmctl03.c
index 9e1c2f0990..f2b735dc85 100644
--- a/testcases/kernel/syscalls/shmctl/shmctl03.c
+++ b/testcases/kernel/syscalls/shmctl/shmctl03.c
@@ -16,6 +16,7 @@
static void verify_ipcinfo(void)
{
struct shminfo info;
+ unsigned long shmmax;
TEST(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));
@@ -30,7 +31,12 @@ static void verify_ipcinfo(void)
else
tst_res(TPASS, "shmmin = 1");
- TST_ASSERT_ULONG(PATH_KERN_SHMMAX, info.shmmax);
+ SAFE_FILE_SCANF(PATH_KERN_SHMMAX, "%lu", &shmmax);
+ if (tst_is_compat_mode() && info.shmmax == INT_MAX)
+ TST_EXP_LE_LU(INT_MAX, shmmax);
+ else
+ TST_EXP_EQ_LU(info.shmmax, shmmax);
+
TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni);
TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall);
}
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread* [LTP] [PATCH v3 2/2] shmctl03: Use test macros
2026-09-25 8:28 [LTP] [PATCH v3 0/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode Petr Vorel
2026-09-25 8:28 ` [LTP] [PATCH v3 1/2] " Petr Vorel
@ 2026-09-25 8:28 ` Petr Vorel
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2026-09-25 8:28 UTC (permalink / raw)
To: ltp
Use test macros to shorten the code.
Link manpage.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/syscalls/shmctl/shmctl03.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/testcases/kernel/syscalls/shmctl/shmctl03.c b/testcases/kernel/syscalls/shmctl/shmctl03.c
index f2b735dc85..bccab5ba37 100644
--- a/testcases/kernel/syscalls/shmctl/shmctl03.c
+++ b/testcases/kernel/syscalls/shmctl/shmctl03.c
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2020 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) Linux Test Project, 2026
*/
/*\
- * Call shmctl() with IPC_INFO flag and check that the data are consistent with
- * /proc/sys/kernel/shm*.
+ * Call :manpage:`shmctl(2)` with IPC_INFO flag and check that the data are
+ * consistent with /proc/sys/kernel/shm*.
*/
#define _GNU_SOURCE
@@ -18,18 +19,11 @@ static void verify_ipcinfo(void)
struct shminfo info;
unsigned long shmmax;
- TEST(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));
-
- if (TST_RET < 0) {
- tst_res(TFAIL | TTERRNO,
- "shmctl(0, IPC_INFO, ...) returned %li", TST_RET);
+ TST_EXP_POSITIVE(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));
+ if (!TST_PASS)
return;
- }
- if (info.shmmin != 1)
- tst_res(TFAIL, "shmmin = %li, expected 1", info.shmmin);
- else
- tst_res(TPASS, "shmmin = 1");
+ TST_EXP_EQ_LU(info.shmmin, 1);
SAFE_FILE_SCANF(PATH_KERN_SHMMAX, "%lu", &shmmax);
if (tst_is_compat_mode() && info.shmmax == INT_MAX)
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread