Repository navigation
seccomp: return from each filter match instead of a far shared return - #364
Open
congwang-mk wants to merge 1 commit into
Open
congwang-mk wants to merge 1 commit into
congwang-mk wants to merge 1 commit into
Conversation
The notif and deny lists jumped to shared return instructions at the end of the program, with the distance cast to cBPF's u8 jump offset. Once the two lists together passed 255 entries, which extra_deny_syscalls and handler syscalls can reach, the offset wrapped and a syscall meant to be notified or denied landed on an unrelated instruction and could be allowed. Each match now returns from the instruction after it, so no jump depends on the list length. Signed-off-by: Cong Wang <cwang@multikernel.io>
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.
Problem
assemble_filtersent every notif and deny match to shared return instructions at the end of the program, and cast the distance to cBPF's u8 jump offset. The first notif entry jumpsnotif + denyinstructions, so once the two lists together pass 255 entries the offset wraps. A syscall meant to be notified or denied then lands on an unrelated instruction and can be allowed.The default lists stay well under that, but
extra_deny_syscalls(including group names) and handler syscalls are caller-controlled and can reach it. The only guard was the 4096-instruction cap, which does not cover the u8 arithmetic.Fix
Each match is now a
JEQ nr,0,1; RET <action>pair, withRET ALLOWas the final fall-through. No jump distance depends on list length.The program uses two instructions per listed syscall instead of one. The 4096-instruction cap is still enforced, which now allows roughly 2000 listed syscalls.
Tests
actions_hold_past_the_u8_jump_range: 200 notif plus 200 deny syscalls evaluated through the filter interpreter, checking every action.test_default_allow_is_the_fall_throughreplaces the test that assumed three trailing returns.🤖 Generated with Claude Code