Skip to contentSkip to conversation

apparmor: fix odd_ptr_err.cocci warnings (fwd)

PATCH In review Julia Lawall 3 participants 4 messages Oct 24, 2019

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

PATCH 1/1 apparmor: fix odd_ptr_err.cocci warnings (fwd)

Hello,

The change suggested by Coccinelle is not correct, but the original code is not correct either because the argument to PTR_ERR should be a pointer, not an integer.

julia

---------- Forwarded message ----------
Date: Thu, 24 Oct 2019 18:21:57 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] apparmor: fix odd_ptr_err.cocci warnings

CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Navid Emamdoost <[email protected]>

From: kbuild test robot <[email protected]>

security/apparmor/audit.c:199:5-11: inconsistent IS_ERR and PTR_ERR on line 202.

PTR_ERR should access the value just tested by IS_ERR

Semantic patch information:
There can be false positives in the patch case, where it is the call to IS_ERR that is wrong.

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

Fixes 6f939f24599c ("apparmor: Fix use-after-free in aa_audit_rule_init")
CC Navid Emamdoost <[email protected]>

---

url:    https://github.com/0day-ci/linux/commits/Navid-Emamdoost/apparmor-Fix-use-after-free-in-aa_audit_rule_init/20191024-123239
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-testing

:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

Please take the patch only if it's a positive warning. Thanks!

 audit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/audit.c +1 -1
@@ -199,7 +199,7 @@ int aa_audit_rule_init(u32 field, u32 op
 	if (IS_ERR(rule->label)) {
 		int err = rule->label;
 		aa_audit_rule_free(rule);
-		return PTR_ERR(err);
+		return PTR_ERR(rule->label);
 	}
 
 	*vrule = rule;
#1 lore raw

Hello,

I added Tyler to this conversation.
I believe v3 of the patch addresses this issue:
https://lore.kernel.org/patchwork/patch/1142523/

Quoted 51 lines · Julia Lawall

Hello,

The change suggested by Coccinelle is not correct, but the original code is not correct either because the argument to PTR_ERR should be a pointer, not an integer.

julia

---------- Forwarded message ----------
Date: Thu, 24 Oct 2019 18:21:57 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] apparmor: fix odd_ptr_err.cocci warnings

CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Navid Emamdoost <[email protected]>

From: kbuild test robot <[email protected]>

security/apparmor/audit.c:199:5-11: inconsistent IS_ERR and PTR_ERR on line 202.

PTR_ERR should access the value just tested by IS_ERR

Semantic patch information:
There can be false positives in the patch case, where it is the call to IS_ERR that is wrong.

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

Fixes 6f939f24599c ("apparmor: Fix use-after-free in aa_audit_rule_init")
CC Navid Emamdoost <[email protected]>

---

url:    https://github.com/0day-ci/linux/commits/Navid-Emamdoost/apparmor-Fix-use-after-free-in-aa_audit_rule_init/20191024-123239
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-testing

:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

Please take the patch only if it's a positive warning. Thanks!

 audit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

security/apparmor/audit.c int aa_audit_rule_init(u32 field, u32 op · line 205

Quoted 8 lines
security/apparmor/audit.c +1 -1
@@ -199,7 +199,7 @@ int aa_audit_rule_init(u32 field, u32 op
        if (IS_ERR(rule->label)) {
                int err = rule->label;
                aa_audit_rule_free(rule);
-               return PTR_ERR(err);
+               return PTR_ERR(rule->label);
        }
 
        *vrule = rule;

--
Navid.

#2 lore raw
Quoted 5 lines · Navid Emamdoost

Hello,

I added Tyler to this conversation.
I believe v3 of the patch addresses this issue:
https://lore.kernel.org/patchwork/patch/1142523/

It looks ok like that, thanks.

Please don't top post.

julia

Quoted 68 lines · Julia Lawall
Quoted 51 lines

Hello,

The change suggested by Coccinelle is not correct, but the original code is not correct either because the argument to PTR_ERR should be a pointer, not an integer.

julia

---------- Forwarded message ----------
Date: Thu, 24 Oct 2019 18:21:57 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] apparmor: fix odd_ptr_err.cocci warnings

CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Navid Emamdoost <[email protected]>

From: kbuild test robot <[email protected]>

security/apparmor/audit.c:199:5-11: inconsistent IS_ERR and PTR_ERR on line 202.

PTR_ERR should access the value just tested by IS_ERR

Semantic patch information:
There can be false positives in the patch case, where it is the call to IS_ERR that is wrong.

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

Fixes 6f939f24599c ("apparmor: Fix use-after-free in aa_audit_rule_init")
CC Navid Emamdoost <[email protected]>

---

url:    https://github.com/0day-ci/linux/commits/Navid-Emamdoost/apparmor-Fix-use-after-free-in-aa_audit_rule_init/20191024-123239
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-testing

:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

Please take the patch only if it's a positive warning. Thanks!

 audit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

security/apparmor/audit.c int aa_audit_rule_init(u32 field, u32 op · line 205

Quoted 8 lines
security/apparmor/audit.c +1 -1
@@ -199,7 +199,7 @@ int aa_audit_rule_init(u32 field, u32 op
        if (IS_ERR(rule->label)) {
                int err = rule->label;
                aa_audit_rule_free(rule);
-               return PTR_ERR(err);
+               return PTR_ERR(rule->label);
        }
 
        *vrule = rule;

--
Navid.

#3 lore raw
In reply to Navid Emamdoost
Quoted 5 lines · Navid Emamdoost

Hello,

I added Tyler to this conversation.
I believe v3 of the patch addresses this issue:
https://lore.kernel.org/patchwork/patch/1142523/

Yes, I agree. v3 is the fix.

Tyler

Quoted 67 lines · Julia Lawall
Quoted 51 lines

Hello,

The change suggested by Coccinelle is not correct, but the original code is not correct either because the argument to PTR_ERR should be a pointer, not an integer.

julia

---------- Forwarded message ----------
Date: Thu, 24 Oct 2019 18:21:57 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] apparmor: fix odd_ptr_err.cocci warnings

CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Navid Emamdoost <[email protected]>

From: kbuild test robot <[email protected]>

security/apparmor/audit.c:199:5-11: inconsistent IS_ERR and PTR_ERR on line 202.

PTR_ERR should access the value just tested by IS_ERR

Semantic patch information:
There can be false positives in the patch case, where it is the call to IS_ERR that is wrong.

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

Fixes 6f939f24599c ("apparmor: Fix use-after-free in aa_audit_rule_init")
CC Navid Emamdoost <[email protected]>

---

url:    https://github.com/0day-ci/linux/commits/Navid-Emamdoost/apparmor-Fix-use-after-free-in-aa_audit_rule_init/20191024-123239
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-testing

:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

Please take the patch only if it's a positive warning. Thanks!

 audit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

security/apparmor/audit.c int aa_audit_rule_init(u32 field, u32 op · line 205

Quoted 8 lines
security/apparmor/audit.c +1 -1
@@ -199,7 +199,7 @@ int aa_audit_rule_init(u32 field, u32 op
        if (IS_ERR(rule->label)) {
                int err = rule->label;
                aa_audit_rule_free(rule);
-               return PTR_ERR(err);
+               return PTR_ERR(rule->label);
        }
 
        *vrule = rule;

--
Navid.