[LTP] shmctl03: Fix 32-bit compat mode failure by adjusting comparisons for compat mode truncation

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Apr 29 10:04:00 CEST 2026


Hi Wei,

On Mon, 13 Apr 2026 06:19:53 +0000, Wei Gao wrote:
> shmctl03: Fix 32-bit compat mode failure by adjusting comparisons for compat mode truncation

> +#define TST_ASSERT_SATURATED_INT   0x01
> +#define TST_ASSERT_SATURATED_ULONG 0x02
> +#define TST_ASSERT_BITWISE         0x04

TST_ASSERT_SATURATED_ULONG is never used in this patch. Either remove it
or rename it to TST_ASSERT_SATURATED_U32 — the current name implies
saturation at ULONG_MAX but it actually clamps to UINT_MAX (32-bit).

> +void tst_assert_ulong(const char *file, const int lineno, const char *path,
> +			unsigned long val, int flags)

Continuation should align with the opening '(' to match the declaration
in tst_assert.h.

> +	if (tst_is_compat_mode()) {
> +		TST_ASSERT_ULONG("/proc/sys/kernel/shmmax", info.shmmax, TST_ASSERT_SATURATED_INT);
> +		TST_ASSERT_ULONG("/proc/sys/kernel/shmmni", info.shmmni, TST_ASSERT_BITWISE);
> +		TST_ASSERT_ULONG("/proc/sys/kernel/shmall", info.shmall, TST_ASSERT_BITWISE);

Add a comment here explaining why shmmax uses saturation at INT_MAX while
shmmni/shmall use bitwise truncation — the choice is non-obvious without
knowing the kernel compat path behaviour.

> +Signed-off-by: Wei Gao <wegao@suse.com>

This is a bug fix; please add a Fixes: tag pointing to the commit that
originally added shmctl03 without compat mode handling.

Pre-existing issues noticed in the surrounding code (not introduced
by this patch):

- testcases/kernel/syscalls/ipc/shmctl/shmctl03.c:12 — includes
  tse_newipc.h using the non-standard tse_ prefix instead of tst_.

---
Note:

Our agent completed the review of the patch. The full review can be
found at: https://patchwork.ozlabs.org/project/ltp/list/?series=499648

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


More information about the ltp mailing list