linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed
@ 2011-09-30 19:40 Darrick J. Wong
  2011-09-30 21:38 ` Ted Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2011-09-30 19:40 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

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

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;

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

* Re: [PATCH] e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed
  2011-09-30 19:40 [PATCH] e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed Darrick J. Wong
@ 2011-09-30 21:38 ` Ted Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2011-09-30 21:38 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

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

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

end of thread, other threads:[~2011-09-30 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30 19:40 [PATCH] e2fsck: When restarting fsck on account of MMP, zero ctx->fs after fs is freed Darrick J. Wong
2011-09-30 21:38 ` Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).