mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
selftests/namespaces: check listns() with a U64_MAX cursor
Pass the largest possible namespace id as the cursor and check that listns() fails with ENOENT instead of starting over: - in the unified tree - in a type-specific tree - in the owner tree of the caller's user namespace Nothing can come after the largest possible id. Link: https://patch.msgid.link/20261021-work-mount-statmount_listns_fixes-v1-6-8917a4c1bd14@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
2a1887000e
commit
486b257357
|
|
@ -676,4 +676,38 @@ TEST(listns_error_cases)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A cursor at the largest possible namespace id must not wrap around and
|
||||
* restart the listing from the beginning.
|
||||
*/
|
||||
TEST(listns_cursor_max)
|
||||
{
|
||||
struct ns_id_req req = {
|
||||
.size = sizeof(req),
|
||||
.ns_id = ULLONG_MAX,
|
||||
};
|
||||
__u64 ns_ids[10];
|
||||
ssize_t ret;
|
||||
|
||||
/* unified tree */
|
||||
ret = sys_listns(&req, ns_ids, ARRAY_SIZE(ns_ids), 0);
|
||||
if (ret < 0 && errno == ENOSYS)
|
||||
SKIP(return, "listns() not supported");
|
||||
ASSERT_EQ(ret, -1);
|
||||
ASSERT_EQ(errno, ENOENT);
|
||||
|
||||
/* type-specific tree */
|
||||
req.ns_type = CLONE_NEWUSER;
|
||||
ret = sys_listns(&req, ns_ids, ARRAY_SIZE(ns_ids), 0);
|
||||
ASSERT_EQ(ret, -1);
|
||||
ASSERT_EQ(errno, ENOENT);
|
||||
|
||||
/* owner tree */
|
||||
req.ns_type = 0;
|
||||
req.user_ns_id = LISTNS_CURRENT_USER;
|
||||
ret = sys_listns(&req, ns_ids, ARRAY_SIZE(ns_ids), 0);
|
||||
ASSERT_EQ(ret, -1);
|
||||
ASSERT_EQ(errno, ENOENT);
|
||||
}
|
||||
|
||||
TEST_HARNESS_MAIN
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user