[LTP] [PATCH v3 1/2] shmctl03: Fix shmmax clamped to INT_MAX in 32bit compat mode

Cyril Hrubis chrubis@suse.cz
Thu Oct 22 15:25:49 CEST 2026


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

Looks to me.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

>  	TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni);
>  	TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall);
>  }
> -- 
> 2.55.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list