[RFC PATCH v7 25/26] selftests/userland: Add userland test suite
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Sun Nov 22 19:52:31 UTC 2026
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] selftests/userland: host /tmp mount leak in
check_child_src_slave_locking()
- [Medium] selftests/userland: 64K-page E2BIG failure in
test_userns_set_idmap()
- [Low] selftests/userland: Python 3.10+ parenthesized with-statements
in test
--
commit cd1410a72fb4e8338db290b21743ad1e3c5bf460
Author: Jarkko Sakkinen <jarkko at kernel.org>
selftests/userland: Add userland test suite
This commit adds a kselftest suite for the userland control object,
namespace sharing, mount-namespace configuration, waitid(P_USERLAND),
pidfd_send_signal(), and userns_set_idmap().
> diff --git a/tools/testing/selftests/userland/userland_test.py b/tools/testing/selftests/userland/userland_test.py
> new file mode 100755
> index 0000000000000..2b43adbbb4291
> --- /dev/null
> +++ b/tools/testing/selftests/userland/userland_test.py
[ ... ]
> + with (
> + self.closing_fd(rns.get_nsfd(CloneFlag.NEWNS)) as mntns_fd,
> + self.closing_fd(rns.make_mount("tmpfs")) as rootfd,
> + ):
[Severity: Low]
Will these parenthesized multi-item with-statements fail with a SyntaxError
on Python 3.9? Parenthesized context managers across multiple clauses
require Python 3.10+, whereas Documentation/process/changes.rst specifies
Python 3.9.x as the minimum supported version.
[ ... ]
> + def check_child_src_slave_locking() -> None:
> + self.enter_userns_if_unpriv()
> + os.unshare(CloneFlag.NEWNS)
> + with self.closing_fd(self.make_plain_mount("tmpfs")) as tfd:
> + os.mkdir("sub", 0o755, dir_fd=tfd)
> + Sys.move_mount(
> + tfd,
> + "",
> + Sys.AT_FDCWD,
> + "/tmp",
> + MoveMountFlag.F_EMPTY_PATH,
> + )
[Severity: Medium]
Does check_child_src_slave_locking() leak a tmpfs mount over the host /tmp
when the test runs as root?
When os.geteuid() == 0, enter_userns_if_unpriv() returns without unsharing
CLONE_NEWUSER, so os.unshare(CloneFlag.NEWNS) keeps shared mount peer
groups with the host mount namespace. Mounting tfd onto /tmp before
making mount propagation private propagates the tmpfs mount into the host
mount namespace, and cleanup only detaches /tmp/sub, leaving the host /tmp
masked after the test exits. Calling Sys.set_mount_propagation("/") right
after os.unshare(CloneFlag.NEWNS), as check_standalone_mntns() does, would
prevent the mount from propagating to the host.
[ ... ]
> + big_buf = ctypes.create_string_buffer(65536)
> + with self.assertRaises(OSError) as cm:
> + Sys.userns_set_idmap_raw(
> + userns_fd, ctypes.addressof(big_buf), size=65536
> + )
> + self.assertEqual(cm.exception.errno, errno.E2BIG)
[Severity: Medium]
Does this E2BIG check fail on kernels configured with 64 KiB (or 256 KiB)
base pages?
userns_set_idmap() returns -E2BIG only when size > PAGE_SIZE. When
PAGE_SIZE >= 65536, size=65536 passes the PAGE_SIZE check and fails later
with EINVAL because the zeroed buffer has no extents. Sizing the buffer
with os.sysconf("SC_PAGE_SIZE") + 1 would exceed PAGE_SIZE on all page
sizes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122193539.3334213-1-jarkko@kernel.org?part=25
More information about the Linux-security-module-archive
mailing list