Blame SOURCES/fusermount-don-t-feed-escaped-commas-into-mount-opti.patch

9a0615
From 520f09be3c2d351722c33daf7389d6ac4716be98 Mon Sep 17 00:00:00 2001
9a0615
From: Jann Horn <jannh@google.com>
9a0615
Date: Fri, 13 Jul 2018 15:15:36 -0700
9a0615
Subject: [PATCH] fusermount: don't feed "escaped commas" into mount options
9a0615
9a0615
The old code permits the following behavior:
9a0615
9a0615
$ _FUSE_COMMFD=10000 priv_strace -etrace=mount -s200 fusermount -o 'foobar=\,allow_other' mount
9a0615
mount("/dev/fuse", ".", "fuse", MS_NOSUID|MS_NODEV, "foobar=\\,allow_other,fd=3,rootmode=40000,user_id=1000,group_id=1000") = -1 EINVAL (Invalid argument)
9a0615
9a0615
However, backslashes do not have any special meaning for the kernel here.
9a0615
9a0615
As it happens, you can't abuse this because there is no FUSE mount option
9a0615
that takes a string value that can contain backslashes; but this is very
9a0615
brittle. Don't interpret "escape characters" in places where they don't
9a0615
work.
9a0615
---
9a0615
 util/fusermount.c | 5 ++++-
9a0615
 1 file changed, 4 insertions(+), 1 deletion(-)
9a0615
9a0615
diff --git a/util/fusermount.c b/util/fusermount.c
9a0615
index 26a0b75bbecb..5175c0115a05 100644
9a0615
--- a/util/fusermount.c
9a0615
+++ b/util/fusermount.c
9a0615
@@ -29,6 +29,7 @@
9a0615
 #include <sys/socket.h>
9a0615
 #include <sys/utsname.h>
9a0615
 #include <sched.h>
9a0615
+#include <stdbool.h>
9a0615
 
9a0615
 #define FUSE_COMMFD_ENV		"_FUSE_COMMFD"
9a0615
 
9a0615
@@ -739,8 +740,10 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
9a0615
 		unsigned len;
9a0615
 		const char *fsname_str = "fsname=";
9a0615
 		const char *subtype_str = "subtype=";
9a0615
+		bool escape_ok = begins_with(s, fsname_str) ||
9a0615
+				 begins_with(s, subtype_str);
9a0615
 		for (len = 0; s[len]; len++) {
9a0615
-			if (s[len] == '\\' && s[len + 1])
9a0615
+			if (escape_ok && s[len] == '\\' && s[len + 1])
9a0615
 				len++;
9a0615
 			else if (s[len] == ',')
9a0615
 				break;
9a0615
-- 
9a0615
2.14.3
9a0615