Skip to content

kver: more resilient version handling - #473

Open
cyphar wants to merge 2 commits into
mainfrom
kver-resilience
Open

cyphar wants to merge 2 commits into
mainfrom
kver-resilience

Conversation

@cyphar

@cyphar cyphar commented Nov 22, 2026

Copy link
Copy Markdown
Owner

It's really quite extreme to panic if the host kernel version is
unknown because in libpathrs we have all sorts of fallbacks for older
kernel versions. A much simpler approach is to treat an unknown kernel
version as being some impossibly ancient kernel and thus enable all
compatibility workarounds.


Some systems have really funky kernel versions like 5.4.0.custom which
would previously be treated as completely invalid version strings by
libpathrs.

Given that kernel builders have a lot of freedom to pick all sorts of
whacky release version schemes we should take a more permissive approach
and just accept any dot-separated digits at the start of the version as
the version string. Once we hit a non-digit or otherwise invalid
component we truncate any later dot-separated digits (meaning that
3.1..5 will be treated as 3.1).

This should make us more resilient to weird cases.

Fixes #471
Closes #472
Reported-by: Alexej Disterhoft alexej@disterhoft.de
Signed-off-by: Aleksa Sarai cyphar@cyphar.com

@cyphar

cyphar commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

@nobbs PTAL?

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utils/kernel_version.rs 97.36% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

It's really quite extreme to panic if the host kernel version is
unknown because in libpathrs we have all sorts of fallbacks for older
kernel versions. A much simpler approach is to treat an unknown kernel
version as being some impossibly ancient kernel and thus enable all
compatibility workarounds.

(Ideally we would also log something but we don't do logging from
libpathrs yet so instead we just pick an obviously fake version number
-- 0.99.1234 -- that hopefully shows up in a log somewhere.)

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Some systems have really funky kernel versions like "5.4.0.custom" which
would previously be treated as completely invalid version strings by
libpathrs.

Given that kernel builders have a lot of freedom to pick all sorts of
whacky release version schemes we should take a more permissive approach
and just accept any dot-separated digits at the start of the version as
the version string. Once we hit a non-digit or otherwise invalid
component we truncate any later dot-separated digits (meaning that
"3.1..5" will be treated as "3.1").

This should make us more resilient to weird cases.

Reported-by: Alexej Disterhoft <alexej@disterhoft.de>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
@nobbs

nobbs commented Nov 22, 2026

Copy link
Copy Markdown

@cyphar Thanks! Confirmed 6.18.52.mshv1-2.azl3 now parses as 6.18.52.

This branch has not been deployed

No deployments
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.

Kernel version parsing rejects releases with a dot before the vendor suffix

2 participants