linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, hch@infradead.org, rlove@google.com,
	msb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org
Subject: [PATCH 3/4] vfs: change sb->s_maxbytes to a loff_t
Date: Fri,  7 Aug 2009 14:57:40 -0400	[thread overview]
Message-ID: <1249671461-9071-4-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1249671461-9071-1-git-send-email-jlayton@redhat.com>

sb->s_maxbytes is supposed to indicate the maximum size of a file that
can exist on the filesystem. It's declared as an unsigned long long.

Even if a filesystem has no inherent limit that prevents it from using
every bit in that unsigned long long, it's still problematic to set it
to anything larger than MAX_LFS_FILESIZE. A lot of places implicitly
cast s_maxbytes to a signed value when doing comparisons against it
(usually using loff_t on the other side of the comparison). If it's
set too large then this cast makes it a negative number and generally
breaks the comparison.

Change s_maxbytes to be loff_t instead. That should help eliminate the
temptation to set it too large by making it a signed value.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/super.c         |   10 ++++++++++
 include/linux/fs.h |    2 +-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 2761d3e..929d55d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -889,6 +889,16 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
  	if (error)
  		goto out_sb;
 
+	/*
+	 * filesystems should never set s_maxbytes larger than MAX_LFS_FILESIZE
+	 * but s_maxbytes was an unsigned long long for many releases. Throw
+	 * this warning for a little while to try and catch filesystems that
+	 * violate this rule. This warning can be removed in 2.6.34.
+	 */
+	WARN(((unsigned long long) mnt->mnt_sb->s_maxbytes > MAX_LFS_FILESIZE),
+		"WARNING: %s sets sb->s_maxbytes too large (%llu)", type->name,
+		(unsigned long long) mnt->mnt_sb->s_maxbytes);
+
 	mnt->mnt_mountpoint = mnt->mnt_root;
 	mnt->mnt_parent = mnt;
 	up_write(&mnt->mnt_sb->s_umount);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a36ffa5..25d9743 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1316,7 +1316,7 @@ struct super_block {
 	unsigned long		s_blocksize;
 	unsigned char		s_blocksize_bits;
 	unsigned char		s_dirt;
-	unsigned long long	s_maxbytes;	/* Max file size */
+	loff_t			s_maxbytes;	/* Max file size */
 	struct file_system_type	*s_type;
 	const struct super_operations	*s_op;
 	struct dquot_operations	*dq_op;
-- 
1.6.0.6


  parent reply	other threads:[~2009-08-07 18:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07 18:57 [PATCH 0/4] vfs: change sb->s_maxbytes to loff_t Jeff Layton
2009-08-07 18:57 ` [PATCH 1/4] vfs: make get_sb_pseudo set s_maxbytes to value that can be cast to signed Jeff Layton
2009-08-07 22:28   ` Johannes Weiner
2009-08-07 18:57 ` [PATCH 2/4] vfs: explicitly cast s_maxbytes in fiemap_check_ranges Jeff Layton
2009-08-07 22:12   ` Johannes Weiner
2009-08-08 11:20     ` Jeff Layton
2009-08-07 18:57 ` Jeff Layton [this message]
2009-08-07 20:14   ` [PATCH 3/4] vfs: change sb->s_maxbytes to a loff_t Andreas Dilger
2009-08-07 22:51   ` Johannes Weiner
2009-08-08 11:15     ` Jeff Layton
2009-08-07 18:57 ` [PATCH 4/4] vfs: remove redundant checks in do_sendfile Jeff Layton
2009-08-07 20:58   ` Mandeep Singh Baines
2009-08-07 21:05     ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249671461-9071-4-git-send-email-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msb@google.com \
    --cc=rlove@google.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).