[PATCH] apparmor: fix error code in aafs_create()

Subsystems: apparmor security module, security subsystem, the rest

STALE3409d

2 messages, 2 authors, 2017-06-14 · open the first message on its own page

[PATCH] apparmor: fix error code in aafs_create()

From: Dan Carpenter <hidden>
Date: 2017-06-14 10:40:02

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")
Signed-off-by: Dan Carpenter <redacted>
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 853c2ec8e0c9..2caeb748070c 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH] apparmor: fix error code in aafs_create()

From: John Johansen <john.johansen@canonical.com>
Date: 2017-06-14 14:44:52

On 06/14/2017 03:40 AM, Dan Carpenter wrote:
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")
Signed-off-by: Dan Carpenter <redacted>
Acked-by: John Johansen <john.johansen@canonical.com>

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

thanks
quoted hunk
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 853c2ec8e0c9..2caeb748070c 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help