Skip to contentSkip to conversation

apparmor: fix incorrect success return value in unpack_tag_headers()

PATCH In review Massimiliano Pellizzer 2 participants 3 messages Feb 10 – Mar 19

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

PATCH 1/1 apparmor: fix incorrect success return value in unpack_tag_headers()

unpack_tag_headers() returns true (1) on success instead of 0. Since it's caller unpack_tags() checks the return value with if (error), a non-zero success value is incorrectly treated as a failure, causing tag header unpacking to always even if the data is well-formed.

Change the success return in unpack_tag_headers() from true to 0.

Fixes 3d28e2397af7 ("apparmor: add support loading per permission tagging")
---
 security/apparmor/policy_unpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
index dc908e1f5a88..221208788025 100644
@@ -825,7 +825,7 @@ static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags)
 	tags->hdrs.size = size;
 	tags->hdrs.table = hdrs;
 	AA_DEBUG(DEBUG_UNPACK, "headers %ld size %d", (long) hdrs, size);
-	return true;
+	return 0;
 
 fail:
 	kfree_sensitive(hdrs);
Signature · 1 line
2.51.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Massimiliano Pellizzer

unpack_tag_headers() returns true (1) on success instead of 0. Since it's caller unpack_tags() checks the return value with if (error), a non-zero success value is incorrectly treated as a failure, causing tag header unpacking to always even if the data is well-formed.

Change the success return in unpack_tag_headers() from true to 0.

Fixes 3d28e2397af7 ("apparmor: add support loading per permission tagging")

sorry, my reply to this seems to have failed. This was pulled in for the 7.0 PR

Quoted 17 lines
---
  security/apparmor/policy_unpack.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
index dc908e1f5a88..221208788025 100644
@@ -825,7 +825,7 @@ static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags)
  	tags->hdrs.size = size;
  	tags->hdrs.table = hdrs;
  	AA_DEBUG(DEBUG_UNPACK, "headers %ld size %d", (long) hdrs, size);
-	return true;
+	return 0;
 
  fail:
  	kfree_sensitive(hdrs);
#2 lore raw
Quoted 34 lines · John Johansen
Quoted 10 lines · Massimiliano Pellizzer

unpack_tag_headers() returns true (1) on success instead of 0. Since it's caller unpack_tags() checks the return value with if (error), a non-zero success value is incorrectly treated as a failure, causing tag header unpacking to always even if the data is well-formed.

Change the success return in unpack_tag_headers() from true to 0.

Fixes 3d28e2397af7 ("apparmor: add support loading per permission tagging")

sorry, my reply to this seems to have failed. This was pulled in for the 7.0 PR

Quoted 15 lines
---
  security/apparmor/policy_unpack.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
index dc908e1f5a88..221208788025 100644
@@ -825,7 +825,7 @@ static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags)
      tags->hdrs.size = size;
      tags->hdrs.table = hdrs;
      AA_DEBUG(DEBUG_UNPACK, "headers %ld size %d", (long) hdrs, size);
-     return true;
+     return 0;
 
Quoted 3 lines

security/apparmor/policy_unpack.c static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags) · line 831

Quoted 2 lines
security/apparmor/policy_unpack.c +0 -0
  fail:
      kfree_sensitive(hdrs);

Hello JJ,
I don't see this patch being part of v7.0-rc4:

$ git --no-pager log --grep "apparmor: fix incorrect success return
value in unpack"

I don't see the change applied to the apparmor-next branch either
(https://gitlab.com/apparmor/apparmor-kernel/-/blob/apparmor-next/security/apparmor/policy_unpack.c).

---
Massimiliano Pellizzer