Repository navigation
soc: apple: sep: rate-limit request-path log messages - #1578
Merged
Merged
Conversation
Anyone who can open /dev/sep-key or /dev/sep-bio can make the driver
refuse a request as often as they like, and most refusals printed a
line. The sep-key request fuzzer (3000 rounds of malformed SIGN
records) added about 3600 kernel log lines on an M1 Pro, 660 of them
at warning level ("sks: ref-key sign refused by the enclave"), which
buries real warnings and lets a caller fill the log.
Add ratelimit.rs with per-call-site rate limiting for Rust code, since
the Rust print macros have no _ratelimited forms:
- dev_*_ratelimited! / pr_*_ratelimited! match the C helpers: 10
messages per 5 s per call site, then "N similar messages
suppressed" when the site prints again.
- dev_info_refusal! prints one info line per call site per minute.
It covers an expected refusal of something the caller supplied: a
ref-key record or sealed blob the enclave refuses, a wrong password,
a locked or foreign user bag, and Touch ID verifies refused while
Touch ID waits for a password.
Messages in the modules that run on request paths now use these macros.
Driver, firmware and transport failures keep their level but are
rate-limited. Per-request narrative of normal operation (touch waits,
cancels, sealed/unsealed sizes, LOAD_KEYBAG and ref-key mailbox status)
moves to dev_dbg!. A nonzero status from the ref-key identity unlock,
which was only visible in the removed info line, now gets its own
rate-limited warning. The two SMC rail errors in the sensor shim and
the p256 helper errors are rate-limited too. Probe-only modules (dt,
shmem, profile) and the xarm_trace=1 trace keep plain messages. No
return code or request handling changes.
KUnit suite apple_sep_ratelimit covers the limiter. The new source
test test_log_ratelimit.py fails on any plain message in a request-path
module, and the SEP source workflow runs it. The source tests that
compile driver excerpts get stubs for the new macros.
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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.
Anyone who can open
/dev/sep-keyor/dev/sep-biocan make apple_sep refuse a request as often as they like, and most refusals printed a kernel log line. On fleet64, thesep-ioctl-fuzz.pyrun (3000 rounds) added about 3600 kernel lines on an M1 Pro. 658 of them were warnings (sks: ref-key sign refused by the enclave), and the rest were per-request info lines (LOAD_KEYBAG and ref-key mailbox status). That buries real warnings and lets a caller fill the log.The Rust print macros have no
_ratelimitedforms, so this addsdrivers/soc/apple/ratelimit.rs:dev_*_ratelimited!/pr_*_ratelimited!work like the C helpers: each call site gets 10 messages per 5 s, then logs "N similar messages suppressed" the next time it prints.dev_info_refusal!prints one info line per call site per minute. It is for expected refusals of something the caller supplied: a ref-key record or sealed blob the enclave refuses, a wrong password, a locked or foreign user bag, or a Touch ID verify refused while Touch ID waits for a password.The modules on request paths now log through these macros. Driver, firmware and transport failures keep their level and are rate-limited. Per-request narrative moves to
dev_dbg!. A nonzero status from the ref-key identity unlock used to show only in an info line that is now gone, so it gets its own rate-limited warning. Probe-only modules (dt, shmem, profile) and thexarm_trace=1trace keep the plain macros. Return codes and request handling are unchanged.tools/aurora-sep/tests/test_log_ratelimit.pyfails if a request-path module uses a plain message macro, and the SEP source workflow now runs it. The source tests that compile driver excerpts get stubs for the new macros.Results
Test kernel
7.3.0-aurora-seprl1= integration/aurora 716670b + this commit, one-shot boot on an M2 (J413) withapple_sep.key_selftest=1. The rows are the same ones run on fleet64:-p 4lines added by nofinger + pinprobe v4 + fuzzPINPROBEmarkers; 0 from apple_sepkey_selftest=1fidohw-row.py nofinger: 0 failed.aurora-sep status: PASS (23 pass, 1 warn, 0 fail).pinprobe.py v4: 10 pass, 0 fail.sep-ioctl-fuzz.py(3000 rounds): 7965 checks, 0 failed.Local gates (buildbox):
python3 -m unittestcommand insep-source.ymlpasses, including the new test (5/5). The new test fails 5/5 on the base.tools/aurora-sep/testsdiscover: 1072 tests. The same 2 failures and 8 errors happen on the base (1067 tests), so nothing new.apple_sep*(arm64 QEMU, LLVM=1,sep.kunitconfig): 539 run, 537 pass, 2 skip. The newapple_sep_ratelimitsuite passes 5/5.tools/asahi/run-host-tests.py: 224/224.drivers/soc/apple. checkpatch reports no errors.🤖 Generated with Claude Code