Patchwork e2fsck: don't try to stop mmp if there is no superblock set up

login
register
mail settings
Submitter Eric Sandeen
Date Aug. 16, 2013, 5:05 p.m.
Message ID <520E5BF3.5090502@redhat.com>
Download mbox | patch
Permalink /patch/267712/
State Accepted
Headers show

Comments

Eric Sandeen - Aug. 16, 2013, 5:05 p.m.
Under some failure cases, we can get to fatal_error()
without even having a superblock set up.  In that case,
ext2fs_mmp_stop() will segfault when it tries to dereference
fs->super.

Check for the existence of a superblock before we go
down the ext2fs_mmp_stop() path to avoid this problem.

Reported-by: Hubert Kario <hkario@redhat.com>
Addresses-Red-Hat-Bugzilla: #997972
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

--
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 - Sept. 9, 2013, 2:33 p.m.
On Fri, Aug 16, 2013 at 12:05:55PM -0500, Eric Sandeen wrote:
> Under some failure cases, we can get to fatal_error()
> without even having a superblock set up.  In that case,
> ext2fs_mmp_stop() will segfault when it tries to dereference
> fs->super.
> 
> Check for the existence of a superblock before we go
> down the ext2fs_mmp_stop() path to avoid this problem.
> 
> Reported-by: Hubert Kario <hkario@redhat.com>
> Addresses-Red-Hat-Bugzilla: #997972
> 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

diff --git a/e2fsck/util.c b/e2fsck/util.c
index 9eaf557..18005f4 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -55,7 +55,7 @@  void fatal_error(e2fsck_t ctx, const char *msg)
 		fprintf (stderr, "e2fsck: %s\n", msg);
 	if (!fs)
 		goto out;
-	if (fs->io) {
+	if (fs->io && fs->super) {
 		ext2fs_mmp_stop(ctx->fs);
 		if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
 			io_channel_flush(ctx->fs->io);