Skip to contentSkip to conversation

libsepol: avoid potential NULL dereference on optional parameter

PATCH In review Christian Göttsche 2 participants 3 messages Jun 10, 2022 – Jul 6, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: avoid potential NULL dereference on optional parameter

The parameter reason of context_struct_compute_av() is optional and can be passed in as NULL, like from type_attribute_bounds_av().

---
 libsepol/src/services.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/services.c +2 -1
index d7510e9d..24412d83 100644
@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,
 	/* mask violated permissions */
 	avd->allowed &= ~masked;
 
-	*reason |= SEPOL_COMPUTEAV_BOUNDS;
+	if (reason)
+		*reason |= SEPOL_COMPUTEAV_BOUNDS;
 }
 
 /*
Signature · 1 line
2.36.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christian Göttsche

The parameter reason of context_struct_compute_av() is optional and can be passed in as NULL, like from type_attribute_bounds_av().

Quoted 21 lines
---
 libsepol/src/services.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/services.c +2 -2
index d7510e9d..24412d83 100644
@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,
        /* mask violated permissions */
        avd->allowed &= ~masked;
 
-       *reason |= SEPOL_COMPUTEAV_BOUNDS;
+       if (reason)
+               *reason |= SEPOL_COMPUTEAV_BOUNDS;
 }
 
 /*
--

2.36.1

#2 lore raw
Quoted 11 lines · James Carter
Quoted 5 lines · Christian Göttsche

The parameter reason of context_struct_compute_av() is optional and can be passed in as NULL, like from type_attribute_bounds_av().

Merged.
Thanks,
Jim

Quoted 21 lines
Quoted 21 lines
---
 libsepol/src/services.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/services.c +2 -2
index d7510e9d..24412d83 100644
@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,
        /* mask violated permissions */
        avd->allowed &= ~masked;
 
-       *reason |= SEPOL_COMPUTEAV_BOUNDS;
+       if (reason)
+               *reason |= SEPOL_COMPUTEAV_BOUNDS;
 }
 
 /*
--

2.36.1