Skip to content

Commit e0c0840

Browse files
Seth Forsheeshuahkh
authored andcommitted
selftests/seccomp: Accept any valid fd in user_notification_addfd
This test expects fds to have specific values, which works fine when the test is run standalone. However, the kselftest runner consumes a couple of extra fds for redirection when running tests, so the test fails when run via kselftest. Change the test to pass on any valid fd number. Signed-off-by: Seth Forshee <[email protected]> Acked-by: Shuah Khan <[email protected]> Acked-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 1602a31 commit e0c0840

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4019,18 +4019,14 @@ TEST(user_notification_addfd)
40194019

40204020
/* Verify we can set an arbitrary remote fd */
40214021
fd = ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd);
4022-
/*
4023-
* The child has fds 0(stdin), 1(stdout), 2(stderr), 3(memfd),
4024-
* 4(listener), so the newly allocated fd should be 5.
4025-
*/
4026-
EXPECT_EQ(fd, 5);
4022+
EXPECT_GE(fd, 0);
40274023
EXPECT_EQ(filecmp(getpid(), pid, memfd, fd), 0);
40284024

40294025
/* Verify we can set an arbitrary remote fd with large size */
40304026
memset(&big, 0x0, sizeof(big));
40314027
big.addfd = addfd;
40324028
fd = ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD_BIG, &big);
4033-
EXPECT_EQ(fd, 6);
4029+
EXPECT_GE(fd, 0);
40344030

40354031
/* Verify we can set a specific remote fd */
40364032
addfd.newfd = 42;

0 commit comments

Comments
 (0)