linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CacheFiles: Fix error handling in cachefiles_determine_cache_security()
@ 2010-05-12 14:34 David Howells
  2010-05-12 19:36 ` Andrew Morton
  2010-05-13  9:51 ` David Howells
  0 siblings, 2 replies; 3+ messages in thread
From: David Howells @ 2010-05-12 14:34 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: dhowells, linux-cachefs, linux-kernel

cachefiles_determine_cache_security() is expected to return with a security
override in place.  However, if set_create_files_as() fails, we fail to do
this.  In this case, we should just reinstate the security override that was
set by the caller.

Furthermore, if set_create_files_as() fails, we should dispose of the new
credentials we were in the process of creating.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/cachefiles/security.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/cachefiles/security.c b/fs/cachefiles/security.c
index b5808cd..039b501 100644
--- a/fs/cachefiles/security.c
+++ b/fs/cachefiles/security.c
@@ -77,6 +77,8 @@ static int cachefiles_check_cache_dir(struct cachefiles_cache *cache,
 /*
  * check the security details of the on-disk cache
  * - must be called with security override in force
+ * - must return with a security override in force - even in the case of an
+ *   error
  */
 int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
 					struct dentry *root,
@@ -99,6 +101,8 @@ int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
 	 * which create files */
 	ret = set_create_files_as(new, root->d_inode);
 	if (ret < 0) {
+		abort_creds(new);
+		cachefiles_begin_secure(cache, _saved_cred);
 		_leave(" = %d [cfa]", ret);
 		return ret;
 	}


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

end of thread, other threads:[~2010-05-13  9:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12 14:34 [PATCH] CacheFiles: Fix error handling in cachefiles_determine_cache_security() David Howells
2010-05-12 19:36 ` Andrew Morton
2010-05-13  9:51 ` David Howells

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