Skip to content

Commit f201308

Browse files
committed
shmget02: reduce the shmmax test value for compat mode
As Arnd Bergmann pointed out that SHMMAX being defined as (ULONG_MAX - (1UL << 24)), so the kernel would likely use a large 64-bit value, while the 32-bit user space uses a much smaller limit. It finally results in ENOMEM failure: shmget02.c:95: TFAIL: shmget(1644199826, 4278190080, 1536) expected EINVAL: ENOMEM (12) With suggest by Manfred Spraul we could reduce the value of '/proc/sys/kernel/shmmax' for compat mode and only test the overflow behavior with default+1. Reported-by: Linux Kernel Functional Testing <[email protected]> Signed-off-by: Li Wang <[email protected]> Cc: Naresh Kamboju <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Manfred Spraul <[email protected]> Reviewed-by: Martin Doucha <[email protected]>
1 parent 2c577f2 commit f201308

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

testcases/kernel/syscalls/ipc/shmget/shmget02.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static struct tcase {
5656
{&shmkey1, SHM_SIZE, IPC_EXCL, 0, 0, ENOENT},
5757
{&shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL, 0, 0, EEXIST},
5858
{&shmkey1, SHMMIN - 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
59-
{&shmkey1, SHMMAX + 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
59+
{&shmkey1, 8192 + 1, IPC_CREAT | IPC_EXCL, 0, 0, EINVAL},
6060
{&shmkey, SHM_SIZE * 2, IPC_EXCL, 0, 0, EINVAL},
6161
{&shmkey, SHM_SIZE, SHM_RD, 1, 0, EACCES},
6262
{&shmkey1, SHM_SIZE, IPC_CREAT | SHM_HUGETLB, 0, 1, EPERM},
@@ -149,4 +149,8 @@ static struct tst_test test = {
149149
.test = do_test,
150150
.tcnt = ARRAY_SIZE(tcases),
151151
.hugepages = {TST_NO_HUGEPAGES},
152+
.save_restore = (const struct tst_path_val[]) {
153+
{"/proc/sys/kernel/shmmax", "8192", TST_SR_TCONF_MISSING | TST_SR_TBROK_RO},
154+
{}
155+
},
152156
};

0 commit comments

Comments
 (0)