fix(exec): fix seccomp build on armv7 with i32-to-i64 syscall cast#8869
fix(exec): fix seccomp build on armv7 with i32-to-i64 syscall cast#8869
Conversation
On 32-bit armv7, libc::SYS_* constants are i32 but the BTreeMap key type is i64, causing a type mismatch compile error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes a compile error on armv7 targets by casting Confidence Score: 5/5Safe to merge — single-line widening cast is correct and does not affect runtime behaviour on any currently supported architecture. The change is a minimal, correct fix: No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[apply_seccomp_net_filter] --> B[prctl: PR_SET_NO_NEW_PRIVS]
B --> C{arch?}
C -->|x86_64| D[TargetArch::x86_64]
C -->|aarch64| E[TargetArch::aarch64]
C -->|other e.g. armv7| F[Return Error: unsupported arch]
D --> G[Build SeccompRules for AF_INET / AF_INET6]
E --> G
G --> H[Insert syscall as i64 into BTreeMap]
H --> I[SeccompFilter::new]
I --> J[BpfProgram::try_into]
J --> K[seccompiler::apply_filter]
K --> L[Filter active: SYS_socket / SYS_socketpair blocked for inet families]
Reviews (1): Last reviewed commit: "fix(exec): fix seccomp build on armv7 wi..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request updates the seccomp network filter in src/sandbox/seccomp.rs by casting syscall constants to i64 to ensure type compatibility. While this change addresses compilation issues on 32-bit architectures, feedback suggests that additional configuration is required in the architecture matching logic to prevent runtime errors on ARM platforms.
| for syscall in [libc::SYS_socket, libc::SYS_socketpair] { | ||
| rules.insert( | ||
| syscall, | ||
| syscall as i64, |
There was a problem hiding this comment.
While this cast fixes the compilation error on 32-bit ARM architectures, the apply_seccomp_net_filter function will still return an error at runtime on armv7 because the architecture is not handled in the match block at line 24. To fully support armv7, you should also add "arm" => TargetArch::arm to that match block.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.1 x -- echo |
24.4 ± 1.5 | 22.6 | 47.2 | 1.04 ± 0.08 |
mise x -- echo |
23.5 ± 0.8 | 21.9 | 28.1 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.1 env |
21.8 ± 0.6 | 21.0 | 27.7 | 1.00 |
mise env |
22.6 ± 0.7 | 21.4 | 29.2 | 1.04 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.1 hook-env |
23.2 ± 2.7 | 21.6 | 54.6 | 1.00 |
mise hook-env |
26.8 ± 5.4 | 23.5 | 59.0 | 1.15 ± 0.27 |
hook-env is 15% |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.1 ls |
23.1 ± 4.8 | 20.5 | 51.9 | 1.00 |
mise ls |
24.2 ± 4.5 | 21.6 | 52.3 | 1.05 ± 0.29 |
xtasks/test/perf
| Command | mise-2026.4.1 | mise | Variance |
|---|---|---|---|
| install (cached) | 166ms | 162ms | +2% |
| ls (cached) | 89ms | 83ms | +7% |
| bin-paths (cached) | 93ms | 90ms | +3% |
| task-ls (cached) | 831ms | 864ms | -3% |
Summary
libc::SYS_*constants arei32but theBTreeMap<i64, ...>key expectsi64as i64cast which is a no-op on 64-bit and a widening conversion on 32-bitTest plan
🤖 Generated with Claude Code
Note
Low Risk
Low risk compile-time fix that only widens syscall IDs when inserting seccomp rules, primarily affecting 32-bit (e.g., armv7) builds.
Overview
Fixes a type mismatch in the seccomp network filter by casting
libc::SYS_socket/libc::SYS_socketpairtoi64when inserting into theBTreeMap<i64, ...>rule map.This restores builds on 32-bit targets where
libc::SYS_*constants arei32, without changing the intended seccomp behavior on 64-bit platforms.Written by Cursor Bugbot for commit 6ecd24c. This will update automatically on new commits. Configure here.