diff mbox series

[v2] selftests/seccomp: Add SKIP for failed unshare()

Message ID 7f7687696a5c0a2d040a24474616e945c7cf2bb5.1648599460.git.yang.guang5@zte.com.cn (mailing list archive)
State Accepted
Commit 95a126d9812ff51f7ff3e42d956390ff9a1801f8
Headers show
Series [v2] selftests/seccomp: Add SKIP for failed unshare() | expand

Commit Message

David Yang March 30, 2022, 12:22 a.m. UTC
From: Yang Guang <yang.guang5@zte.com.cn>

Running the seccomp tests under the kernel with "defconfig"
shouldn't fail. Because the CONFIG_USER_NS is not supported
in "defconfig". Skipping this case instead of failing it is
better.

Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

---
Changes from v1->v2:
- Modify the commit message to better understand.
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Kees Cook March 30, 2022, 9:52 p.m. UTC | #1
On Wed, 30 Mar 2022 08:22:10 +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Running the seccomp tests under the kernel with "defconfig"
> shouldn't fail. Because the CONFIG_USER_NS is not supported
> in "defconfig". Skipping this case instead of failing it is
> better.
> 
> [...]

Applied to for-next/seccomp, thanks!

[1/1] selftests/seccomp: Add SKIP for failed unshare()
      https://git.kernel.org/kees/c/8a3d3ea66f0d
diff mbox series

Patch

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 313bb0cbfb1e..e9a61cb2eb88 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3742,7 +3742,10 @@  TEST(user_notification_fault_recv)
 	struct seccomp_notif req = {};
 	struct seccomp_notif_resp resp = {};
 
-	ASSERT_EQ(unshare(CLONE_NEWUSER), 0);
+	ASSERT_EQ(unshare(CLONE_NEWUSER), 0) {
+		if (errno == EINVAL)
+			SKIP(return, "kernel missing CLONE_NEWUSER support");
+	}
 
 	listener = user_notif_syscall(__NR_getppid,
 				      SECCOMP_FILTER_FLAG_NEW_LISTENER);