All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] libsepol/cil: fix out-of-bound read of a file context pattern ending with "\"
@ 2021-03-14 20:16 Nicolas Iooss
  2021-03-14 20:16 ` [PATCH 2/6] libsepol/cil: make cil_post_fc_fill_data static Nicolas Iooss
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Nicolas Iooss @ 2021-03-14 20:16 UTC (permalink / raw)
  To: selinux

OSS-Fuzz found a Heap-buffer-overflow in the CIL compiler when trying to
compile the following policy:

    (sid SID)
    (sidorder(SID))
    (filecon "\" any ())
    (filecon "" any ())

When cil_post_fc_fill_data() processes "\", it goes beyond the NUL
terminator of the string. Fix this by returning when '\0' is read after
a backslash.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28484
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsepol/cil/src/cil_post.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index a55df1ea5bb0..5f9cf4efd242 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -179,6 +179,12 @@ void cil_post_fc_fill_data(struct fc_data *fc, char *path)
 			break;
 		case '\\':
 			c++;
+			if (path[c] == '\0') {
+				if (!fc->meta) {
+					fc->stem_len++;
+				}
+				return;
+			}
 			/* FALLTHRU */
 		default:
 			if (!fc->meta) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-03-17 14:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-14 20:16 [PATCH 1/6] libsepol/cil: fix out-of-bound read of a file context pattern ending with "\" Nicolas Iooss
2021-03-14 20:16 ` [PATCH 2/6] libsepol/cil: make cil_post_fc_fill_data static Nicolas Iooss
2021-03-15 21:03   ` James Carter
2021-03-17  8:39     ` Nicolas Iooss
2021-03-14 20:16 ` [PATCH 3/6] libsepol/cil: remove stray printf Nicolas Iooss
2021-03-15 21:03   ` James Carter
2021-03-14 20:16 ` [PATCH 4/6] libsepol/cil: replace printf with proper cil_tree_log Nicolas Iooss
2021-03-15 21:04   ` James Carter
2021-03-14 20:16 ` [PATCH 5/6] libsepol/cil: fix NULL pointer dereference in __cil_insert_name Nicolas Iooss
2021-03-15 21:05   ` James Carter
2021-03-14 20:16 ` [PATCH 6/6] libsepol/cil: do not leak avrulex_ioctl_table memory when an error occurs Nicolas Iooss
2021-03-15 21:05   ` James Carter
2021-03-15 21:02 ` [PATCH 1/6] libsepol/cil: fix out-of-bound read of a file context pattern ending with "\" James Carter
2021-03-15 21:34   ` Nicolas Iooss
2021-03-16 13:34     ` James Carter
2021-03-17  7:45       ` Nicolas Iooss
2021-03-17 14:35         ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.