um: Do not set unsecure permission for temporary file
authorMickaël Salaün <mic@digikod.net>
Tue, 22 Dec 2015 21:15:09 +0000 (22:15 +0100)
committerRichard Weinberger <richard@nod.at>
Sun, 10 Jan 2016 20:49:50 +0000 (21:49 +0100)
Remove the insecure 0777 mode for temporary file to prohibit other users
to change the executable mapped code.

An attacker could gain access to the mapped file descriptor from the
temporary file (before it is unlinked) in a read-only mode but it should
not be accessible in write mode to avoid arbitrary code execution.

To not change the hostfs behavior, the temporary file creation
permission now depends on the current umask(2) and the implementation of
mkstemp(3).

Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Acked-by: Tristan Schmelcher <tschmelcher@google.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/os-Linux/mem.c

index 897e9ad0c108ed7ef70571628ed2fde039109508..840d573f7e388036d3aae20d8e5bed886b6201b6 100644 (file)
@@ -142,12 +142,6 @@ static int __init create_tmp_file(unsigned long long len)
        if (fd < 0)
                exit(1);
 
-       err = fchmod(fd, 0777);
-       if (err < 0) {
-               perror("fchmod");
-               exit(1);
-       }
-
        /*
         * Seek to len - 1 because writing a character there will
         * increase the file size by one byte, to the desired length.
This page took 0.043857 seconds and 5 git commands to generate.