[Devel] [PATCH RFC hci-8.2 2/2] 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
Fri Nov 20 00:54:37 MSK 2026


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/ve: setup failure leaves cgv2_fd and pipe fds open
- [Low] selftests/ve: start_ve() leaks pipe fds on failure returns
--

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

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

This adds ve_setup_task_test. It starts a VE the way vzctl does, with ve.pseudosuper set and an init cloned from the host that writes START to ve.state. It then checks that a host task entering the VE through the ve namespace can open the init's mnt namespace, and that a binary exec'd inside the VE still cannot.

> 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..e9f8851e91724
> --- /dev/null
> +++ b/tools/testing/selftests/ve/ve_setup_task_test.c

[ ... ]

> +	/* The init: a host task cloned into the VE while it starts */
> +	*what = "clone3";
> +	if (enter_cgroup(self->cgv2_fd, self->ctid) < 0)
> +		return -1;
> +	self->init_pid = syscall(__NR_clone3, &cargs, sizeof(cargs));
> +	if (self->init_pid == 0)
> +		run_init(self, status, release);
> +	close(status[1]);
> +	close(release[0]);
> +	self->init_release = release[1];
> +	if (enter_cgroup(self->cgv2_fd, 0) < 0 || self->init_pid < 0)
> +		return -1;
> +
> +	*what = "ve.state START";
> +	if (read(status[0], &c, 1) != 1)
> +		return -1;
> +	close(status[0]);
> +	if (c) {
> +		errno = c;
> +		return -1;
> +	}

[Severity: Low]
Do these early returns leak the pipe descriptors? If clone3() fails,
init_pid is -1 and start_ve() returns with release[1] stored in
init_release. stop_ve() closes init_release only when init_pid > 0, so
release[1] is never closed. If the read of status[0] fails, status[0]
is not closed either. The process is short-lived, so the effect is
small, but closing both descriptors on the failure paths would keep
the error handling tidy.

[ ... ]

> +	/* The harness skips the teardown when the setup fails */
> +	ret = start_ve(self, &what);
> +	err = errno;
> +	if (ret)
> +		stop_ve(self);
> +	ASSERT_EQ(ret, 0) TH_LOG("%s: %s", what, strerror(err));

[Severity: Low]
Does this failure path leak self->cgv2_fd? As the comment says, the
harness skips FIXTURE_TEARDOWN when setup fails. Only stop_ve() runs
here, and it never closes cgv2_fd. The close(self->cgv2_fd) sits only
in FIXTURE_TEARDOWN. Closing cgv2_fd in this error branch after
stop_ve() would fix it.

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/20261119-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v1-0-06fa0b8994a8@virtuozzo.com?part=2



More information about the Devel mailing list