]> git.itanic.dy.fi Git - linux-stable/commit
io_uring/rw: don't attempt to allocate async data if opcode doesn't need it
authorJens Axboe <axboe@kernel.dk>
Fri, 3 Nov 2023 15:26:13 +0000 (09:26 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Nov 2023 15:31:21 +0000 (09:31 -0600)
commit0df96fb71a395b4fc9c80180306420c743f395a8
treecb67a5bb57df72168707174c6bf1f883827b00c3
parent8f6f76a6a29f36d2f3e4510d0bde5046672f6924
io_uring/rw: don't attempt to allocate async data if opcode doesn't need it

The new read multishot method doesn't need to allocate async data ever,
as it doesn't do vectored IO and it must only be used with provided
buffers. While it doesn't have ->prep_async() set, it also sets
->async_size to 0, which is different from any other read/write type we
otherwise support.

If it's used on a file type that isn't pollable, we do try and allocate
this async data, and then try and use that data. But since we passed in
a size of 0 for the data, we get a NULL back on data allocation. We then
proceed to dereference that to copy state, and that obviously won't end
well.

Add a check in io_setup_async_rw() for this condition, and avoid copying
state. Also add a check for whether or not buffer selection is specified
in prep while at it.

Fixes: fc68fcda0491 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218101
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rw.c