Skip to contentSkip to conversation

libsepol: return failure on saturated class name length

PATCH In review Christian Göttsche 2 participants 3 messages Jan 19, 2022 – Jan 27, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: return failure on saturated class name length

Do not return success if the class name length is saturated (or too big in the fuzzer build).

Fixes c3d52a6a ("libsepol: check for saturated class name length")
---
 libsepol/src/policydb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libsepol/src/policydb.c +3 -1
index 562e044e..fc71463e 100644
@@ -3937,7 +3937,9 @@ static int scope_index_read(scope_index_t * scope_index,
 	if (rc < 0)
 		return -1;
 	scope_index->class_perms_len = le32_to_cpu(buf[0]);
-	if (zero_or_saturated(scope_index->class_perms_len)) {
+	if (is_saturated(scope_index->class_perms_len))
+		return -1;
+	if (scope_index->class_perms_len == 0) {
 		scope_index->class_perms_map = NULL;
 		return 0;
 	}
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Christian Göttsche

Do not return success if the class name length is saturated (or too big in the fuzzer build).

Fixes c3d52a6a ("libsepol: check for saturated class name length")
Quoted 22 lines
---
 libsepol/src/policydb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libsepol/src/policydb.c +3 -2
index 562e044e..fc71463e 100644
@@ -3937,7 +3937,9 @@ static int scope_index_read(scope_index_t * scope_index,
        if (rc < 0)
                return -1;
        scope_index->class_perms_len = le32_to_cpu(buf[0]);
-       if (zero_or_saturated(scope_index->class_perms_len)) {
+       if (is_saturated(scope_index->class_perms_len))
+               return -1;
+       if (scope_index->class_perms_len == 0) {
                scope_index->class_perms_map = NULL;
                return 0;
        }
--

2.34.1

#2 lore raw
Quoted 4 lines · James Carter
Quoted 1 line · Christian Göttsche
Quoted 9 lines
Quoted 6 lines

Do not return success if the class name length is saturated (or too big in the fuzzer build).

Fixes c3d52a6a ("libsepol: check for saturated class name length")

Merged.
Thanks,
Jim

Quoted 22 lines
Quoted 22 lines
---
 libsepol/src/policydb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libsepol/src/policydb.c +3 -2
index 562e044e..fc71463e 100644
@@ -3937,7 +3937,9 @@ static int scope_index_read(scope_index_t * scope_index,
        if (rc < 0)
                return -1;
        scope_index->class_perms_len = le32_to_cpu(buf[0]);
-       if (zero_or_saturated(scope_index->class_perms_len)) {
+       if (is_saturated(scope_index->class_perms_len))
+               return -1;
+       if (scope_index->class_perms_len == 0) {
                scope_index->class_perms_map = NULL;
                return 0;
        }
--

2.34.1