[PATCH 5.10.y] io_uring: fix uninitialized field in rw io_kiocb

Miguel Gazquez (Schneider Electric) posted 1 patch 1 week, 1 day ago
io_uring/io_uring.c | 1 +
1 file changed, 1 insertion(+)
[PATCH 5.10.y] io_uring: fix uninitialized field in rw io_kiocb
Posted by Miguel Gazquez (Schneider Electric) 1 week, 1 day ago
From: Joseph Ravichandran <jravi@mit.edu>

[ Upstream commit 32452a3eb8b64e01e2be717f518c0be046975b9d ]

io_rw_init_file does not initialize kiocb->private, so when iocb_bio_iopoll
reads kiocb->private it can contain uninitialized data.

Fixes: 3e08773c3841 ("block: switch polling to be bio based")
Signed-off-by: Joseph Ravichandran <jravi@mit.edu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Miguel Gazquez (Schneider Electric) <miguel.gazquez@bootlin.com>
---
 io_uring/io_uring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 01eff1694d8c..c1716140348b 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2985,6 +2985,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 		    !kiocb->ki_filp->f_op->iopoll)
 			return -EOPNOTSUPP;
 
+		kiocb->private = NULL;
 		kiocb->ki_flags |= IOCB_HIPRI;
 		kiocb->ki_complete = io_complete_rw_iopoll;
 		req->iopoll_completed = 0;

---
base-commit: 1797d8bf8d0c2e74defad605d14e3553d43a3caf
change-id: 20260916-cve-2022-29968-09cc4ab776fa

Best regards,
--  
Miguel Gazquez (Schneider Electric) <miguel.gazquez@bootlin.com>
Re: [PATCH 5.10.y] io_uring: fix uninitialized field in rw io_kiocb
Posted by Sasha Levin 1 week ago
> +		kiocb->private = NULL;

I am dropping this one: the assignment is dead code on 5.10.

The Fixes: target 3e08773c3841 ("block: switch polling to be bio based")
is v5.16, so iocb_bio_iopoll() does not exist on 5.10 and nothing reads
the uninitialized value. __iomap_dio_rw() writes iocb->private
unconditionally before its only -EIOCBQUEUED return, and io_do_iopoll()
skips ->iopoll whenever iopoll_completed is set. The same holds for
5.15, which is also pre-5.16.

-- 
Thanks,
Sasha