Skip to content

seccomp sandbox: allow uname(3)#605

Closed
Icenowy wants to merge 1 commit intoopenssh:masterfrom
Icenowy:seccomp-allow-uname
Closed

seccomp sandbox: allow uname(3)#605
Icenowy wants to merge 1 commit intoopenssh:masterfrom
Icenowy:seccomp-allow-uname

Conversation

@Icenowy
Copy link
Copy Markdown
Contributor

@Icenowy Icenowy commented Nov 7, 2025

The uname(3) syscall is utilized by zlib-ng on RISC-V to decide whether the kernel handles VILL bit of V extension properly (by checking the kernel version against 6.5).

Allow it in the seccomp sandbox.

The uname(3) syscall is utilized by zlib-ng on RISC-V to decide whether
the kernel handles VILL bit of V extension properly (by checking the
kernel version against 6.5).

Allow it in the seccomp sandbox.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
ziyao233 added a commit to ziyao233/zlib-ng that referenced this pull request Nov 8, 2025
Previously, RVV/Zbc is used when

- Linux kernel version (detected by uname(2)) is greater or equal to
  6.5, and HWCAP claims support for such extension, or
- Linux kernel version is less than 6.5, but compiler claims support for
  the extension

and for RVV, we additionally check whether it's (the earlier, draft)
v0.7.1 release or the (the later, ratified) v1.0 release. Zlib-ng only
supports v1.0.

This strategy is problematic in several aspects,

- Fallback to compile-time constants with Linux kernel earlier than 6.5
  makes it hard for distributions to ship the same binary for different
  machines with different kernel versions.
- Detecting Linux kernel version through uname(2) could violate sandbox
  enforcement[1].

And since RVV introduces special vector registers, RVV usage in
userspace relies on the kernel to implement proper context switching,
which is only present since Linux kernel 6.5, which is also the version
when COMPAT_HWCAP_ISA_V was introduced. This makes it reasonable to only
do HWCAP-based extension detection for RVV.

The additional check for RVV version is also unnecessary since in
mainline Linux kernel, COMPAT_HWCAP_ISA_V is only set when a ratified
v1.0 implementation of RVV is present. A downstream kernel claiming
COMPAT_HWCAP_ISA_V with a v0.7.1 RVV implementation breaks the kABI,
and userspace shouldn't pay for the mistake.

This patch removes extra detection logic, now RVV is and only is used
when the kernel claims COMPAT_HWCAP_ISA_V. The detection logic of Zbc
checks an undefined HWCAP bit, thus doesn't detect Zbc correctly with
any current Linux kernel, which should be fixed with another patch.

Fixes: 6ff8b52 ("Support RVV hwcap detect at runtime")
Link: openssh/openssh-portable#605 # [1]
Closes: zlib-ng#1705
Closes: zlib-ng#1769
Signed-off-by: Yao Zi <ziyao@disroot.org>
@djmdjm
Copy link
Copy Markdown
Contributor

djmdjm commented Nov 25, 2025

Merged as ec41739 - thanks

@djmdjm djmdjm closed this Nov 25, 2025
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.

2 participants