]> git.ipfire.org Git - thirdparty/linux.git/commit
io_uring: kiocb_done() should *not* trust ->ki_pos if ->{read,write}_iter() failed
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 28 Aug 2023 22:47:31 +0000 (18:47 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 28 Oct 2023 00:14:11 +0000 (20:14 -0400)
commit1939316bf988f3e49a07d9c4dd6f660bf4daa53d
tree41ba99310df374f9125e15ee15f2a8e08dec6dd0
parent1f36cd05e0081f2c75769a551d584c4ffb2a5660
io_uring: kiocb_done() should *not* trust ->ki_pos if ->{read,write}_iter() failed

->ki_pos value is unreliable in such cases.  For an obvious example,
consider O_DSYNC write - we feed the data to page cache and start IO,
then we make sure it's completed.  Update of ->ki_pos is dealt with
by the first part; failure in the second ends up with negative value
returned _and_ ->ki_pos left advanced as if sync had been successful.
In the same situation write(2) does not advance the file position
at all.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
io_uring/rw.c