Skip to content

Commit

Permalink
um: Do not set unsecure permission for temporary file
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Richard Weinberger <[email protected]>
Acked-by: Tristan Schmelcher <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
l0kod authored and richardweinberger committed Jan 10, 2016
1 parent 42d91f6 commit 571d2f0
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions arch/um/os-Linux/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 571d2f0

Please sign in to comment.