* [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode
@ 2026-10-26 15:16 Petr Vorel
2026-10-26 16:35 ` [LTP] " linuxtestproject.agent
2026-11-10 9:58 ` [LTP] [PATCH 1/1] " Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2026-10-26 15:16 UTC (permalink / raw)
To: ltp
Unlike shmmax, the kernel's compat shmctl(IPC_INFO) path does not clamp
shmall but truncates the 64-bit value into the 32-bit compat shminfo
(see copy_compat_shminfo_to_user() in ipc/shm.c, originally changed by
af7c693f14606 ("Cap shmmax at INT_MAX in compat shminfo") in kernel
v2.6.22.
Parsing /proc/sys/kernel/shmall's full decimal value with "%lu" into a
32-bit unsigned long saturates to ULONG_MAX instead of truncating,
causing a mismatch. Read it into an unsigned long long and compare
against the low 32 bits in compat mode.
Because this is a test specific error, fix it in the test itself instead
adding support to the LTP library.
This fixes error:
shmctl03.c:35: TFAIL: /proc/sys/kernel/shmall != 4294967040 got 4294967295
Reported-by: Wei Gao <wegao@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,
yet another attempt to fix struct shminfo shmall.
I believe in the end this is better than a general approach I posted
previously based on Andrea's suggestion [1] or older Wei's approach [2][3]
based on Cyril's suggestion.
Kind regards,
Petr
[1] https://patchwork.kernel.org/project/ltp/patch/20260924112514.2375626-2-pvorel@suse.cz/
[2] https://patchwork.kernel.org/project/ltp/patch/20260903095255.4925-3-wegao@suse.com/
[3] https://patchwork.kernel.org/project/ltp/patch/20260903095255.4925-2-wegao@suse.com/
testcases/kernel/syscalls/shmctl/shmctl03.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/shmctl/shmctl03.c b/testcases/kernel/syscalls/shmctl/shmctl03.c
index bccab5ba37..e5937fd023 100644
--- a/testcases/kernel/syscalls/shmctl/shmctl03.c
+++ b/testcases/kernel/syscalls/shmctl/shmctl03.c
@@ -18,6 +18,7 @@ static void verify_ipcinfo(void)
{
struct shminfo info;
unsigned long shmmax;
+ unsigned long long shmall;
TST_EXP_POSITIVE(shmctl(0, IPC_INFO, (struct shmid_ds *)&info));
if (!TST_PASS)
@@ -32,7 +33,18 @@ static void verify_ipcinfo(void)
TST_EXP_EQ_LU(info.shmmax, shmmax);
TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni);
- TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall);
+
+ /*
+ * On 32-bit compat, the kernel truncates the (64-bit) shmall to the
+ * 32-bit compat shminfo, instead of clamping it like shmmax. The
+ * /proc file still holds the untruncated value, so compare against
+ * its low 32 bits.
+ */
+ SAFE_FILE_SCANF(PATH_KERN_SHMALL, "%llu", &shmall);
+ if (tst_is_compat_mode())
+ TST_EXP_EQ_LU(info.shmall, (uint32_t)shmall);
+ else
+ TST_EXP_EQ_LU(info.shmall, shmall);
}
static struct tst_test test = {
--
2.56.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode
2026-10-26 15:16 [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode Petr Vorel
@ 2026-10-26 16:35 ` linuxtestproject.agent
2026-11-10 9:58 ` [LTP] [PATCH 1/1] " Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: linuxtestproject.agent @ 2026-10-26 16:35 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi Petr,
On Mon Oct 26 16:16:38 2026 +0100, Petr Vorel <pvorel@suse.cz> wrote:
> shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode
Verdict - Reviewed
---
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
* Re: [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode
2026-10-26 15:16 [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode Petr Vorel
2026-10-26 16:35 ` [LTP] " linuxtestproject.agent
@ 2026-11-10 9:58 ` Cyril Hrubis
2026-11-10 11:13 ` Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2026-11-10 9:58 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Unlike shmmax, the kernel's compat shmctl(IPC_INFO) path does not clamp
> shmall but truncates the 64-bit value into the 32-bit compat shminfo
> (see copy_compat_shminfo_to_user() in ipc/shm.c, originally changed by
> af7c693f14606 ("Cap shmmax at INT_MAX in compat shminfo") in kernel
> v2.6.22.
Sigh, this does look very random, one value is truncated and one is
saturated. I wonder if we should send a patch to kernel so that both
values are saturated, that would make much more sense to me.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode
2026-11-10 9:58 ` [LTP] [PATCH 1/1] " Cyril Hrubis
@ 2026-11-10 11:13 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2026-11-10 11:13 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
> Hi!
> > Unlike shmmax, the kernel's compat shmctl(IPC_INFO) path does not clamp
> > shmall but truncates the 64-bit value into the 32-bit compat shminfo
> > (see copy_compat_shminfo_to_user() in ipc/shm.c, originally changed by
> > af7c693f14606 ("Cap shmmax at INT_MAX in compat shminfo") in kernel
> > v2.6.22.
> Sigh, this does look very random, one value is truncated and one is
> saturated. I wonder if we should send a patch to kernel so that both
> values are saturated, that would make much more sense to me.
IMHO it makes sense, but I will not have time for it before December.
Will you have time to do it?
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-10 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 15:16 [LTP] [PATCH 1/1] shmctl03: Fix shmall clamped to UINT32_MAX in 32bit compat mode Petr Vorel
2026-10-26 16:35 ` [LTP] " linuxtestproject.agent
2026-11-10 9:58 ` [LTP] [PATCH 1/1] " Cyril Hrubis
2026-11-10 11:13 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox