Skip to contentSkip to conversation

shmctl03: Fix 32-bit compat mode failure by forcing limits

PATCH In review Wei Gao via ltp 1 participant 2 messages Jan 28 – Feb 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shmctl03: Fix 32-bit compat mode failure by forcing limits

On 64-bit kernels, the default shmmax and shmall values often exceed the range of a 32-bit unsigned long or are clipped differently by the kernel's compat syscall layer than they appear in /proc.

---
 testcases/kernel/syscalls/ipc/shmctl/shmctl03.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
testcases/kernel/syscalls/ipc/shmctl/shmctl03.c +12 -0
index a3291c37f..335a60980 100644
@@ -13,6 +13,13 @@
 #include "tst_safe_sysv_ipc.h"
 #include "libnewipc.h"
 
+/* Force 32-bit limits to avoid overflow/mismatch on 64-bit kernels */
+#if __WORDSIZE == 32
+# define SET_SHM_LIMIT "2147483647"
+#else
+# define SET_SHM_LIMIT NULL
+#endif
+
 static void verify_ipcinfo(void)
 {
 	struct shminfo info;
@@ -37,4 +44,9 @@ static void verify_ipcinfo(void)
 
 static struct tst_test test = {
 	.test_all = verify_ipcinfo,
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/kernel/shmmax", SET_SHM_LIMIT, TST_SR_TCONF_MISSING},
+		{"/proc/sys/kernel/shmall", SET_SHM_LIMIT, TST_SR_TCONF_MISSING},
+		{}
+	},
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

We already have a discussion on this test, so we should take a look at there " [LTP] shmctl03.c is broken for 32bit compat mode ". Apparently, from 08 August 2025...

Signature · 7 lines
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp