[PATCH 5.17 156/225] io_uring: fix uninitialized field in rw io_kiocb
From: Greg Kroah-Hartman
Date: Wed May 04 2022 - 13:45:14 EST
From: Joseph Ravichandran <jravi@xxxxxxx>
[ 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@xxxxxxx>
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
fs/io_uring.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 531d0086d0b3..87df37912055 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3584,6 +3584,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)
return -EOPNOTSUPP;
+ kiocb->private = NULL;
kiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;
kiocb->ki_complete = io_complete_rw_iopoll;
req->iopoll_completed = 0;
--
2.35.1