Skip to contentSkip to conversation

apparmor: Fix incorrect profile->signal range check

PATCH In review Colin Ian King 3 participants 3 messages May 6, 2025 – May 17, 2025

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

PATCH 1/1 apparmor: Fix incorrect profile->signal range check

The check on profile->signal is always false, the value can never be less than 1 *and* greater than MAXMAPPED_SIG. Fix this by replacing the logical operator && with ||.

Fixes 84c455decf27 ("apparmor: add support for profiles to define the kill signal")
---
 security/apparmor/policy_unpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
index 73139189df0f..e643514a3d92 100644
@@ -919,7 +919,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
 
 	/* optional */
 	(void) aa_unpack_u32(e, &profile->signal, "kill");
-	if (profile->signal < 1 && profile->signal > MAXMAPPED_SIG) {
+	if (profile->signal < 1 || profile->signal > MAXMAPPED_SIG) {
 		info = "profile kill.signal invalid value";
 		goto fail;
 	}
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Colin Ian King

The check on profile->signal is always false, the value can never be less than 1 *and* greater than MAXMAPPED_SIG. Fix this by replacing the logical operator && with ||.

Fixes 84c455decf27 ("apparmor: add support for profiles to define the kill signal")
---
 security/apparmor/policy_unpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -2
index 73139189df0f..e643514a3d92 100644
@@ -919,7 +919,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
 
        /* optional */
        (void) aa_unpack_u32(e, &profile->signal, "kill");
-       if (profile->signal < 1 && profile->signal > MAXMAPPED_SIG) {
+       if (profile->signal < 1 || profile->signal > MAXMAPPED_SIG) {
                info = "profile kill.signal invalid value";
                goto fail;
        }
--
Quoted 1 line

2.49.0

Quoted 2 lines
maintainer Acked-by
#2 lore raw
Quoted 18 lines · Ryan Lee
Quoted 17 lines · Colin Ian King

The check on profile->signal is always false, the value can never be less than 1 *and* greater than MAXMAPPED_SIG. Fix this by replacing the logical operator && with ||.

Fixes 84c455decf27 ("apparmor: add support for profiles to define the kill signal")
---
  security/apparmor/policy_unpack.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +0 -0
index 73139189df0f..e643514a3d92 100644
@@ -919,7 +919,7 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
 
Quoted 11 lines
Quoted 9 lines
security/apparmor/policy_unpack.c +1 -2
         /* optional */
         (void) aa_unpack_u32(e, &profile->signal, "kill");
-       if (profile->signal < 1 && profile->signal > MAXMAPPED_SIG) {
+       if (profile->signal < 1 || profile->signal > MAXMAPPED_SIG) {
                 info = "profile kill.signal invalid value";
                 goto fail;
         }
--

2.49.0

I have pulled this into my tree