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

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