lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 21 Apr 2008 15:24:08 +0530
From:	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
To:	Christoph Hellwig <hch@...radead.org>
Cc:	Mingming Cao <cmm@...ibm.com>,
	James Bottomley <James.Bottomley@...senPartnership.com>,
	linux-fsdevel@...r.kernel.org, Duane Griffin <duaneg@...da.com>,
	linux-ext4 <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] fix up thinko in jbd2 revoke code

On Thu, Apr 03, 2008 at 12:17:27PM -0400, Christoph Hellwig wrote:
> On Mon, Mar 31, 2008 at 11:30:58AM -0700, Mingming Cao wrote:
> > On Mon, 2008-03-31 at 10:57 -0500, James Bottomley wrote:
> > > This commit:
> > > 
> > > commit e898f3154d78d1520265aade0992981866d827fb
> > > Author: Duane Griffin <duaneg@...da.com>
> > > Date:   Tue Mar 25 19:47:39 2008 -0400
> > > 
> > >     jbd2: tidy up revoke cache initialisation and destruction
> > > 
> > > Introduced a thinko (it doesn't check whether jbd2_revoke_record cache
> > > is null, it checks jbd2_revoke_table_cache twice).
> > > 
> > > Signed-off-by: James Bottomley <James.Bottomley@...senPartnership.com>
> > > 
> > Signed-off-by: Mingming Cao <cmm@...ibm.com>
> > 
> > Thanks, I picked this up in ext4 patch queue.
> 
> anyone care to convert this function to proper goto-based error
> unwinding?

Like below. ?

Mingming,

I folded jbd2-tidy-up-revoe-cache-intialisation-and-destruction.patch
jbd2-fix-up-thinko-in-jbd2-revoke-code.patch in the patch queue to 
this.

-aneesh


jbd2: tidy up revoke cache initialisation and destruction

From: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>

Make revocation cache destruction safe to call if initialisation fails
partially or entirely.  This allows it to be used to cleanup in the case of
initialisation failure, simplifying the code slightly.

Signed-off-by: Duane Griffin <duaneg@...da.com>
Signed-off-by: Mingming Cao <cmm@...ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---

 fs/jbd2/revoke.c |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)


diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 2e1453a..72b2608 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -167,33 +167,41 @@ static struct jbd2_revoke_record_s *find_revoke_record(journal_t *journal,
 	return NULL;
 }
 
+void jbd2_journal_destroy_revoke_caches(void)
+{
+	if (jbd2_revoke_record_cache) {
+		kmem_cache_destroy(jbd2_revoke_record_cache);
+		jbd2_revoke_record_cache = NULL;
+	}
+	if (jbd2_revoke_table_cache) {
+		kmem_cache_destroy(jbd2_revoke_table_cache);
+		jbd2_revoke_table_cache = NULL;
+	}
+}
+
 int __init jbd2_journal_init_revoke_caches(void)
 {
+	J_ASSERT(!jbd2_revoke_record_cache);
+	J_ASSERT(!jbd2_revoke_table_cache);
+
 	jbd2_revoke_record_cache = kmem_cache_create("jbd2_revoke_record",
 					   sizeof(struct jbd2_revoke_record_s),
 					   0,
 					   SLAB_HWCACHE_ALIGN|SLAB_TEMPORARY,
 					   NULL);
 	if (!jbd2_revoke_record_cache)
-		return -ENOMEM;
+		goto record_cache_failure;
 
 	jbd2_revoke_table_cache = kmem_cache_create("jbd2_revoke_table",
 					   sizeof(struct jbd2_revoke_table_s),
 					   0, SLAB_TEMPORARY, NULL);
-	if (!jbd2_revoke_table_cache) {
-		kmem_cache_destroy(jbd2_revoke_record_cache);
-		jbd2_revoke_record_cache = NULL;
-		return -ENOMEM;
-	}
+	if (!jbd2_revoke_table_cache)
+		goto table_cache_failure;
 	return 0;
-}
-
-void jbd2_journal_destroy_revoke_caches(void)
-{
-	kmem_cache_destroy(jbd2_revoke_record_cache);
-	jbd2_revoke_record_cache = NULL;
-	kmem_cache_destroy(jbd2_revoke_table_cache);
-	jbd2_revoke_table_cache = NULL;
+table_cache_failure:
+	jbd2_journal_destroy_revoke_caches();
+record_cache_failure:
+		return -ENOMEM;
 }
 
 /* Initialise the revoke table for a given journal to a given size. */
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ