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

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