Skip to content

soc: apple: sep: rate-limit request-path log messages - #1578

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
seprl/sep-log-ratelimit-v2
Nov 11, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
seprl/sep-log-ratelimit-v2

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Anyone who can open /dev/sep-key or /dev/sep-bio can make apple_sep refuse a request as often as they like, and most refusals printed a kernel log line. On fleet64, the sep-ioctl-fuzz.py run (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 _ratelimited forms, so this adds drivers/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 the xarm_trace=1 trace keep the plain macros. Return codes and request handling are unchanged.

tools/aurora-sep/tests/test_log_ratelimit.py fails 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) with apple_sep.key_selftest=1. The rows are the same ones run on fleet64:

fleet64 (same rows) this PR
kernel -p 4 lines added by nofinger + pinprobe v4 + fuzz 727 (4 → 731) 16 (6 → 22), all userspace PINPROBE markers; 0 from apple_sep
apple_sep warnings or worse ~700 0
kernel lines added by the fuzz phase ~3600 (M1 Pro, fuzz alone) 0
all apple_sep lines across the three phases n/a 67, mostly self-test output enabled by key_selftest=1
  • fidohw-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.
  • SELinux enforcing, 0 AVC, 0 SEP kernel errors, 0 failed units.

Local gates (buildbox):

  • SEP source job: every python3 -m unittest command in sep-source.yml passes, including the new test (5/5). The new test fails 5/5 on the base.
  • Full tools/aurora-sep/tests discover: 1072 tests. The same 2 failures and 8 errors happen on the base (1067 tests), so nothing new.
  • KUnit apple_sep* (arm64 QEMU, LLVM=1, sep.kunitconfig): 539 run, 537 pass, 2 skip. The new apple_sep_ratelimit suite passes 5/5.
  • tools/asahi/run-host-tests.py: 224/224.
  • Full arm64 kernel build (fleet config): no new warnings under drivers/soc/apple. checkpatch reports no errors.

🤖 Generated with Claude Code

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]>
@RyanTheTide
RyanTheTide merged commit aeccd86 into integration/aurora Nov 11, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the seprl/sep-log-ratelimit-v2 branch November 11, 2026 18:51
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.

1 participant