Skip to contentSkip to conversation

libsepol/cil: restore error on context rule conflicts

PATCH In review Christian Göttsche 3 participants 4 messages Oct 12, 2022 – Oct 13, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol/cil: restore error on context rule conflicts

Commit bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts") reworked the processing of context rule conflicts to limit the number of written conflicting statements to increase readability of the printed error message. It forgot to set the return value, signaling a context conflict, in the case the logging level is higher than warning (e.g. in semodule(8), which defaults to error).

Fixes bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts")

[1]: https://lore.kernel.org/selinux/[email protected]/

---
 libsepol/cil/src/cil_post.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_post.c +1 -1
index 6e95225f..11e572e2 100644
@@ -2290,6 +2290,7 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
 		} else {
 			removed++;
 			if (!db->multiple_decls || concompar(&sort->array[i], &sort->array[j]) != 0) {
+				rc = SEPOL_ERR;
 				conflicting++;
 				if (log_level >= CIL_WARN) {
 					struct cil_list_item li;
@@ -2297,7 +2298,6 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
 					li.flavor = flavor;
 					if (conflicting == 1) {
 						cil_log(CIL_WARN, "Found conflicting %s rules\n", flavor_str);
-						rc = SEPOL_ERR;
 						li.data = sort->array[i];
 						rc2 = cil_tree_walk(db->ast->root, __cil_post_report_conflict,
 											NULL, NULL, &li);
Signature · 1 line
2.37.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christian Göttsche

Commit bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts") reworked the processing of context rule conflicts to limit the number of written conflicting statements to increase readability of the printed error message. It forgot to set the return value, signaling a context conflict, in the case the logging level is higher than warning (e.g. in semodule(8), which defaults to error).

Quoted 6 lines
Fixes bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts")

[1]: https://lore.kernel.org/selinux/[email protected]/

Quoted 27 lines
---
 libsepol/cil/src/cil_post.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_post.c +1 -2
index 6e95225f..11e572e2 100644
@@ -2290,6 +2290,7 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                } else {
                        removed++;
                        if (!db->multiple_decls || concompar(&sort->array[i], &sort->array[j]) != 0) {
+                               rc = SEPOL_ERR;
                                conflicting++;
                                if (log_level >= CIL_WARN) {
                                        struct cil_list_item li;
@@ -2297,7 +2298,6 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                                        li.flavor = flavor;
                                        if (conflicting == 1) {
                                                cil_log(CIL_WARN, "Found conflicting %s rules\n", flavor_str);
-                                               rc = SEPOL_ERR;
                                                li.data = sort->array[i];
                                                rc2 = cil_tree_walk(db->ast->root, __cil_post_report_conflict,
                                                                                        NULL, NULL, &li);
--

2.37.2

Tested-by
#2 lore raw
Quoted 11 lines · James Carter
Quoted 9 lines · Christian Göttsche

Commit bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts") reworked the processing of context rule conflicts to limit the number of written conflicting statements to increase readability of the printed error message. It forgot to set the return value, signaling a context conflict, in the case the logging level is higher than warning (e.g. in semodule(8), which defaults to error).

Quoted 8 lines
Quoted 6 lines
Fixes bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts")

[1]: https://lore.kernel.org/selinux/[email protected]/

Thanks!

Quoted 27 lines
Quoted 27 lines
---
 libsepol/cil/src/cil_post.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_post.c +1 -2
index 6e95225f..11e572e2 100644
@@ -2290,6 +2290,7 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                } else {
                        removed++;
                        if (!db->multiple_decls || concompar(&sort->array[i], &sort->array[j]) != 0) {
+                               rc = SEPOL_ERR;
                                conflicting++;
                                if (log_level >= CIL_WARN) {
                                        struct cil_list_item li;
@@ -2297,7 +2298,6 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                                        li.flavor = flavor;
                                        if (conflicting == 1) {
                                                cil_log(CIL_WARN, "Found conflicting %s rules\n", flavor_str);
-                                               rc = SEPOL_ERR;
                                                li.data = sort->array[i];
                                                rc2 = cil_tree_walk(db->ast->root, __cil_post_report_conflict,
                                                                                        NULL, NULL, &li);
--

2.37.2

#3 lore raw
Quoted 19 lines · Petr Lautrbach
Quoted 16 lines · James Carter
Quoted 14 lines · Christian Göttsche

Commit bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts") reworked the processing of context rule conflicts to limit the number of written conflicting statements to increase readability of the printed error message. It forgot to set the return value, signaling a context conflict, in the case the logging level is higher than warning (e.g. in semodule(8), which defaults to error).

Fixes bc26ddc59c8d ("libsepol/cil: Limit the amount of reporting for context rule conflicts")

[1]: https://lore.kernel.org/selinux/[email protected]/

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks!

Merged.
Jim

Quoted 29 lines
Quoted 28 lines
Quoted 28 lines
---
 libsepol/cil/src/cil_post.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_post.c +1 -2
index 6e95225f..11e572e2 100644
@@ -2290,6 +2290,7 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                } else {
                        removed++;
                        if (!db->multiple_decls || concompar(&sort->array[i], &sort->array[j]) != 0) {
+                               rc = SEPOL_ERR;
                                conflicting++;
                                if (log_level >= CIL_WARN) {
                                        struct cil_list_item li;
@@ -2297,7 +2298,6 @@ static int __cil_post_process_context_rules(struct cil_sort *sort, int (*compar)
                                        li.flavor = flavor;
                                        if (conflicting == 1) {
                                                cil_log(CIL_WARN, "Found conflicting %s rules\n", flavor_str);
-                                               rc = SEPOL_ERR;
                                                li.data = sort->array[i];
                                                rc2 = cil_tree_walk(db->ast->root, __cil_post_report_conflict,
                                                                                        NULL, NULL, &li);
--

2.37.2