Skip to content

runtime: tolerate vendor suffixes in Linux kernel release strings#170

Merged
bradfitz merged 1 commit into
tailscale.go1.26from
bradfitz/underscore
May 27, 2026
Merged

runtime: tolerate vendor suffixes in Linux kernel release strings#170
bradfitz merged 1 commit into
tailscale.go1.26from
bradfitz/underscore

Conversation

@bradfitz

@bradfitz bradfitz commented May 22, 2026

Copy link
Copy Markdown
Member

Synology kernels can have a "_" in their uname version. Make the
parsing more tolerant. And also don't throw during init if we fail to
parse the kernel version. Instead, fall back to probing. (We can't
probe all the time, because seccomp filters on some platforms like
Android kill the process if we call a verbotenen system call)

This regressed in CL 758902 (forked from CL 751340) on 2026-03-24,
which started calling parseRelease unconditionally during osinit on
32-bit Linux.

Updates golang#79612

Updates #162
Updates tailscale/tailscale#6860

Change-Id: I98f61b94e54c7b9d08029f3aef664bdda9ec7f69
(cherry picked from commit dc6ef1e053c22ff9736f944e737bfc8015bd30ab
patchset 4 of https://go-review.googlesource.com/c/go/+/781800)

@bradfitz bradfitz requested review from cmol and creachadair May 22, 2026 04:15

@creachadair creachadair 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.

Just one non-blocking nit.

Comment thread src/runtime/os_linux.go Outdated
// elided.
func parseRelease(rel string) (major, minor, patch int, ok bool) {
// Strip anything after a dash or plus.
// Strip anything after a dash, plus, or underscore. Some

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.

The change seems fine, but we no longer actually follow semver grammar, strictly speaking (to be fair, Synology et al. started it). Maybe note this in the doc comment above? E.g.,

// parseRelease parses a dot-separated version number.
// It follows semver syntax, but allows the minor and patch
// versions to be elided, and accepts "_" as a separator for
// pre-release labels in addition to "-".

or words to that effect.

(Likewise we don't handle build labels either, though if we got one of those on a kernel release we probably have bigger issues 😅)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Strictly speaking, this code from Go (which is like 10 years old) never did semver... it also parse "4.5" without a patch.

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.

Yeah, I don't think we need to match the spec, my comment was mostly just about updating the comment. But it's unexported, so certainly not essential.

@bradfitz bradfitz force-pushed the bradfitz/underscore branch from ca0927e to f8637b7 Compare May 27, 2026 16:26
… strings

Synology kernels can have a "_" in their uname version. Make the
parsing more tolerant. And also don't throw during init if we fail to
parse the kernel version. Instead, fall back to probing. (We can't
probe all the time, because seccomp filters on some platforms like
Android kill the process if we call a verbotenen system call)

This regressed in CL 758902 (forked from CL 751340) on 2026-03-24,
which started calling parseRelease unconditionally during osinit on
32-bit Linux.

Updates golang#79612

Updates #162
Updates tailscale/tailscale#6860

Change-Id: I98f61b94e54c7b9d08029f3aef664bdda9ec7f69
(cherry picked from commit dc6ef1e053c22ff9736f944e737bfc8015bd30ab
 patchset 4 of https://go-review.googlesource.com/c/go/+/781800)
@bradfitz bradfitz force-pushed the bradfitz/underscore branch from f8637b7 to 7104161 Compare May 27, 2026 16:27
@bradfitz bradfitz changed the title runtime: handle underscore in Linux kernel release strings runtime: tolerate vendor suffixes in Linux kernel release strings May 27, 2026
@bradfitz bradfitz merged commit 7104161 into tailscale.go1.26 May 27, 2026
4 checks passed
@bradfitz bradfitz deleted the bradfitz/underscore branch May 27, 2026 16:59
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.

3 participants