semctl09: Fix heap smash
PATCH 1/1 semctl09: Fix heap smash
semctl() expects pointer to a buffer as its fourth argument, not pointer to a pointer. Passing &un.buf results in heap smash that corrupts internal LTP data structures on some archs.
CC Feiyu Zhu <[email protected]>
Signed-off-by Martin Doucha <[email protected]>
--- testcases/kernel/syscalls/ipc/semctl/semctl09.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/ipc/semctl/semctl09.c +6 -2
@@ -51,11 +51,15 @@ static union semun un;*/ static inline int do_semctl (int semid,int semnum,int cmd) { +struct semid_ds info; + + un.buf = &info; +switch (tst_variant) {case 0 : -return tst_syscall (__NR_semctl, semid, semnum, cmd, &un.buf); +return tst_syscall (__NR_semctl, semid, semnum, cmd, un);case 1 : -return semctl (semid, semnum, cmd, &un.buf); +return semctl (semid, semnum, cmd, un); }return -1 ; }
Signature · 1 line
2.29.2
PATCH 1/1 semctl09: Fix heap smash
Hi Martin
LGTM, pushed. Thanks.
Best Regards
Yang Xu
Quoted 32 lines
semctl()expects pointer to a buffer as its fourth argument, not pointer to a pointer. Passing&un.buf results in heap smash that corrupts internal LTP data structures on some archs.CC Feiyu Zhu<[email protected]>Signed-off-by Martin Doucha<[email protected]>--- testcases/kernel/syscalls/ipc/semctl/semctl09.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)testcases/kernel/syscalls/ipc/semctl/semctl09.c +6
-2@@ -51,11 +51,15 @@ static union semun un;*/ static inline int do_semctl (int semid,int semnum,int cmd) { +struct semid_ds info; + + un.buf =&info; +switch (tst_variant) {case 0 : -return tst_syscall (__NR_semctl, semid, semnum, cmd,&un.buf); +return tst_syscall (__NR_semctl, semid, semnum, cmd, un);case 1 : -return semctl (semid, semnum, cmd,&un.buf); +return semctl (semid, semnum, cmd, un); }return -1 ; }