Skip to contentSkip to conversation

mke2fs: don't accept too-high revision levels

PATCH In review Eric Sandeen 3 participants 7 messages May 1, 2014 – Jan 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mke2fs: don't accept too-high revision levels

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.

---

misc/mke2fs.c +3 -2
index aecd5d5..82019dc 100644
@@ -1679,9 +1679,10 @@ profile_error:
 			break;
 		case 'r':
 			r_opt = strtoul(optarg, &tmp, 0);
-			if (*tmp) {
+			if (*tmp || (r_opt > EXT2_MAX_SUPP_REV)) {
 				com_err(program_name, 0,
-					_("bad revision level - %s"), optarg);
+					_("bad revision level - %s (max %d)"),
+					   optarg, EXT2_MAX_SUPP_REV);
 				exit(1);
 			}
 			fs_param.s_rev_level = r_opt;
#1 lore raw

PATCH v2 1/1 mke2fs: prevent creation of filesystem with unsupported revision

From: Frank Sorenson <[email protected]>

Don't create a filesystem with an unsupported revision number

---

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

misc/mke2fs.c +5 -0
@@ -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 */
#2 lore raw

Re: [PATCH V2] mke2fs: prevent creation of filesystem with unsupported revision

Quoted 3 lines · Eric Sandeen

From: Frank Sorenson <[email protected]>

Don't create a filesystem with an unsupported revision number

I like the commit comment on the original patch better...

Cheers, Andreas

Quoted 22 lines

---

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

misc/mke2fs.c +5 -1
@@ -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 */
--
Quoted 3 lines

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

Cheers, Andreas

#3 lore raw

PATCH v3 1/1 mke2fs: prevent creation of filesystem with unsupported revision

In reply to Eric Sandeen

From: Frank Sorenson <[email protected]>

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.

[[email protected]: Add more verbose commit log]

---

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 :)

misc/mke2fs.c +5 -0
@@ -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 */
#4 lore raw

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

Quoted 10 lines · Eric Sandeen

From: Frank Sorenson <[email protected]>

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.

Quoted 5 lines

Just reject anything > EXT2_MAX_SUPP_REV at mkfs time.

[[email protected]: Add more verbose commit log]

Thanks, applied.

- Ted

#5 lore raw
In reply to Eric Sandeen

Came across this, still not merged, so ping?

Quoted 36 lines · Eric Sandeen

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.

---

misc/mke2fs.c +3 -3
index aecd5d5..82019dc 100644
@@ -1679,9 +1679,10 @@ profile_error:
 			break;
 		case 'r':
 			r_opt = strtoul(optarg, &tmp, 0);
-			if (*tmp) {
+			if (*tmp || (r_opt > EXT2_MAX_SUPP_REV)) {
 				com_err(program_name, 0,
-					_("bad revision level - %s"), optarg);
+					_("bad revision level - %s (max %d)"),
+					   optarg, EXT2_MAX_SUPP_REV);
 				exit(1);
 			}
 			fs_param.s_rev_level = r_opt;
 
--

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

Reviewed-by
#6 lore raw
Quoted 17 lines · Eric Sandeen

Came across this, still not merged, so ping?

Quoted 11 lines · Eric Sandeen

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.

Quoted 20 lines
Quoted 20 lines

---

misc/mke2fs.c +3 -2
index aecd5d5..82019dc 100644
@@ -1679,9 +1679,10 @@ profile_error:
 			break;
 		case 'r':
 			r_opt = strtoul(optarg, &tmp, 0);
-			if (*tmp) {
+			if (*tmp || (r_opt > EXT2_MAX_SUPP_REV)) {
 				com_err(program_name, 0,
-					_("bad revision level - %s"), optarg);
+					_("bad revision level - %s (max %d)"),
+					   optarg, EXT2_MAX_SUPP_REV);
 				exit(1);
 			}
 			fs_param.s_rev_level = r_opt;
Quoted 10 lines
Quoted 5 lines

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

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

Cheers, Andreas