Re: [RFC PATCH v8 28/29] selftests/userland: Add userland test suite
From: Jarkko Sakkinen
Date: Mon Nov 30 2026 - 05:11:12 EST
On Mon, Nov 30, 2026 at 09:01:34AM +0200, Jarkko Sakkinen wrote:
> On Mon, Nov 30, 2026 at 08:49:42AM +0200, Jarkko Sakkinen wrote:
> > On Mon, Nov 30, 2026 at 04:39:42AM +0200, Jarkko Sakkinen wrote:
> > > On Mon, Nov 30, 2026 at 03:34:23AM +0200, Jarkko Sakkinen wrote:
> > > > On Sun, Nov 29, 2026 at 01:58:07AM +0200, Jarkko Sakkinen wrote:
> > > > > Verify the userland_open() control object, namespace sharing,
> > > > > mount-namespace configuration, waitid(P_USERLAND), pidfd_send_signal(),
> > > > > and userns_set_idmap() uAPI and security invariants across privileged,
> > > > > unprivileged, SCM_RIGHTS delegation, and edge-case scenarios.
> > > > >
> > > > > Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> > > >
> > > >
> > > > At https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd-test.git/:
> > > >
> > > > $ make
> > > > make help Show this help
> > > > make list List available defconfigs
> > > > make download Prime the download cache
> > > > make sdk Build and cache SDK toolchains
> > > > make configure Force <BOARD> configuration
> > > > make savedefconfig Save minimal <BOARD> defconfig
> > > > make linux-update-defconfig Save minimal <BOARD> kernel defconfig
> > > > make build Incrementally build <BOARD> (FORCE=1 to run again)
> > > > make userland Build <BOARD> with userland trees (FORCE=1 to run again)
> > > > make ssh Open an SSH session to <BOARD>
> > > > make burn Write existing image to DEVICE (does not build)
> > > > make clean Remove build artifacts
> > > > make clean-sdk Remove cached SDK toolchains
> > > > make lint Run linters
> > > >
> > > > "userland" target builds a a hybrid ISO containing a bootc/composefs
> > > > based OS build, and having Userland-patched Linux, SystemD, Bubblewrap
> > > > and Podman. My kernel testing suite has developed into a Silverblue'ish
> > > > environment because I needed something like that for testing lockdown
> > > > hibernate patches.
> > > >
> > > > Here's virsh hosted "tpmdd_amd64.iso" built with "make userland
> > > > BOARD=tpmdd_amd64" running the kselftest:
> > > >
> > > > TAP version 13
> > > > 1..1
> > > > kselftest: Running tests in userland
> > > > # timeout set to 45
> > > > # selftests: userland: test_smoke.sh
> > > > # TAP version 13
> > > > # 1..17
> > > > # ok 1 UserlandUapiTest.test_cell_broadcast_kill
> > > > # ok 2 UserlandUapiTest.test_cell_lifecycle_exec_and_hot_mount
> > > > # ok 3 UserlandUapiTest.test_clone_flags_and_pidns_ancestry
> > > > # ok 3 UserlandUapiTest.test_clone_flags_and_pidns_ancestry
> > > > # ok 3 UserlandUapiTest.test_clone_flags_and_pidns_ancestry
> > > > # ok 3 UserlandUapiTest.test_clone_flags_and_pidns_ancestry
> > > > # ok 3 UserlandUapiTest.test_clone_flags_and_pidns_ancestry
> > > > # ok 4 UserlandUapiTest.test_concurrent_bootstrap
> > > > # ok 5 UserlandUapiTest.test_create_flags
> > > > # ok 6 UserlandUapiTest.test_get_nsfd
> > > > # # UserlandUapiTest.test_landlock_namespace_use: Landlock not enabled
> > > > # ok 7 UserlandUapiTest.test_landlock_namespace_use # SKIP
> > > > # ok 8 UserlandUapiTest.test_mount_and_fsconfig_validation
> > > > # ok 9 UserlandUapiTest.test_pivot_root_and_standalone_mntns_hot_mount
> > > > # ok 10 UserlandUapiTest.test_proc_submount_and_nested_namespaces
> > > > # ok 11 UserlandUapiTest.test_send_signal_and_kill_on_close
> > > > # ok 12 UserlandUapiTest.test_setns_owner_vs_foreign
> > > > # ok 13 UserlandUapiTest.test_share_nsfd
> > > > # ok 14 UserlandUapiTest.test_unprivileged_without_entering_userns
> > > > # ok 15 UserlandUapiTest.test_userns_set_idmap
> > > > # ok 16 UserlandUapiTest.test_userns_set_idmap_delegation
> > > > # ok 17 UserlandUapiTest.test_wait_poll_and_clone_dead
> > > > # # 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
> > > > # # Totals: pass:16 fail:0 xfail:0 xpass:0 skip:1 error:0
> > > > ok 1 selftests: userland: test_smoke.sh
> > > > # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> > > >
> > > > Yes, I should "CONFIG_LANDLOCK=y". It's the next thing on the list.
> > > >
> > > > Generally I plan to make it model based stochastic test with seed
> > > > printed at start so that failures can be replayed.
> > > >
> > > > I've used model based testing lately very successfully in my Landstrip
> > > > stateless parametric agent sandbox (compatible with Anthtropic's policy
> > > > format): https://github.com/landstrip/landstrip
> > > >
> > > > It feels like right way to go so that the syscall interface can be
> > > > actually stressed.
> > >
> > > It's also "crypto-ready" architecture. I.e. given that entities are
> > > inspired by confidential computing workloads, there's a clean staging
> > > phase, and that provides integration points for having cryptograhic
> > > measurement, if that is ever wanted. Obviously, that would be still
> > > non-trivial problem but architecture is doing best effort on helping
> > > to resolve it.
> >
> > This could be useful actually in lockdown-hibernate. It could have
> > more zeroing host OS state mode as long as boostrap can decrypt
> > the container after powering up back from S4.
> >
> > Unconsidered idea, and partly off-topic but had to write this down
> > as lockdown-hibernate is active review process.
> >
> > I.e., possibly in addition to PCR 5 trampoline, it should have
> > "container mode".
>
> In container-S4-wakeup the same trampoline would be used but I'm
> thinking could you only sign a critical portion of the RAM and
> forget rest and wake up rest of the state from a container.
>
> Might be a bad idea but highlights how important it would be for a
> container abstraction to be relatively opaque object so that other
> things like authentication and power management have also room for
> consideration.
>
> I think where the design is going wrong all the time is to consider this
> as Linux namespaces feature while container is actually more like "soft
> arch" and the feature that I've been doing can be imagined as "soft
> kexec".
I have now rudimentary model-based test. Initially it just generates a
test case per category but before I push this I'll make it generate a
bunch of test cases per category; each randomized per run.
I also pixel-perfected Cells-emulator quite a lot and it is much more
comparable than the one in this patch set. These obviously exercise
also kselftest/cells/userland stack. The test is now in fact in good
shape enough that it would be easy to to make it even cross patch
set compatible.
Example output:
TAP version 13
1..1
# timeout set to 120
# selftests: userland: test_smoke.sh
# TAP version 13
# 1..6
# # seed 0xdeac25bb4153280d (replay: USERLAND_SEED=0xdeac25bb4153280d)
# ok 1 reproduce
# ok 2 lifecycle
# ok 3 idmap
# ok 4 mounts
# ok 5 cells
# # landlock: Landlock not enabled
# ok 6 landlock # SKIP
# # 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
# # Totals: pass:5 fail:0 xfail:0 xpass:0 skip:1 error:0
ok 1 selftests: userland: test_smoke.sh
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Yep, it's again landlock ;-)
Br, Jarkko