splice: check f_mode for seekable file
PATCH 1/3 splice: check f_mode for seekable file
check f_mode for seekable file
As a seekable file is allowed without a llseek function, so the old way isn't work any more.
Signed-off-by Changli Gao <[email protected]>
----
fs/splice.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/splice.c +2 -4
@@ -1321,8 +1321,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,if (off_in)return -ESPIPE ;if (off_out) { -if (!out->f_op || !out->f_op->llseek || - out->f_op->llseek == no_llseek) +if (!(out->f_mode &FMODE_PWRITE ))return -EINVAL ;if (copy_from_user (&offset, off_out,sizeof (loff_t)))return -EFAULT ;
@@ -1342,8 +1341,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,if (off_out)return -ESPIPE ;if (off_in) { -if (!in->f_op || !in->f_op->llseek || - in->f_op->llseek == no_llseek) +if (!(in->f_mode &FMODE_PREAD ))return -EINVAL ;if (copy_from_user (&offset, off_in,sizeof (loff_t)))return -EFAULT ;
Quoted 6 lines · Changli Gao
check
f_modefor seekable fileAs a seekable file is allowed without a llseek function, so the old way isn't work any more.
Signed-off-by Changli Gao <[email protected]>
Looks good.
Acked-by Miklos Szeredi <[email protected]>
BTW, you should send splice patches to Jens Axboe, he's the maintainer of the splice code.
Miklos
Quoted 32 lines
----
fs/splice.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/splice.c +2
-5@@ -1321,8 +1321,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,if (off_in)return -ESPIPE ;if (off_out) { -if (!out->f_op || !out->f_op->llseek || - out->f_op->llseek == no_llseek) +if (!(out->f_mode &FMODE_PWRITE ))return -EINVAL ;if (copy_from_user (&offset, off_out,sizeof (loff_t)))return -EFAULT ;@@ -1342,8 +1341,7 @@ static long do_splice(struct file *in, loff_t __user *off_in,if (off_out)return -ESPIPE ;if (off_in) { -if (!in->f_op || !in->f_op->llseek || - in->f_op->llseek == no_llseek) +if (!(in->f_mode &FMODE_PREAD ))return -EINVAL ;if (copy_from_user (&offset, off_in,sizeof (loff_t)))return -EFAULT ; --To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html