fusermount: refuse unknown options
authorJann Horn <jannh@google.com>
Sat, 14 Jul 2018 10:47:50 +0000 (03:47 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Wed, 18 Jul 2018 19:32:28 +0000 (20:32 +0100)
Blacklists are notoriously fragile; especially if the kernel wishes to add
some security-critical mount option at a later date, all existing systems
with older versions of fusermount installed will suddenly have a security
problem.
Additionally, if the kernel's option parsing became a tiny bit laxer, the
blacklist could probably be bypassed.

Whitelist known-harmless flags instead, even if it's slightly more
inconvenient.

util/fusermount.c

index 4e0f51a39d257ff93e2322f2c45e3ccc19eb8c88..27924073d633fcd6891aa27ce6265296d657ccae 100644 (file)
@@ -819,10 +819,16 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
                                                flags |= flag;
                                        else
                                                flags  &= ~flag;
-                               } else {
+                               } else if (opt_eq(s, len, "default_permissions") ||
+                                          opt_eq(s, len, "allow_other") ||
+                                          begins_with(s, "max_read=") ||
+                                          begins_with(s, "blksize=")) {
                                        memcpy(d, s, len);
                                        d += len;
                                        *d++ = ',';
+                               } else {
+                                       fprintf(stderr, "%s: unknown option '%.*s'\n", progname, len, s);
+                                       exit(1);
                                }
                        }
                }