All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sendfile calls lock_verify_area with wrong parameters
@ 2004-01-18 12:37 Manfred Spraul
  2004-01-18 13:04 ` Manfred Spraul
  0 siblings, 1 reply; 2+ messages in thread
From: Manfred Spraul @ 2004-01-18 12:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

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.

Fix attached.

--
    Manfred

[-- Attachment #2: patch-locks-sendfile --]
[-- Type: text/plain, Size: 795 bytes --]

--- 2.6/fs/read_write.c	2004-01-17 12:19:38.000000000 +0100
+++ build-2.6/fs/read_write.c	2004-01-18 13:26:46.000000000 +0100
@@ -544,6 +544,8 @@
 	ssize_t retval;
 	int fput_needed_in, fput_needed_out;
 
+	if (!ppos)
+		ppos = &in_file->f_pos;
 	/*
 	 * Get input file, and verify that it is ok..
 	 */
@@ -559,7 +561,7 @@
 		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);
+	retval = locks_verify_area(FLOCK_VERIFY_READ, in_inode, in_file, *ppos, count);
 	if (retval)
 		goto fput_in;
 
@@ -588,9 +590,6 @@
 	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);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sendfile calls lock_verify_area with wrong parameters
  2004-01-18 12:37 [PATCH] sendfile calls lock_verify_area with wrong parameters Manfred Spraul
@ 2004-01-18 13:04 ` Manfred Spraul
  0 siblings, 0 replies; 2+ messages in thread
From: Manfred Spraul @ 2004-01-18 13:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

Manfred Spraul wrote:

>+	if (!ppos)
>+		ppos = &in_file->f_pos;
>  
>
Too early - in_file not yet initialized.

An updated (and tested with 2.6.1-mm4) patch is attached - sorry for the 
noise.

--
    Manfred

[-- Attachment #2: patch-locks-sendfile --]
[-- Type: text/plain, Size: 657 bytes --]

--- 2.6/fs/read_write.c	2004-01-17 12:19:38.000000000 +0100
+++ build-2.6/fs/read_write.c	2004-01-18 13:42:11.000000000 +0100
@@ -559,7 +559,9 @@
 		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 @@
 	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);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-18 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-18 12:37 [PATCH] sendfile calls lock_verify_area with wrong parameters Manfred Spraul
2004-01-18 13:04 ` Manfred Spraul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.