mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
fs: check FMODE_LSEEK to control internal pipe splicing
[ Upstream commit97ef77c52b
] 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:b92ce55893
("[PATCH] splice: add direct fd <-> fd splicing support") Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6c4e435b8d
commit
48cca38787
1 changed files with 4 additions and 6 deletions
10
fs/splice.c
10
fs/splice.c
|
@ -898,17 +898,15 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *pipe;
|
struct pipe_inode_info *pipe;
|
||||||
long ret, bytes;
|
long ret, bytes;
|
||||||
umode_t i_mode;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
int i, flags, more;
|
int i, flags, more;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We require the input being a regular file, as we don't want to
|
* We require the input to be seekable, as we don't want to randomly
|
||||||
* randomly drop data for eg socket -> socket splicing. Use the
|
* drop data for eg socket -> socket splicing. Use the piped splicing
|
||||||
* piped splicing for that!
|
* for that!
|
||||||
*/
|
*/
|
||||||
i_mode = file_inode(in)->i_mode;
|
if (unlikely(!(in->f_mode & FMODE_LSEEK)))
|
||||||
if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue