mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] small sendfile fixes
@ 2009-06-22 18:15 Robert Love
  2009-06-22 19:04 ` Robert Love
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Love @ 2009-06-22 18:15 UTC (permalink / raw)
  To: lkml, Al Viro

Three fixes for sendfile, mostly related to sending large files from pseudo
filesystems:

- Fix sendfile for offsets > 300G. This can happen with pseudo filesystems.
  This happens because the overflow check is using inode->i_sb->s_maxbytes
  and not the superblock of the backing device's s_maxbytes. For a regular file
  these are interchangible but for a special file these are different and you
  want the latter.

- Don't compare against the max of the out_inode's superblock. Doesn't make
  sense.

- For pseudo and other filesystems with s_maxbytes set to ~0ULL, max ends up
  holding a negative number as it is signed. Check for and correct that.

Git patch is against 2.6.30. I'd like Al to take a look and make sure
my logic is right before applying.

        Robert

From: Mandeep Singh Baines <msb@google.com>
Signed-off-by: Robert Love <rlove@google.com>

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

* Re: [patch] small sendfile fixes
  2009-06-22 18:15 [patch] small sendfile fixes Robert Love
@ 2009-06-22 19:04 ` Robert Love
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2009-06-22 19:04 UTC (permalink / raw)
  To: lkml, Al Viro

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

And...the actual patch.

      Robert

[-- Attachment #2: sendfile-fix-2.6.30-rlove-1.patch --]
[-- Type: application/octet-stream, Size: 1723 bytes --]

From e588b75745a524e41aca72580a9173d0607c8ba0 Mon Sep 17 00:00:00 2001
From: Robert Love <rlove@dhcp-172-31-205-236.cam.corp.google.com>
Date: Thu, 18 Jun 2009 14:42:11 -0400
Subject: [PATCH] three fixes for sendfile

Three fixes for sendfile, mostly related to sending large files from pseudo
filesystems:

- Fix sendfile for offsets > 300G. This can happen with pseudo filesystems.
  This happens because the overflow check is using inode->i_sb->s_maxbytes
  and not the superblock of the backing device's s_maxbytes. For a regular file
  these are interchangible but for a special file these are different and you
  want the latter.

- Don't compare against the max of the out_inode's superblock. Doesn't make
  sense.

- For pseudo and other filesystems with s_maxbytes set to ~0ULL, max ends up
  holding a negative number as it is signed. Check for and correct that.

Patch is against 2.6.30.

	Robert

From: Mandeep Singh Baines <msb@google.com>
Signed-off-by: Robert Love <rlove@google.com>

---
 fs/read_write.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 6c8c55d..b586763 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -835,8 +835,15 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
 		goto fput_out;
 	count = retval;
 
-	if (!max)
-		max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
+	if (!max) {
+		max = in_inode->i_mapping->host->i_sb->s_maxbytes;
+		/*
+		 * For psuedo filesystems, s_maxbytes is ~0ULL. When converted
+		 * to loff_t, it can go negative. So we check for and fix that.
+		 */
+		if (max < 0)
+			max = LLONG_MAX;
+	}
 
 	pos = *ppos;
 	retval = -EINVAL;
-- 
1.6.2.2


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

end of thread, other threads:[~2009-06-22 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-22 18:15 [patch] small sendfile fixes Robert Love
2009-06-22 19:04 ` Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®