Support per-rule actions and SECCOMP_FILTER_FLAG_NEW_LISTENER loading#99
Open
lu-zero wants to merge 2 commits into
Open
Support per-rule actions and SECCOMP_FILTER_FLAG_NEW_LISTENER loading#99lu-zero wants to merge 2 commits into
lu-zero wants to merge 2 commits into
Conversation
|
I like the idea of being able to specify specific actions for different rules but I think this commit is overloaded with too many disparate changes. Please split the work. |
SeccompRule gains an optional per-rule action overriding the filter's match_action (None preserves existing behavior). Adds new_with_action and always constructors; append_syscall_chain emits the rule's own RET. validate() is relaxed: a condition-less rule is valid iff it carries an action. This is the core feature split out of the combined per-rule-actions + NEW_LISTENER change; the UserNotif-specific loader follows separately. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
|
Please make the CI pass. |
Installs a filter with NEW_LISTENER (Linux 5.0+) and returns the listener fd as an OwnedFd, making SeccompAction::UserNotif usable. Separate from apply_filter_with_flags because the seccomp(2) rc contract differs: a positive rc is the listener fd, not a TSYNC-offending tid. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Author
|
It should be fine now |
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.
Summary
Make
SeccompAction::UserNotif(added in #95) usable in hybrid filters,where different syscalls take different actions in one filter.
SeccompFilterapplies a single
match_actionto every rule today; this adds per-rule actionsand a loader for
SECCOMP_FILTER_FLAG_NEW_LISTENER.Motivated by fakeroost#7,
which routes
statthrough aUSER_NOTIFpool while keeping writes onTRACE—previously requiring hand-rolled BPF. Reference port:
fakeroost#8.
Relationship to #75
#75 (colinmarc, stalled since Apr 2025) adds a
Notifyvariant + a loader butnot per-rule actions — it can't express "syscall A → Notify, syscall B → Trace"
in one filter, which is the gap this PR fills. #95 already merged
UserNotifunconditionally, superseding #75's feature-gated
Notify. Our loader(
apply_filter_with_listener) overlaps #75'sapply_filter_with_notify_fd; happyto adopt that name if preferred.
Changes
SeccompRulegainsaction: Option<SeccompAction>;Nonefalls back to thefilter's
match_action(existing usage unchanged). New constructorsnew_with_action(conditions + action) andalways(unconditional). Firstmatching rule wins;
append_syscall_chainemits the rule's ownRET.validate()relaxed: a condition-less rule is valid iff it carries an action.apply_filter_with_listener() -> Result<OwnedFd>installs withNEW_LISTENER(Linux 5.0+) and returns the listener fd. Separate from
apply_filter_with_flags(rc contract differs: positive rc = fd, not TSYNC).new_with_action(vec![], ..)now returnsErr(EmptyRule)— previously itsilently behaved like
always.SeccompAction::UserNotifis intentionally unit: the kernel ignores thereturn-data bits for
SECCOMP_RET_USER_NOTIF, so au32would be a tag itdiscards (unlike
Errno/Trace). Seedocs/design-per-rule-actions.md.Testing
New unit + integration tests for the above; 36 tests / 5 suites pass,
clippy -D warningsclean,fmtclean. fakeroost's integration suite passeson this branch (#8).
Open questions (none block this draft)
IdenticalActionsis over-strict when every rule overrides.actionfield yet (non-breaking).libc(#5224); a high-level
supervisor API would be a separate crate.
Draft to gather feedback — especially on reconciling with #75 — before
finalizing.