]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs: take i_mutex during prepare_binprm for set[ug]id executables
authorJann Horn <jann@thejh.net>
Sun, 19 Apr 2015 00:48:39 +0000 (02:48 +0200)
committerZefan Li <lizefan@huawei.com>
Fri, 19 Jun 2015 03:40:33 +0000 (11:40 +0800)
commite661bb1c6d22a28c9038f4c2888e1e3b52f5b247
treee797ebe2ad53fc979ec9c94eb628a222c42a102e
parentfcafa22d451873a00bc97caa3abeeaa07b07685e
fs: take i_mutex during prepare_binprm for set[ug]id executables

commit 8b01fc86b9f425899f8a3a8fc1c47d73c2c20543 upstream.

This prevents a race between chown() and execve(), where chowning a
setuid-user binary to root would momentarily make the binary setuid
root.

This patch was mostly written by Linus Torvalds.

Signed-off-by: Jann Horn <jann@thejh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[lizf: Backported to 3.4:
 - adjust context
 - remove task_no_new_priv and user namespace stuff
 - open-code file_inode()
 - s/READ_ONCE/ACCESS_ONCE]
Signed-off-by: Zefan Li <lizefan@huawei.com>
fs/exec.c