Skip to contentSkip to conversation

apparmor: fix error code in aafs_create()

PATCH In review Dan Carpenter 2 participants 2 messages Jun 14, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apparmor: fix error code in aafs_create()

We accidentally return ERR_PTR(0) if lookup_one_len() fails. The caller is expecting error pointers so it likely causes problems later on. For example, on one path I saw it triggered an AA_BUG().

Fixes a481f4d91783 ("apparmor: add custom apparmorfs that will be used by policy namespace files")
security/apparmor/apparmorfs.c +3 -1
index 853c2ec8e0c9..2caeb748070c 100644
@@ -248,8 +248,10 @@ static struct dentry *aafs_create(const char *name, umode_t mode,
 
 	inode_lock(dir);
 	dentry = lookup_one_len(name, parent, strlen(name));
-	if (IS_ERR(dentry))
+	if (IS_ERR(dentry)) {
+		error = PTR_ERR(dentry);
 		goto fail_lock;
+	}
 
 	if (d_really_is_positive(dentry)) {
 		error = -EEXIST;
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

We accidentally return ERR_PTR(0) if lookup_one_len() fails. The caller is expecting error pointers so it likely causes problems later on. For example, on one path I saw it triggered an AA_BUG().

Fixes a481f4d91783 ("apparmor: add custom apparmorfs that will be used by policy namespace files")

I'll pull this in and forward it up to James along with a couple of other bug fixes

thanks

Quoted 18 lines
security/apparmor/apparmorfs.c +3 -1
index 853c2ec8e0c9..2caeb748070c 100644
@@ -248,8 +248,10 @@ static struct dentry *aafs_create(const char *name, umode_t mode,
 
 	inode_lock(dir);
 	dentry = lookup_one_len(name, parent, strlen(name));
-	if (IS_ERR(dentry))
+	if (IS_ERR(dentry)) {
+		error = PTR_ERR(dentry);
 		goto fail_lock;
+	}
 
 	if (d_really_is_positive(dentry)) {
 		error = -EEXIST;