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

Wei Gao wegao@suse.com
Thu May 7 11:51:51 CEST 2026


On Wed, May 06, 2026 at 05:28:18PM +0000, Andrea Cervesato wrote:
> Hi Wei,
> 
> the agent review seems to be valid. The shmmax is defined as
> unsigned long and we should keep the unsigned state of the
> variable.

Kernel indeed saturates shmmax to INT_MAX for compat syscalls
Relevant kernel code in ipc/shm.c:

static int copy_compat_shminfo_to_user(void __user *buf, struct shminfo64 *in,
                                        int version)
{
        if (in->shmmax > INT_MAX)
                in->shmmax = INT_MAX; <<<<<<<
        if (version == IPC_64) {
                struct compat_shminfo64 info;
                memset(&info, 0, sizeof(info));
                info.shmmax = in->shmmax;

> 
> Please verify that it works and we can proceed with the patch.
> 
> Regards,
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com


More information about the ltp mailing list