Blame SOURCES/0101-libsepol-cil-do-not-allow-0-in-quoted-strings.patch

71cd55
From af29a235531f66882e5a027e1348658b8d8c1e68 Mon Sep 17 00:00:00 2001
71cd55
From: Nicolas Iooss <nicolas.iooss@m4x.org>
71cd55
Date: Mon, 12 Jul 2021 10:44:28 +0200
71cd55
Subject: [PATCH] libsepol/cil: do not allow \0 in quoted strings
71cd55
71cd55
Using the '\0' character in strings in a CIL policy is not expected to
71cd55
happen, and makes the flex tokenizer very slow. For example when
71cd55
generating a file with:
71cd55
71cd55
    python -c 'print("\"" + "\0"*100000 + "\"")' > policy.cil
71cd55
71cd55
secilc fails after 26 seconds, on my desktop computer. Increasing the
71cd55
numbers of \0 makes this time increase significantly. But replacing \0
71cd55
with another character makes secilc fail in only few milliseconds.
71cd55
71cd55
Fix this "possible denial of service" issue by forbidding \0 in strings
71cd55
in CIL policies.
71cd55
71cd55
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36016
71cd55
71cd55
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
71cd55
---
71cd55
 libsepol/cil/src/cil_lexer.l | 2 +-
71cd55
 1 file changed, 1 insertion(+), 1 deletion(-)
71cd55
71cd55
diff --git a/libsepol/cil/src/cil_lexer.l b/libsepol/cil/src/cil_lexer.l
71cd55
index e28c33ecb9f1..8bf2b6e7765a 100644
71cd55
--- a/libsepol/cil/src/cil_lexer.l
71cd55
+++ b/libsepol/cil/src/cil_lexer.l
71cd55
@@ -49,7 +49,7 @@ spec_char	[\[\]\.\@\=\/\*\-\_\$\%\+\-\!\|\&\^\:\~\`\#\{\}\'\<\>\?\,]
71cd55
 symbol		({digit}|{alpha}|{spec_char})+
71cd55
 white		[ \t]
71cd55
 newline		[\n\r]
71cd55
-qstring		\"[^"\n]*\"
71cd55
+qstring		\"[^"\n\0]*\"
71cd55
 hll_lm          ^;;\*
71cd55
 comment		;
71cd55
 
71cd55
-- 
71cd55
2.32.0
71cd55