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

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