diff mbox series

[5.17,156/225] io_uring: fix uninitialized field in rw io_kiocb

Message ID 20220504153123.976903087@linuxfoundation.org
State New
Headers show
Series None | expand

Commit Message

gregkh@linuxfoundation.org May 4, 2022, 4:46 p.m. UTC
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>
---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

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;