Repository navigation
Conversation
Some kernels separate their vendor suffix from the version with a "."
rather than a "-". For instance, the Azure Linux guest kernel used by
AKS Pod Sandboxing (Kata Containers) reports "6.18.52.mshv1-2.azl3".
Previously we only stripped the suffix at the first character that was
neither a digit nor a ".", which left a trailing empty component
("6.18.52.") that failed to parse, causing host_kernel_version() to
panic and runc to abort container startup.
So, also treat a "." followed by a letter as the start of the suffix.
Other stray dots ("42.12.", "4.10.-default", "1..3") are still rejected
as malformed.
Fixes cyphar#471
Signed-off-by: Alexej Disterhoft <alexej@disterhoft.de>
cyphar
reviewed
Nov 22, 2026
Comment on lines
129
to
136
| let kver = kver_str | ||
| .split('.') | ||
| .map(|num| match num { | ||
| "" => None, // version components must be non-empty | ||
| _ => num.parse().ok(), // version components must be valid numbers | ||
| }) | ||
| .collect::<Option<Vec<_>>>() | ||
| .map(KernelVersion); |
Owner
There was a problem hiding this comment.
I think a better solution would be to still dot-split the version and just cut it off at the first invalid component instead of making the split-determination more complicated. I'll push a version of this (as well as a patch that removes the stupid expect that triggered the crash).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #471.
Summary
parse_kernel_versioncut the release string at the first character that was neither a digit nor., so6.18.52.mshv1-2.azl3(Azure Linux guest kernel on AKS Pod Sandboxing / Kata) became6.18.52.and failed on the empty trailing component.host_kernel_version()then panics and runc aborts container startup.Stray dots that the existing tests reject on purpose (
42.12.,4.10.-default,1..3) are still rejected.Evidence
New test
parse_kernel_version_with_dot_suffix, run inrust:1.99-trixie:cargo test --lib utils::kernel_version→15 passed; 1 failed(parse_kernel_version_with_dot_suffix)After:
16 passed; 0 failed;cargo fmt --checkandcargo clippy --all-targetsclean.Merge Danger
Door: two-way
Blast Radius: narrow
Only changes which release strings parse; strings that parsed before give the same result. Releases of the form
X.Y.Z.<letter>…now parse instead of panicking.