mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
selftests/namespaces: fifth inactive namespace resurrection test
Test SIOCGSKNS fails on non-socket file descriptors. Link: https://patch.msgid.link/20251029-work-namespace-nstree-listns-v4-59-2e6f823ebdc0@kernel.org Tested-by: syzbot@syzkaller.appspotmail.com Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
40226da471
commit
2b9fa5bf0c
|
|
@ -307,4 +307,30 @@ TEST(siocgskns_across_setns)
|
|||
close(netns_a_fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test SIOCGSKNS fails on non-socket file descriptors.
|
||||
*/
|
||||
TEST(siocgskns_non_socket)
|
||||
{
|
||||
int fd;
|
||||
int pipefd[2];
|
||||
|
||||
/* Test on regular file */
|
||||
fd = open("/dev/null", O_RDONLY);
|
||||
ASSERT_GE(fd, 0);
|
||||
|
||||
ASSERT_LT(ioctl(fd, SIOCGSKNS), 0);
|
||||
ASSERT_TRUE(errno == ENOTTY || errno == EINVAL);
|
||||
close(fd);
|
||||
|
||||
/* Test on pipe */
|
||||
ASSERT_EQ(pipe(pipefd), 0);
|
||||
|
||||
ASSERT_LT(ioctl(pipefd[0], SIOCGSKNS), 0);
|
||||
ASSERT_TRUE(errno == ENOTTY || errno == EINVAL);
|
||||
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
}
|
||||
|
||||
TEST_HARNESS_MAIN
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user