exec: Ensure mm->user_ns contains the execed files 52/198052/3 accepted/tizen/unified/20190128.061431 submit/tizen/20190122.013020
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 17 Nov 2016 04:06:51 +0000 (22:06 -0600)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 18 Jan 2019 06:35:28 +0000 (15:35 +0900)
commit92c624bbcc160397fcd6127cdbece1f0f20a2b97
tree4729140a6803bac76adc8c7041629796f87e8591
parent417ee94fa3297aee98a7a397624349707e29b7d9
exec: Ensure mm->user_ns contains the execed files

commit f84df2a6f268de584a201e8911384a2d244876e3 upstream.

When the user namespace support was merged the need to prevent
ptrace from revealing the contents of an unreadable executable
was overlooked.

Correct this oversight by ensuring that the executed file
or files are in mm->user_ns, by adjusting mm->user_ns.

Use the new function privileged_wrt_inode_uidgid to see if
the executable is a member of the user namespace, and as such
if having CAP_SYS_PTRACE in the user namespace should allow
tracing the executable.  If not update mm->user_ns to
the parent user namespace until an appropriate parent is found.

Reported-by: Jann Horn <jann@thejh.net>
Fixes: 9e4a36ece652 ("userns: Fail exec for suid and sgid binaries with ids outside our user namespace.")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: backport linux-4.4.y commit b35f34f66943 to resolve smack permission deny issue in cgroup_release_agent kthread]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Iafbc32f9c5cc7f4c963876bd30a65be87646b207
fs/exec.c
include/linux/capability.h
kernel/capability.c