diff mbox

e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed

Message ID 20110930194005.GT12086@tux1.beaverton.ibm.com
State Accepted, archived
Headers show

Commit Message

Darrick J. Wong Sept. 30, 2011, 7:40 p.m. UTC
If MMP is enabled and e2fsck determines that it needs to restart itself on
account of various MMP conditions, it will close the current fs and jump back
to the start of fs checking.  However, closing fs also frees it, which means
that we need to set ctx->fs to NULL to prevent subsequent open code from
accessing the old deleted pointer.

(This fix came up while testing the metadata checksumming patchset)

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 e2fsck/unix.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

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

Comments

Theodore Ts'o Sept. 30, 2011, 9:38 p.m. UTC | #1
On Fri, Sep 30, 2011 at 12:40:05PM -0700, Darrick J. Wong wrote:
> If MMP is enabled and e2fsck determines that it needs to restart itself on
> account of various MMP conditions, it will close the current fs and jump back
> to the start of fs checking.  However, closing fs also frees it, which means
> that we need to set ctx->fs to NULL to prevent subsequent open code from
> accessing the old deleted pointer.
> 
> (This fix came up while testing the metadata checksumming patchset)
> 
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.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
diff mbox

Patch

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index f980962..37cfb00 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1351,6 +1351,7 @@  failure:
 	  * Restart in order to reopen fs but this time start mmp.
 	  */
 	if (flags & EXT2_FLAG_SKIP_MMP) {
+		ctx->fs = NULL;
 		ext2fs_close(fs);
 		flags &= ~EXT2_FLAG_SKIP_MMP;
 		goto restart;