Skip to contentSkip to conversation

libselinux: warn on identical duplicate properties

PATCH In review Thiébaud Weksteen 2 participants 3 messages Feb 13, 2025 – Apr 7, 2025 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: warn on identical duplicate properties

Instead of raising an error in case of matching duplicates, only report the issue as a warning. This matches the downstream (AOSP) behaviour for Android.

---
 libselinux/src/label_backends_android.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libselinux/src/label_backends_android.c +3 -3
index cbe932ae..cf4f5cbf 100644
@@ -58,10 +58,10 @@ static int nodups_specs(struct saved_data *data, const char *path)
 		for (jj = ii + 1; jj < data->nspec; jj++) {
 			if (!strcmp(spec_arr[jj].property_key,
 					    curr_spec->property_key)) {
-				rc = -1;
-				errno = EINVAL;
 				if (strcmp(spec_arr[jj].lr.ctx_raw,
 						    curr_spec->lr.ctx_raw)) {
+					rc = -1;
+					errno = EINVAL;
 					selinux_log
 						(SELINUX_ERROR,
 						 "%s: Multiple different specifications for %s  (%s and %s).\n",
@@ -70,7 +70,7 @@ static int nodups_specs(struct saved_data *data, const char *path)
 						 curr_spec->lr.ctx_raw);
 				} else {
 					selinux_log
-						(SELINUX_ERROR,
+						(SELINUX_WARNING,
 						 "%s: Multiple same specifications for %s.\n",
 						 path, curr_spec->property_key);
 				}
Signature · 1 line
2.48.1.502.g6dc24dfdaf-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Thiébaud Weksteen

Instead of raising an error in case of matching duplicates, only report the issue as a warning. This matches the downstream (AOSP) behaviour for Android.

Quoted 34 lines
---
 libselinux/src/label_backends_android.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libselinux/src/label_backends_android.c +3 -4
index cbe932ae..cf4f5cbf 100644
@@ -58,10 +58,10 @@ static int nodups_specs(struct saved_data *data, const char *path)
                for (jj = ii + 1; jj < data->nspec; jj++) {
                        if (!strcmp(spec_arr[jj].property_key,
                                            curr_spec->property_key)) {
-                               rc = -1;
-                               errno = EINVAL;
                                if (strcmp(spec_arr[jj].lr.ctx_raw,
                                                    curr_spec->lr.ctx_raw)) {
+                                       rc = -1;
+                                       errno = EINVAL;
                                        selinux_log
                                                (SELINUX_ERROR,
                                                 "%s: Multiple different specifications for %s  (%s and %s).\n",
@@ -70,7 +70,7 @@ static int nodups_specs(struct saved_data *data, const char *path)
                                                 curr_spec->lr.ctx_raw);
                                } else {
                                        selinux_log
-                                               (SELINUX_ERROR,
+                                               (SELINUX_WARNING,
                                                 "%s: Multiple same specifications for %s.\n",
                                                 path, curr_spec->property_key);
                                }
--

2.48.1.502.g6dc24dfdaf-goog

#2 lore raw
Quoted 11 lines · James Carter
Quoted 6 lines · Thiébaud Weksteen

Instead of raising an error in case of matching duplicates, only report the issue as a warning. This matches the downstream (AOSP) behaviour for Android.

Merged.
Thanks,
Jim

Quoted 34 lines
Quoted 34 lines
---
 libselinux/src/label_backends_android.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libselinux/src/label_backends_android.c +3 -4
index cbe932ae..cf4f5cbf 100644
@@ -58,10 +58,10 @@ static int nodups_specs(struct saved_data *data, const char *path)
                for (jj = ii + 1; jj < data->nspec; jj++) {
                        if (!strcmp(spec_arr[jj].property_key,
                                            curr_spec->property_key)) {
-                               rc = -1;
-                               errno = EINVAL;
                                if (strcmp(spec_arr[jj].lr.ctx_raw,
                                                    curr_spec->lr.ctx_raw)) {
+                                       rc = -1;
+                                       errno = EINVAL;
                                        selinux_log
                                                (SELINUX_ERROR,
                                                 "%s: Multiple different specifications for %s  (%s and %s).\n",
@@ -70,7 +70,7 @@ static int nodups_specs(struct saved_data *data, const char *path)
                                                 curr_spec->lr.ctx_raw);
                                } else {
                                        selinux_log
-                                               (SELINUX_ERROR,
+                                               (SELINUX_WARNING,
                                                 "%s: Multiple same specifications for %s.\n",
                                                 path, curr_spec->property_key);
                                }
--

2.48.1.502.g6dc24dfdaf-goog