Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode
@ 2026-09-25  8:28 Petr Vorel
  2026-09-25  8:28 ` [LTP] [PATCH v3 1/2] " Petr Vorel
  2026-09-25  8:28 ` [LTP] [PATCH v3 2/2] shmctl03: Use test macros Petr Vorel
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2026-09-25  8:28 UTC (permalink / raw)
  To: ltp

Changes v2->v3:
* Drop first fix from Andrea:
  https://lore.kernel.org/ltp/20260924112514.2375626-2-pvorel@suse.cz/
  I'm no longer confident it's a good idea even if we document changed
  behavior. See my concern:
  https://lore.kernel.org/ltp/20260925080154.GC2387785@pevik/
  Maybe we should either handle this entirely in shmctl03.c as there is
  no other test which needs it.
* Use unsigned long instead of unsigned long long (no need for that big
  variable)
* Use correct macro TST_EXP_EQ_LU() (agent)
* Read shmmax only once (agent)
* TST_EXP_POSITIVE SAFE_SHMCTL() instead of safe_shmctl() (no TBROK
  instead of TFAIL in case of failure and it's probably slightly more
  readable)

Petr Vorel (2):
  shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode
  shmctl03: Use test macros

 testcases/kernel/syscalls/shmctl/shmctl03.c | 24 ++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.55.0


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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

* Re: [LTP] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode
  2026-09-25  8:28 ` [LTP] [PATCH v3 1/2] " Petr Vorel
@ 2026-09-25 11:21   ` linuxtestproject.agent
  0 siblings, 0 replies; 4+ messages in thread
From: linuxtestproject.agent @ 2026-09-25 11:21 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr,

On Fri, 25 Sep 2026 10:28:39 +0200, Petr Vorel wrote:
> [PATCH 1/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode

--- [PATCH 1/2] ---

> +	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);

Testing `info.shmmax == INT_MAX` in the condition masks regressions; if the
kernel fails to clamp `info.shmmax`, execution takes the else branch and
reports TPASS. Additionally, `TST_EXP_LE_LU(INT_MAX, shmmax)` compares
`INT_MAX` against `shmmax` rather than verifying `info.shmmax`. Use
`unsigned long long` with `"%llu"` to avoid 32-bit overflow when reading
`PATH_KERN_SHMMAX`, and assert `info.shmmax` equals `INT_MAX` when
`tst_is_compat_mode() && shmmax > INT_MAX` (or `shmmax` otherwise).

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-25 11:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 11:21   ` [LTP] " linuxtestproject.agent
2026-09-25  8:28 ` [LTP] [PATCH v3 2/2] shmctl03: Use test macros Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox