Skip to content

Commit 3ff0a89

Browse files
axboegregkh
authored andcommitted
io_uring: gate REQ_F_ISREG on !S_ANON_INODE as well
commit 6f11adc upstream. io_uring marks a request as dealing with a regular file on S_ISREG. This drives things like retries on short reads or writes, which is generally not expected on a regular file (or bdev). Applications tend to not expect that, so io_uring tries hard to ensure it doesn't deliver short IO on regular files. However, a recent commit added S_IFREG to anonymous inodes. When io_uring is used to read from various things that are backed by anon inodes, like eventfd, timerfd, etc, then it'll now all of a sudden wait for more data when rather than deliver what was read or written in a single operation. This breaks applications that issue reads on anon inodes, if they ask for more data than a single read delivers. Add a check for !S_ANON_INODE as well before setting REQ_F_ISREG to prevent that. Cc: Christian Brauner <brauner@kernel.org> Cc: stable@vger.kernel.org Link: ghostty-org/ghostty#7720 Fixes: cfd86ef ("anon_inode: use a proper mode internally") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c7d15ba commit 3ff0a89

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

io_uring/io_uring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,11 +1647,12 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags)
16471647

16481648
io_req_flags_t io_file_get_flags(struct file *file)
16491649
{
1650+
struct inode *inode = file_inode(file);
16501651
io_req_flags_t res = 0;
16511652

16521653
BUILD_BUG_ON(REQ_F_ISREG_BIT != REQ_F_SUPPORT_NOWAIT_BIT + 1);
16531654

1654-
if (S_ISREG(file_inode(file)->i_mode))
1655+
if (S_ISREG(inode->i_mode) && !(inode->i_flags & S_ANON_INODE))
16551656
res |= REQ_F_ISREG;
16561657
if ((file->f_flags & O_NONBLOCK) || (file->f_mode & FMODE_NOWAIT))
16571658
res |= REQ_F_SUPPORT_NOWAIT;

0 commit comments

Comments
 (0)