Blame SOURCES/0059-libsepol-quote-paths-in-CIL-conversion.patch

71cd55
From 644c5bbbc4c71f6636c939cb7748dd2dfa50e638 Mon Sep 17 00:00:00 2001
71cd55
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
71cd55
Date: Tue, 8 Jun 2021 21:39:02 +0200
71cd55
Subject: [PATCH] libsepol: quote paths in CIL conversion
71cd55
MIME-Version: 1.0
71cd55
Content-Type: text/plain; charset=UTF-8
71cd55
Content-Transfer-Encoding: 8bit
71cd55
71cd55
When generating CIL policy from kernel or module policy quote paths,
71cd55
which are allowed to contain spaces, in the statements `genfscon` and
71cd55
`devicetreecon`.
71cd55
71cd55
Reported by LuK1337 while building policy for Android via IRC.
71cd55
71cd55
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
71cd55
---
71cd55
 libsepol/src/kernel_to_cil.c | 4 ++--
71cd55
 libsepol/src/module_to_cil.c | 2 +-
71cd55
 2 files changed, 3 insertions(+), 3 deletions(-)
71cd55
71cd55
diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c
71cd55
index 989aacde8a12..30a27bf527d5 100644
71cd55
--- a/libsepol/src/kernel_to_cil.c
71cd55
+++ b/libsepol/src/kernel_to_cil.c
71cd55
@@ -2654,7 +2654,7 @@ static int write_genfscon_rules_to_cil(FILE *out, struct policydb *pdb)
71cd55
 				goto exit;
71cd55
 			}
71cd55
 
71cd55
-			rc = strs_create_and_add(strs, "(genfscon %s %s %s)", 3,
71cd55
+			rc = strs_create_and_add(strs, "(genfscon %s \"%s\" %s)", 3,
71cd55
 						 fstype, name, ctx);
71cd55
 			free(ctx);
71cd55
 			if (rc != 0) {
71cd55
@@ -3115,7 +3115,7 @@ static int write_xen_devicetree_rules_to_cil(FILE *out, struct policydb *pdb)
71cd55
 			goto exit;
71cd55
 		}
71cd55
 
71cd55
-		sepol_printf(out, "(devicetreecon %s %s)\n", name, ctx);
71cd55
+		sepol_printf(out, "(devicetreecon \"%s\" %s)\n", name, ctx);
71cd55
 
71cd55
 		free(ctx);
71cd55
 	}
71cd55
diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
71cd55
index 496693f4616e..19c7c65c6382 100644
71cd55
--- a/libsepol/src/module_to_cil.c
71cd55
+++ b/libsepol/src/module_to_cil.c
71cd55
@@ -2963,7 +2963,7 @@ static int genfscon_to_cil(struct policydb *pdb)
71cd55
 
71cd55
 	for (genfs = pdb->genfs; genfs != NULL; genfs = genfs->next) {
71cd55
 		for (ocon = genfs->head; ocon != NULL; ocon = ocon->next) {
71cd55
-			cil_printf("(genfscon %s %s ", genfs->fstype, ocon->u.name);
71cd55
+			cil_printf("(genfscon %s \"%s\" ", genfs->fstype, ocon->u.name);
71cd55
 			context_to_cil(pdb, &ocon->context[0]);
71cd55
 			cil_printf(")\n");
71cd55
 		}
71cd55
-- 
71cd55
2.32.0
71cd55