Skip to content

Fix race condition in create_v2_cgroup#166

Open
burgerdev wants to merge 2 commits into
kata-containers:mainfrom
burgerdev:fix-cgroup-create-race
Open

Fix race condition in create_v2_cgroup#166
burgerdev wants to merge 2 commits into
kata-containers:mainfrom
burgerdev:fix-cgroup-create-race

Conversation

@burgerdev

Copy link
Copy Markdown

There used to be a race condition while creating the cgroup hierarchy: if a parent directory was created after .exists() but before .create_dir, the function failed unnecessarily.

This commit changes the function to use create_dir_all, which is the atomic variant of the above pattern, and fixes some surrounding docstrings on the way.

This should fix kata-containers/kata-containers#12176

There used to be a race condition while creating the cgroup hierarchy:
if a parent directory was created after .exists() but before
.create_dir, the function failed unnecessarily.

This commit changes the function to use create_dir_all, which is the
atomic variant of the above pattern, and fixes some surrounding
docstrings on the way.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
@burgerdev burgerdev requested review from Apokleos and fidencio June 16, 2026 07:10
Some dependencies require a newer Rust version.

Signed-off-by: Markus Rudy <mr@edgeless.systems>

@fidencio fidencio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @burgerdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime-rs/cloud-hypervisor: Issue tacking for cgroup

2 participants