Patch "io_uring: zero iocb->ki_pos for stream file types" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring: zero iocb->ki_pos for stream file types

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-zero-iocb-ki_pos-for-stream-file-types.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 89cd295ff6066f01103f802e943ef5b915313d15
Author: Jens Axboe <axboe@xxxxxxxxx>
Date:   Wed Dec 22 20:26:56 2021 -0700

    io_uring: zero iocb->ki_pos for stream file types
    
    [ Upstream commit 7b9762a5e8837b92a027d58d396a9d27f6440c36 ]
    
    io_uring supports using offset == -1 for using the current file position,
    and we read that in as part of read/write command setup. For the non-iter
    read/write types we pass in NULL for the position pointer, but for the
    iter types we should not be passing any anything but 0 for the position
    for a stream.
    
    Clear kiocb->ki_pos if the file is a stream, don't leave it as -1. If we
    do, then the request will error with -ESPIPE.
    
    Fixes: ba04291eb66e ("io_uring: allow use of offset == -1 to mean file position")
    Link: https://github.com/axboe/liburing/discussions/501
    Reported-by: Samuel Williams <samuel.williams@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/io_uring.c b/fs/io_uring.c
index e9b06e339c4b0..0006fc7479ca3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2879,9 +2879,13 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 		req->flags |= REQ_F_ISREG;
 
 	kiocb->ki_pos = READ_ONCE(sqe->off);
-	if (kiocb->ki_pos == -1 && !(file->f_mode & FMODE_STREAM)) {
-		req->flags |= REQ_F_CUR_POS;
-		kiocb->ki_pos = file->f_pos;
+	if (kiocb->ki_pos == -1) {
+		if (!(file->f_mode & FMODE_STREAM)) {
+			req->flags |= REQ_F_CUR_POS;
+			kiocb->ki_pos = file->f_pos;
+		} else {
+			kiocb->ki_pos = 0;
+		}
 	}
 	kiocb->ki_hint = ki_hint_validate(file_write_hint(kiocb->ki_filp));
 	kiocb->ki_flags = iocb_flags(kiocb->ki_filp);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux