summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-05-12 15:34:03 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-26 14:29:20 -0700
commit58e4a597dc9b8cd7ec28680a5b01c3f1718ca115 (patch)
tree07f6921a263ecf69eec6dd5f5448823e26603ac4
parent7bb08a1cac8ed8e4fda495bd907988bd4077b342 (diff)
downloadlwn-58e4a597dc9b8cd7ec28680a5b01c3f1718ca115.tar.gz
lwn-58e4a597dc9b8cd7ec28680a5b01c3f1718ca115.zip
CacheFiles: Fix error handling in cachefiles_determine_cache_security()
commit 7ac512aa8237c43331ffaf77a4fd8b8d684819ba upstream. 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--fs/cachefiles/security.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/cachefiles/security.c b/fs/cachefiles/security.c
index b5808cdb2232..039b5011d83b 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;
}