fs: check FMODE_LSEEK to control internal pipe splicing
[linux-block.git] / fs / splice.c
index 047b79db8eb52e05f39af3977fb328a0250212d7..93a2c9bf624941af7791ab2c58871e855913ba6e 100644 (file)
@@ -814,17 +814,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;
 
        /*