Patch "fs: check FMODE_LSEEK to control internal pipe splicing" has been added to the 4.19-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

    fs: check FMODE_LSEEK to control internal pipe splicing

to the 4.19-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:
     fs-check-fmode_lseek-to-control-internal-pipe-splici.patch
and it can be found in the queue-4.19 subdirectory.

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



commit 42eb7ea9b9b0285baaa106cba62df51bfda33647
Author: Jason A. Donenfeld <Jason@xxxxxxxxx>
Date:   Wed Jun 29 15:06:58 2022 +0200

    fs: check FMODE_LSEEK to control internal pipe splicing
    
    [ Upstream commit 97ef77c52b789ec1411d360ed99dca1efe4b2c81 ]
    
    The original direct splicing mechanism from Jens required the input to
    be a regular file because it was avoiding the special socket case. It
    also recognized blkdevs as being close enough to a regular file. But it
    forgot about chardevs, which behave the same way and work fine here.
    
    This is an okayish heuristic, but it doesn't totally work. For example,
    a few chardevs should be spliceable here. And a few regular files
    shouldn't. This patch fixes this by instead checking whether FMODE_LSEEK
    is set, which represents decently enough what we need rewinding for when
    splicing to internal pipes.
    
    Fixes: b92ce5589374 ("[PATCH] splice: add direct fd <-> fd splicing support")
    Cc: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
    Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/splice.c b/fs/splice.c
index fd28c7da3c83..ef1604e307f1 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -899,17 +899,15 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
 {
 	struct pipe_inode_info *pipe;
 	long ret, bytes;
-	umode_t i_mode;
 	size_t len;
 	int i, flags, more;
 
 	/*
-	 * We require the input being a regular file, as we don't want to
-	 * randomly drop data for eg socket -> socket splicing. Use the
-	 * piped splicing for that!
+	 * We require the input to be seekable, as we don't want to randomly
+	 * drop data for eg socket -> socket splicing. Use the piped splicing
+	 * for that!
 	 */
-	i_mode = file_inode(in)->i_mode;
-	if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
+	if (unlikely(!(in->f_mode & FMODE_LSEEK)))
 		return -EINVAL;
 
 	/*



[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