[LTP] shmctl03.c is broken for 32bit compat mode

Cyril Hrubis chrubis@suse.cz
Mon Aug 11 11:35:04 CEST 2025


Hi!
> To be honest, the correct thing with regards to shmall is to cap it at
> INT_MAX in the kernel as well.  I didn't want to suggest this because it
> was Friday afternoon.  Reporting whatever is in the low 32bits is sort
> of random.  But that would make it even more tricky to handle in LTP.

We have tst_is_compat_mode() helper that returns true if we are running
in 32bit compatibility mode. So I suppose that we need a flag for the
TST_ASSERT_ULONG() that would tell it to do a saturated comparsion:

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
index a3291c37f..5e33b3a2c 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
@@ -16,6 +16,7 @@
 static void verify_ipcinfo(void)
 {
        struct shminfo info;
+       int flag = 0;

        TEST(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));

@@ -30,9 +31,12 @@ static void verify_ipcinfo(void)
        else
                tst_res(TPASS, "shmmin = 1");

-       TST_ASSERT_ULONG("/proc/sys/kernel/shmmax", info.shmmax);
-       TST_ASSERT_ULONG("/proc/sys/kernel/shmmni", info.shmmni);
-       TST_ASSERT_ULONG("/proc/sys/kernel/shmall", info.shmall);
+       if (tst_is_compat_mode())
+               flag = TST_ASSERT_ULONG_SATURATED;
+
+       TST_ASSERT_ULONG("/proc/sys/kernel/shmmax", info.shmmax, flag);
+       TST_ASSERT_ULONG("/proc/sys/kernel/shmmni", info.shmmni, flag);
+       TST_ASSERT_ULONG("/proc/sys/kernel/shmall", info.shmall, flag);
 }

And the TST_ASSERT_ULONG() would read the syfs file as unsigned long
long and if the saturated flag is present cap it at ULONG_MAX.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list