[LTP] [PATCH v9 2/2] shmctl03: Fix 32-bit compat mode failure

Petr Vorel pvorel@suse.cz
Wed Sep 2 11:06:45 CEST 2026


Hi Wei,

> 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.

> Fix this by utilizing the new TST_ASSERT_ULONG() flags to properly
> clamp and truncate the expected values under compat mode.
...
> -	TST_ASSERT_ULONG(PATH_KERN_SHMMAX, info.shmmax);
> -	TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni);
> -	TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall);
> +	int c = tst_is_compat_mode();
> +
> +	/*
> +	 * On 64-bit kernel, shmmax is clamped to INT_MAX for 32-bit
> +	 * compat syscall, while shmmni and shmall are truncated
> +	 * to 32-bit.
> +	 */
> +	TST_ASSERT_ULONG(PATH_KERN_SHMMAX, info.shmmax, c ? TST_ASSERT_SATURATED_INT : TST_ASSERT_NONE);
> +	TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni, c ? TST_ASSERT_TRUNC_32BIT : TST_ASSERT_NONE);
> +	TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall, c ? TST_ASSERT_TRUNC_32BIT : TST_ASSERT_NONE);

Obviously correct (with the fact I already noted, that I'd use 0 instead adding
TST_ASSERT_NONE into enum).

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list