blob: 83bef302295be9e941a71ad7238a86d0d7457994 [file] [log] [blame]
Armin Kuster066be202018-07-08 14:58:53 -07001From 28bdae3d113ef479c1660a581ef720cdc33bf466 Mon Sep 17 00:00:00 2001
2From: Jann Horn <jannh@google.com>
3Date: Fri, 13 Jul 2018 15:15:36 -0700
4Subject: [PATCH] fusermount: don't feed "escaped commas" into mount options
5
6The old code permits the following behavior:
7
8$ _FUSE_COMMFD=10000 priv_strace -etrace=mount -s200 fusermount -o 'foobar=\,allow_other' mount
9mount("/dev/fuse", ".", "fuse", MS_NOSUID|MS_NODEV, "foobar=\\,allow_other,fd=3,rootmode=40000,user_id=1000,group_id=1000") = -1 EINVAL (Invalid argument)
10
11However, backslashes do not have any special meaning for the kernel here.
12
13As it happens, you can't abuse this because there is no FUSE mount option
14that takes a string value that can contain backslashes; but this is very
15brittle. Don't interpret "escape characters" in places where they don't
16work.
17
18CVE: CVE-2018-10906
19Upstream-Status: Backport [https://github.com/libfuse/libfuse/commit/28bdae3d113ef479c1660a581ef720cdc33bf466]
20
21Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
22---
23 util/fusermount.c | 5 ++++-
24 1 file changed, 4 insertions(+), 1 deletion(-)
25
26diff --git a/util/fusermount.c b/util/fusermount.c
27index 0e1d34d..143bd4a 100644
28--- a/util/fusermount.c
29+++ b/util/fusermount.c
30@@ -29,6 +29,7 @@
31 #include <sys/socket.h>
32 #include <sys/utsname.h>
33 #include <sched.h>
34+#include <stdbool.h>
35
36 #define FUSE_COMMFD_ENV "_FUSE_COMMFD"
37
38@@ -754,8 +755,10 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
39 unsigned len;
40 const char *fsname_str = "fsname=";
41 const char *subtype_str = "subtype=";
42+ bool escape_ok = begins_with(s, fsname_str) ||
43+ begins_with(s, subtype_str);
44 for (len = 0; s[len]; len++) {
45- if (s[len] == '\\' && s[len + 1])
46+ if (escape_ok && s[len] == '\\' && s[len + 1])
47 len++;
48 else if (s[len] == ',')
49 break;
50--
512.13.3
52