[LTP] [PATCH 1/4] syscalls/ipc: shmctl04: Parse /proc/sysvipc/shm size as unsigned long
Guixiong Wei
weiguixiong@bytedance.com
Mon Feb 23 04:19:00 CET 2026
The size column in /proc/sysvipc/shm may exceed int range on
some systems. Parse it as unsigned long.
Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
---
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
index 3ba05f9b5..908cd2926 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
@@ -57,7 +57,8 @@ static void parse_proc_sysvipc(struct shm_info *info)
break;
}
- int shmid, size, rss, swap;
+ int shmid, rss, swap;
+ unsigned long size;
/*
* Sum rss, swap and size for all elements listed, which should equal
@@ -66,7 +67,7 @@ static void parse_proc_sysvipc(struct shm_info *info)
* Note that the size has to be rounded up to nearest multiple of page
* size.
*/
- while (fscanf(f, "%*i %i %*i %i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %i %i",
+ while (fscanf(f, "%*i %i %*i %lu %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %i %i",
&shmid, &size, &rss, &swap) > 0) {
used_ids++;
shm_rss += rss/page_size;
--
2.20.1
More information about the ltp
mailing list