Linux NFS development
 help / color / mirror / Atom feed
* [patch 14/23] Fix race related problem when adding items to and svcrpc auth cache.
       [not found] ` <20060804053807.GA769@kroah.com>
@ 2006-08-04  5:39   ` Greg KH
  0 siblings, 0 replies; only message in thread
From: Greg KH @ 2006-08-04  5:39 UTC (permalink / raw)
  To: linux-kernel, stable, Philipp Matthias Hahn
  Cc: Justin Forbes, Zwane Mwaikambo, Theodore Ts'o, Randy Dunlap,
	Dave Jones, Chuck Wolber, Chris Wedgwood, torvalds, akpm, alan,
	nfs, Neil Brown, Greg Kroah-Hartman

-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Neil Brown <neilb@suse.de>

Fix race related problem when adding items to and svcrpc auth cache.

If we don't find the item we are lookng for, we allocate a new one,
and then grab the lock again and search to see if it has been added
while we did the alloc.
If it had been added we need to 'cache_put' the newly created item
that we are never going to use.  But as it hasn't been initialised
properly, putting it can cause an oops.

So move the ->init call earlier to that it will always be fully
initilised if we have to put it.

Thanks to Philipp Matthias Hahn <pmhahn@svs.Informatik.Uni-Oldenburg.de>
for reporting the problem.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


---
 net/sunrpc/cache.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- linux-2.6.17.7.orig/net/sunrpc/cache.c
+++ linux-2.6.17.7/net/sunrpc/cache.c
@@ -71,7 +71,12 @@ struct cache_head *sunrpc_cache_lookup(s
 	new = detail->alloc();
 	if (!new)
 		return NULL;
+	/* must fully initialise 'new', else
+	 * we might get lose if we need to
+	 * cache_put it soon.
+	 */
 	cache_init(new);
+	detail->init(new, key);
 
 	write_lock(&detail->hash_lock);
 
@@ -85,7 +90,6 @@ struct cache_head *sunrpc_cache_lookup(s
 			return tmp;
 		}
 	}
-	detail->init(new, key);
 	new->next = *head;
 	*head = new;
 	detail->entries++;

--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-08-04  5:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20060804053258.391158155@quad.kroah.org>
     [not found] ` <20060804053807.GA769@kroah.com>
2006-08-04  5:39   ` [patch 14/23] Fix race related problem when adding items to and svcrpc auth cache Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox