Armin Kuster | 066be20 | 2018-07-08 14:58:53 -0700 | [diff] [blame] | 1 | From 28bdae3d113ef479c1660a581ef720cdc33bf466 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jann Horn <jannh@google.com> |
| 3 | Date: Fri, 13 Jul 2018 15:15:36 -0700 |
| 4 | Subject: [PATCH] fusermount: don't feed "escaped commas" into mount options |
| 5 | |
| 6 | The old code permits the following behavior: |
| 7 | |
| 8 | $ _FUSE_COMMFD=10000 priv_strace -etrace=mount -s200 fusermount -o 'foobar=\,allow_other' mount |
| 9 | 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) |
| 10 | |
| 11 | However, backslashes do not have any special meaning for the kernel here. |
| 12 | |
| 13 | As it happens, you can't abuse this because there is no FUSE mount option |
| 14 | that takes a string value that can contain backslashes; but this is very |
| 15 | brittle. Don't interpret "escape characters" in places where they don't |
| 16 | work. |
| 17 | |
| 18 | CVE: CVE-2018-10906 |
| 19 | Upstream-Status: Backport [https://github.com/libfuse/libfuse/commit/28bdae3d113ef479c1660a581ef720cdc33bf466] |
| 20 | |
| 21 | Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> |
| 22 | --- |
| 23 | util/fusermount.c | 5 ++++- |
| 24 | 1 file changed, 4 insertions(+), 1 deletion(-) |
| 25 | |
| 26 | diff --git a/util/fusermount.c b/util/fusermount.c |
| 27 | index 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 | -- |
| 51 | 2.13.3 |
| 52 | |