]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
selftests/capabilities: Fix the test_execve test
authorAndy Lutomirski <luto@kernel.org>
Thu, 29 Jun 2017 15:46:12 +0000 (08:46 -0700)
committerShuah Khan <shuahkh@osg.samsung.com>
Fri, 30 Jun 2017 16:06:24 +0000 (10:06 -0600)
commit796a3bae2fba6810427efdb314a1c126c9490fb3
tree2564ffe87dc6fbb99b1e71ea805b35277516e738
parent4ca90c21b215b6b09761b51547b88993a2046893
selftests/capabilities: Fix the test_execve test

test_execve does rather odd mount manipulations to safely create
temporary setuid and setgid executables that aren't visible to the
rest of the system.  Those executables end up in the test's cwd, but
that cwd is MNT_DETACHed.

The core namespace code considers MNT_DETACHed trees to belong to no
mount namespace at all and, in general, MNT_DETACHed trees are only
barely function.  This interacted with commit 380cf5ba6b0a ("fs:
Treat foreign mounts as nosuid") to cause all MNT_DETACHed trees to
act as though they're nosuid, breaking the test.

Fix it by just not detaching the tree.  It's still in a private
mount namespace and is therefore still invisible to the rest of the
system (except via /proc, and the same nosuid logic will protect all
other programs on the system from believing in test_execve's setuid
bits).

While we're at it, fix some blatant whitespace problems.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Fixes: 380cf5ba6b0a ("fs: Treat foreign mounts as nosuid")
Cc: stable@vger.kernel.org
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Greg KH <greg@kroah.com>
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/capabilities/test_execve.c