From cd118432cc937e9c1ec040c53860f9d687e34167 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 20 Jan 2004 03:13:47 -0800 Subject: [PATCH] [PATCH] sendfile calls lock_verify_area with wrong parameters From: Manfred Spraul sendfile supports reading from a given start offset for in_file, like pread. But for the locks_verify_area call, in_file->f_pos is always used, even if a start offset is used. Result: wrong area is checked for mandatory locks. --- fs/read_write.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index a3cc592ff8538..3fe9b8732601b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -559,7 +559,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, goto fput_in; if (!in_file->f_op || !in_file->f_op->sendfile) goto fput_in; - retval = locks_verify_area(FLOCK_VERIFY_READ, in_inode, in_file, in_file->f_pos, count); + if (!ppos) + ppos = &in_file->f_pos; + retval = locks_verify_area(FLOCK_VERIFY_READ, in_inode, in_file, *ppos, count); if (retval) goto fput_in; @@ -588,9 +590,6 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, if (retval) goto fput_out; - if (!ppos) - ppos = &in_file->f_pos; - if (!max) max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes); -- 2.53.0