fuse: fix exec environment for mount and umount
[openwrt.git] / package / utils / fuse / patches / 001-fix_exec_environment_for_mount_and_umount.patch
1 From cfe13b7a217075ae741c018da50cd600e5330de2 Mon Sep 17 00:00:00 2001
2 From: Miklos Szeredi <mszeredi@suse.cz>
3 Date: Fri, 22 May 2015 10:58:43 +0200
4 Subject: [PATCH] libfuse: fix exec environment for mount and umount
5
6 Found by Tavis Ormandy (CVE-2015-3202).
7 ---
8 --- a/lib/mount_util.c
9 +++ b/lib/mount_util.c
10 @@ -95,10 +95,12 @@ static int add_mount(const char *prognam
11                 goto out_restore;
12         }
13         if (res == 0) {
14 +               char *env = NULL;
15 +
16                 sigprocmask(SIG_SETMASK, &oldmask, NULL);
17                 setuid(geteuid());
18 -               execl("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
19 -                     "-f", "-t", type, "-o", opts, fsname, mnt, NULL);
20 +               execle("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
21 +                      "-f", "-t", type, "-o", opts, fsname, mnt, NULL, &env);
22                 fprintf(stderr, "%s: failed to execute /bin/mount: %s\n",
23                         progname, strerror(errno));
24                 exit(1);
25 @@ -146,10 +148,17 @@ static int exec_umount(const char *progn
26                 goto out_restore;
27         }
28         if (res == 0) {
29 +               char *env = NULL;
30 +
31                 sigprocmask(SIG_SETMASK, &oldmask, NULL);
32                 setuid(geteuid());
33 -               execl("/bin/umount", "/bin/umount", "-i", rel_mnt,
34 -                     lazy ? "-l" : NULL, NULL);
35 +               if (lazy) {
36 +                       execle("/bin/umount", "/bin/umount", "-i", rel_mnt,
37 +                              "-l", NULL, &env);
38 +               } else {
39 +                       execle("/bin/umount", "/bin/umount", "-i", rel_mnt,
40 +                              NULL, &env);
41 +               }
42                 fprintf(stderr, "%s: failed to execute /bin/umount: %s\n",
43                         progname, strerror(errno));
44                 exit(1);
45 @@ -205,10 +214,12 @@ static int remove_mount(const char *prog
46                 goto out_restore;
47         }
48         if (res == 0) {
49 +               char *env = NULL;
50 +
51                 sigprocmask(SIG_SETMASK, &oldmask, NULL);
52                 setuid(geteuid());
53 -               execl("/bin/umount", "/bin/umount", "--no-canonicalize", "-i",
54 -                     "--fake", mnt, NULL);
55 +               execle("/bin/umount", "/bin/umount", "--no-canonicalize", "-i",
56 +                      "--fake", mnt, NULL, &env);
57                 fprintf(stderr, "%s: failed to execute /bin/umount: %s\n",
58                         progname, strerror(errno));
59                 exit(1);