Skip to content

Commit 49fbe99

Browse files
DylanZAaxboe
authored andcommitted
io_uring: do not allow multishot read to set addr or len
For addr: this field is not used, since buffer select is forced. But by forcing it to be zero it leaves open future uses of the field. len is actually usable, you could imagine that you want to receive multishot up to a certain length. However right now this is not how it is implemented, and it seems safer to force this to be zero. Fixes: fc68fcd ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT") Signed-off-by: Dylan Yudaken <dyudaken@gmail.com> Link: https://lore.kernel.org/r/20231106203909.197089-3-dyudaken@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 89d528b commit 49fbe99

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

io_uring/rw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ int io_prep_rw_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe)
143143
*/
144144
int io_read_mshot_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
145145
{
146+
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
146147
int ret;
147148

148149
/* must be used with provided buffers */
@@ -153,6 +154,9 @@ int io_read_mshot_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
153154
if (unlikely(ret))
154155
return ret;
155156

157+
if (rw->addr || rw->len)
158+
return -EINVAL;
159+
156160
req->flags |= REQ_F_APOLL_MULTISHOT;
157161
return 0;
158162
}

0 commit comments

Comments
 (0)