public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] nfs: don't assume fscache_acquire_cookie will always succeed
@ 2010-01-20 12:21 Suresh Jayaraman
  2010-01-20 21:35 ` Trond Myklebust
  2010-01-21 11:07 ` David Howells
  0 siblings, 2 replies; 6+ messages in thread
From: Suresh Jayaraman @ 2010-01-20 12:21 UTC (permalink / raw)
  To: trond.myklebust, David Howells; +Cc: Linux NFS mailing list

We seem to be assuming fscache_acquire_cookie will always succeed and will
obtain a valid cookie. But, under low memory conditions kmem_cache_alloc
could fail and that would leave nfsi->fscache being set to NULL.

This could lead to a possibility of a page with PG_fscache flag set but
cookie not set(i.e. NULL). This inconsistency could trigger a kernel BUG in
nfs_fscache_release_page() and other places as we do BUG_ON(!cookie), I think.

I'm aware that there are other places where we would need such checks, but
wanted to validate this patch before getting on to them.

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---

 fs/nfs/client.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index ee77713..7776e8a 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -155,6 +155,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
 		clp->cl_machine_cred = cred;
 
 	nfs_fscache_get_client_cookie(clp);
+	if (!clp->fscache)
+		goto error_cleanup;
 
 	return clp;
 
-- 
Suresh Jayaraman

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

end of thread, other threads:[~2010-01-23  3:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-20 12:21 [RFC][PATCH] nfs: don't assume fscache_acquire_cookie will always succeed Suresh Jayaraman
2010-01-20 21:35 ` Trond Myklebust
2010-01-21 11:07 ` David Howells
2010-01-21 11:41   ` Suresh Jayaraman
2010-01-22 12:52   ` Suresh Jayaraman
2010-01-23  3:48     ` David Howells

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