io_submit: Use TST_PTR_TO_UINT() for aio_buf
PATCH 1/1 io_submit: Use TST_PTR_TO_UINT() for aio_buf
From: Victor Cheng-Yen Yang <[email protected]>
GCC sign-extends a 32-bit pointer cast straight to a 64-bit integer, so a buffer at or above 0x80000000 is passed as 0xffffffff8xxxxxxx and io_submit() fails with EINVAL. The static buffer can land there in a PIE binary with ASLR, and io_submit02 and io_submit03 then fail intermittently.
Fixes 7fb2b884ae8f ("syscalls/io_submit: Add io_submit02 test for native AIO")
Fixes cd99e77be2ef ("syscalls/io_submit: Add io_submit03 test for native AIO")
Signed-off-by Victor Cheng-Yen Yang <[email protected]>
--- testcases/kernel/syscalls/io_submit/io_submit02.c | 2 +- testcases/kernel/syscalls/io_submit/io_submit03.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/io_submit/io_submit02.c +1 -1
@@ -45,7 +45,7 @@ static inline void io_prep_option(struct iocb *cb, int fd, void *buf,memset (cb,0 ,sizeof (*cb)); cb->aio_fildes = fd; cb->aio_lio_opcode = opcode; - cb->aio_buf = (uint64_t )buf; + cb->aio_buf =TST_PTR_TO_UINT (buf); cb->aio_offset = offset; cb->aio_nbytes = count; }
testcases/kernel/syscalls/io_submit/io_submit03.c +1 -1
@@ -71,7 +71,7 @@ static inline void io_prep_option(struct iocb *cb, int fd, void *buf,memset (cb,0 ,sizeof (*cb)); cb->aio_fildes = fd; cb->aio_lio_opcode = opcode; - cb->aio_buf = (uint64_t )buf; + cb->aio_buf =TST_PTR_TO_UINT (buf); cb->aio_offset = offset; cb->aio_nbytes = count; }
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Victor,
Quoted 1 line · Victor Cheng-Yen Yang
io_submit: UseTST_PTR_TO_UINT()foraio_buf
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp