linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH] reject too-large filesystems on 32-bit kernels
Date: Wed, 12 Aug 2009 17:06:37 -0500	[thread overview]
Message-ID: <4A833CED.2010708@redhat.com> (raw)

ext4 will happily mount a > 16T filesystem on a 32-bit box, but
this is not safe; writes to the block device will wrap past 16T
and the page cache can't index past 16T (2^32 index * 4k pages).

Adding another test to the existing "too many sectors" test
should do the trick.

Add a comment, a relevant return value, and fix the reference
to the CONFIG_LBD(AF) option as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

Index: linux-2.6.29.noarch/fs/ext4/super.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/super.c
+++ linux-2.6.29.noarch/fs/ext4/super.c
@@ -2274,13 +2274,20 @@ static int ext4_fill_super(struct super_
 		goto failed_mount;
 	}
 
+	/*
+	 * Test whether we have more sectors than will fit in sector_t,
+	 * and whether the max offset is addressable by the page cache.
+	 */
 	if (ext4_blocks_count(es) >
-		    (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
+		    (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9) ||
+	    ext4_blocks_count(es) >
+		    (pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - sb->s_blocksize_bits)) {
 		printk(KERN_ERR "EXT4-fs: filesystem on %s:"
-			" too large to mount safely\n", sb->s_id);
+			" too large to mount safely on this system\n", sb->s_id);
 		if (sizeof(sector_t) < 8)
-			printk(KERN_WARNING "EXT4-fs: CONFIG_LBD not "
+			printk(KERN_WARNING "EXT4-fs: CONFIG_LBDAF not "
 					"enabled\n");
+		ret = EFBIG;
 		goto failed_mount;
 	}
 


             reply	other threads:[~2009-08-12 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-12 22:06 Eric Sandeen [this message]
2009-08-12 22:30 ` [PATCH V2] reject too-large filesystems on 32-bit kernels Eric Sandeen
2009-08-18  3:47   ` Theodore Tso

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=4A833CED.2010708@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /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).