Skip to contentSkip to conversation

apparmor: Fix checking address of an array in accum_label_info()

PATCH In review Nathan Chancellor 2 participants 3 messages Jan 20, 2025 – Jan 31, 2025

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

PATCH 1/1 apparmor: Fix checking address of an array in accum_label_info()

clang warns:

security/apparmor/label.c:206:15: error: address of array 'new->vec' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

    206 |         AA_BUG(!new->vec);
        |                ~~~~~~^~~

The address of this array can never be NULL because it is not at the beginning of a structure. Convert the assertion to check that the new pointer is not NULL.

Fixes de4754c801f4 ("apparmor: carry mediation check on label")
---
 security/apparmor/label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/label.c +1 -1
index afded9996f61..79be2d3d604b 100644
@@ -203,7 +203,7 @@ static void accum_label_info(struct aa_label *new)
 	long u = FLAG_UNCONFINED;
 	int i;
 
-	AA_BUG(!new->vec);
+	AA_BUG(!new);
 
 	/* size == 1 is a profile and flags must be set as part of creation */
 	if (new->size == 1)

---
base-commit: e6b087676954e36a7b1ed51249362bb499f8c1c2
change-id: 20250120-apparmor-pointer-bool-conversion-label-7c1027964c7f

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Nathan Chancellor

clang warns:

   security/apparmor/label.c:206:15: error: address of array 'new->vec' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
     206 |         AA_BUG(!new->vec);
         |                ~~~~~~^~~
Quoted 8 lines

The address of this array can never be NULL because it is not at the beginning of a structure. Convert the assertion to check that the new pointer is not NULL.

Fixes de4754c801f4 ("apparmor: carry mediation check on label")

I have pulled this into my tree

Quoted 23 lines
---
  security/apparmor/label.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/label.c +1 -2
index afded9996f61..79be2d3d604b 100644
@@ -203,7 +203,7 @@ static void accum_label_info(struct aa_label *new)
  	long u = FLAG_UNCONFINED;
  	int i;
 
-	AA_BUG(!new->vec);
+	AA_BUG(!new);
 
  	/* size == 1 is a profile and flags must be set as part of creation */
  	if (new->size == 1)
 
---

base-commit: e6b087676954e36a7b1ed51249362bb499f8c1c2
change-id: 20250120-apparmor-pointer-bool-conversion-label-7c1027964c7f

Best regards,

#2 lore raw
Quoted 11 lines · John Johansen
Quoted 10 lines · Nathan Chancellor

clang warns:

   security/apparmor/label.c:206:15: error: address of array 'new->vec' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
     206 |         AA_BUG(!new->vec);
         |                ~~~~~~^~~

The address of this array can never be NULL because it is not at the beginning of a structure. Convert the assertion to check that the new pointer is not NULL.

Quoted 8 lines
Quoted 4 lines
Fixes de4754c801f4 ("apparmor: carry mediation check on label")

I have pulled this into my tree

Thanks! Is this going to be pushed to -next soon? I am still seeing this on next-20240131.

Quoted 23 lines
Quoted 21 lines
---
  security/apparmor/label.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/label.c +1 -2
index afded9996f61..79be2d3d604b 100644
@@ -203,7 +203,7 @@ static void accum_label_info(struct aa_label *new)
  	long u = FLAG_UNCONFINED;
  	int i;
-	AA_BUG(!new->vec);
+	AA_BUG(!new);
  	/* size == 1 is a profile and flags must be set as part of creation */
  	if (new->size == 1)
 
---

base-commit: e6b087676954e36a7b1ed51249362bb499f8c1c2
change-id: 20250120-apparmor-pointer-bool-conversion-label-7c1027964c7f

Best regards,