binfmt_elf: switch to new creds when switching to new mm
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 22 Aug 2016 23:41:46 +0000 (16:41 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Aug 2016 16:13:56 +0000 (09:13 -0700)
commit9f834ec18defc369d73ccf9e87a2790bfa05bf46
tree5f70d5826dda2f6e59f7dc5a20ebb1e8278e26d3
parent61b5ebd6ffc3099618a2e79903e5ee0577c10799
binfmt_elf: switch to new creds when switching to new mm

We used to delay switching to the new credentials until after we had
mapped the executable (and possible elf interpreter).  That was kind of
odd to begin with, since the new executable will actually then _run_
with the new creds, but whatever.

The bigger problem was that we also want to make sure that we turn off
prof events and tracing before we start mapping the new executable
state.  So while this is a cleanup, it's also a fix for a possible
information leak.

Reported-by: Robert Święcki <robert@swiecki.net>
Tested-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/binfmt_elf.c