Skip to content

Commit 6faaf6e

Browse files
isilenceaxboe
authored andcommitted
io_uring/cmd: warn on reg buf imports by ineligible cmds
For IORING_URING_CMD_FIXED-less commands io_uring doesn't pull buf_index from the sqe, so imports might succeed if the index coincide, e.g. when it's 0, but otherwise it's error prone. Warn if someone tries to import without the flag. Signed-off-by: Pavel Begunkov <[email protected]> Reviewed-by: Anuj Gupta <[email protected]> Link: https://lore.kernel.org/r/a1c2c88e53c3fe96978f23d50c6bc66c2c79c337.1747991070.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 0b2b066 commit 6faaf6e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

io_uring/uring_cmd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
275275
{
276276
struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
277277

278+
if (WARN_ON_ONCE(!(ioucmd->flags & IORING_URING_CMD_FIXED)))
279+
return -EINVAL;
280+
278281
return io_import_reg_buf(req, iter, ubuf, len, rw, issue_flags);
279282
}
280283
EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
@@ -289,6 +292,9 @@ int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
289292
struct io_async_cmd *ac = req->async_data;
290293
int ret;
291294

295+
if (WARN_ON_ONCE(!(ioucmd->flags & IORING_URING_CMD_FIXED)))
296+
return -EINVAL;
297+
292298
ret = io_prep_reg_iovec(req, &ac->vec, uvec, uvec_segs);
293299
if (ret)
294300
return ret;

0 commit comments

Comments
 (0)