Patchwork [V3] mke2fs: prevent creation of filesystem with unsupported revision

login
register
mail settings
Submitter Eric Sandeen
Date May 1, 2014, 10:35 p.m.
Message ID <5362CC14.2070902@redhat.com>
Download mbox | patch
Permalink /patch/344825/
State Accepted
Headers show

Comments

Eric Sandeen - May 1, 2014, 10:35 p.m.
From: Frank Sorenson <fsorenso@redhat.com>

It's a bit strange to accept revision levels higher than
the code creating the filesystem can understand, so don't
allow it.

At least the kernel will mount the fs readonly if it's too
high, but no other utility will touch it, so you can't
fix the error.

Just reject anything > EXT2_MAX_SUPP_REV at mkfs time.

Signed-off-by: Frank Sorenson <fsorenso@redhat.com>
[sandeen@redhat.com: Add more verbose commit log]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: Frank did this independently, and it's better.  I forgot about
using com_err here.

V3: go back to V1's commit log for Andreas :)


--
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
Theodore Ts'o - July 4, 2014, 7:32 p.m.
On Thu, May 01, 2014 at 05:35:00PM -0500, Eric Sandeen wrote:
> From: Frank Sorenson <fsorenso@redhat.com>
> 
> It's a bit strange to accept revision levels higher than
> the code creating the filesystem can understand, so don't
> allow it.
> 
> At least the kernel will mount the fs readonly if it's too
> high, but no other utility will touch it, so you can't
> fix the error.
> 
> Just reject anything > EXT2_MAX_SUPP_REV at mkfs time.
> 
> Signed-off-by: Frank Sorenson <fsorenso@redhat.com>
> [sandeen@redhat.com: Add more verbose commit log]
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Thanks, applied.

					- Ted
--
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

Patch

--- a/misc/mke2fs.c	
+++ a/misc/mke2fs.c	
@@ -1684,6 +1684,11 @@  profile_error:
 					_("bad revision level - %s"), optarg);
 				exit(1);
 			}
+			if (r_opt > EXT2_MAX_SUPP_REV) {
+				com_err(program_name, EXT2_ET_REV_TOO_HIGH,
+					_("while trying to create revision %d"), r_opt);
+				exit(1);
+			}
 			fs_param.s_rev_level = r_opt;
 			break;
 		case 's':	/* deprecated */