[Devel] [PATCH hci-8.2 v5 3/3] selftests/ve: check a host task entering a pseudosuper VE reaches its init

no-reply at sashiko.virtuozzo.com no-reply at sashiko.virtuozzo.com
Tue Dec 1 04:02:32 MSK 2026


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/ve: run_init() may report START success after a failed
  write
- [Low] selftests/ve: negative test accepts any EACCES, not just the
  setup-task denial
--

commit d1314e3bf7a94b2e7ca6d3ca90983fd9dc1e00b8
Author: Konstantin Khorenko <khorenko at virtuozzo.com>

selftests/ve: check a host task entering a pseudosuper VE reaches its init

This adds a selftest that starts a VE the way libvzctl does, with ve.pseudosuper set and an init cloned from the host. It then checks that a host task entering the VE reaches the init, and that a binary exec'd inside the VE does not.

> diff --git a/tools/testing/selftests/ve/ve_setup_task_test.c b/tools/testing/selftests/ve/ve_setup_task_test.c
> new file mode 100644
> index 0000000000000..66423f9f4a17f
> --- /dev/null
> +++ b/tools/testing/selftests/ve/ve_setup_task_test.c

[ ... ]

> +static void run_init(FIXTURE_DATA(ve_setup_task) * self, int status[2],
> +		     int release[2])
> +{
> +	char c;
> +
> +	prctl(PR_SET_PDEATHSIG, SIGKILL);
> +	close(status[0]);
> +	close(release[1]);
> +	c = ve_write(self, "ve.state", "START") ? errno : 0;

[Severity: Low]
Can this report success after a failed START write? write_file_at() returns -1 on a short write without setting errno. In that case c gets a stale or zero errno, and the parent treats the start as successful. The later ve.state check still fails the test, but with a misleading EINVAL instead of the real error.

[ ... ]

> +TEST_F(ve_setup_task, exec_in_ve_does_not_reach_init)
> +{

[ ... ]

> +	ASSERT_EQ(waitpid(p, &status, 0), p);
> +	ASSERT_TRUE(WIFEXITED(status));
> +	ASSERT_NE(WEXITSTATUS(status), 254);
> +	EXPECT_EQ(WEXITSTATUS(status), EACCES)
> +		TH_LOG("open of the init's mnt namespace: %s",
> +		       strerror(WEXITSTATUS(status)));

[Severity: Low]
Is this negative check specific enough? Any EACCES from the exec'd probe passes the test, whatever the cause. The proc ns get_link path returns -EACCES whenever ptrace_may_access() fails. That covers the uid/gid/capability checks, task_still_dumpable() and LSM hooks, so the errno does not identify the setup-task rule.

Would a control help, such as clearing ve.pseudosuper and checking that the same exec'd open then succeeds?

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-0-32c4b6342ec2@virtuozzo.com?part=3



More information about the Devel mailing list