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

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