All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reject too-large filesystems on 32-bit kernels
@ 2009-08-12 22:06 Eric Sandeen
  2009-08-12 22:30 ` [PATCH V2] " Eric Sandeen
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-08-12 22:06 UTC (permalink / raw)
  To: ext4 development

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;
 	}
 


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

* [PATCH V2] reject too-large filesystems on 32-bit kernels
  2009-08-12 22:06 [PATCH] reject too-large filesystems on 32-bit kernels Eric Sandeen
@ 2009-08-12 22:30 ` Eric Sandeen
  2009-08-18  3:47   ` Theodore Tso
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-08-12 22:30 UTC (permalink / raw)
  To: ext4 development

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 (232 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>
---

V2: Get error sign right, too much userspace today :)

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;
 	}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH V2] reject too-large filesystems on 32-bit kernels
  2009-08-12 22:30 ` [PATCH V2] " Eric Sandeen
@ 2009-08-18  3:47   ` Theodore Tso
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Tso @ 2009-08-18  3:47 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development

On Wed, Aug 12, 2009 at 05:30:23PM -0500, Eric Sandeen wrote:
> 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 (232 index * 4k pages).

Applied in the ext4 patch queue, with minor changes to take into
account the use of ext4_msg().

					- Ted

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

end of thread, other threads:[~2009-08-18  3:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-12 22:06 [PATCH] reject too-large filesystems on 32-bit kernels Eric Sandeen
2009-08-12 22:30 ` [PATCH V2] " Eric Sandeen
2009-08-18  3:47   ` Theodore Tso

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.