Skip to content

nfc: apple-stockholm: opt-in read-only Secure Element probe - #1180

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
sedemo/stockholm-se-probe
Nov 10, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
sedemo/stockholm-se-probe

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

This is an opt-in debugfs probe that looks inside the embedded Secure Element behind the Stockholm NFC controller. It can't change anything there. It's off unless the module is loaded with se_probe=1. Userspace decoder: aurora-se-probe (aurora-silicon/aurora-diag PR).

What it does

se_probe=1 (load time only) creates /sys/kernel/debug/apple-stockholm/<dev>/ with these files (0400, CAP_SYS_ADMIN):

file hardware what
nfcee yes VEN up, CORE_RESET/CORE_INIT, NFCEE discovery, park VEN low
se_probe yes the same; if an NFCEE takes APDUs directly: enable it if it was disabled, open a logical connection, run the fixed command table, close the connection, restore the NFCEE mode, park
apdu_allowlist no the command table

Safety

  • Commands come only from the compiled-in table: SELECT of the card manager (empty and GP/OP AIDs), GET DATA 9F7F (CPLC) / 0066 (card data) / 00E0 (key info), and SELECT probes of public AIDs (CRS, PPSE/PSE, payment networks, FIDO U2F, PIV, OpenPGP, NDEF, CCC digital key). Userspace can't supply an APDU.
  • stockholm_se_apdu_allowed() checks every command again right before it's sent, including the GET RESPONSE and corrected-Le retries the probe builds. It allows CLA 00 SELECT by DF name (P1 04, P2 00), CLA 80 GET DATA of those three tags, and GET RESPONSE, and nothing else. KUnit checks that INITIALIZE UPDATE, EXTERNAL AUTHENTICATE, INSTALL, DELETE, LOAD, PUT KEY, SET STATUS, STORE DATA, PUT DATA, VERIFY, CHANGE REFERENCE DATA, GET STATUS, MANAGE CHANNEL and GET CHALLENGE are refused, along with variants that use other classes, logical channels, secure messaging, P1/P2, tags or lengths.
  • No HCI pipe is created. HCI pipes would change controller state that macOS shares.
  • The report holds CPLC (chip serial, dates), so it's wiped on release. The userspace tool redacts it by default. Raw reports stay private.

Results

  • MacBook Neo (J700, firmware 37010160, fleet27 + this module, module swap only, no reboot, SELinux enforcing): identity line as before, then NFCEE discovery: NFCEE_DISCOVER_RSP 00 01 and one NTF, 01 01 01 01 00. That is NFCEE 0x01, the HCI network, disabled, protocol HCI access only, no TLVs. No NFCEE takes APDUs directly, so se_probe stops at apdu-nfcee none: nothing was sent to the Secure Element and nothing was enabled. VEN parked low after each run (gpio-10 out lo). Stock module restored afterwards.
  • J616s: pending (machine busy); expected to be the same.
  • buildbox: kunit.py run --arch=arm64 --kunitconfig=drivers/nfc 9/9 (4 new cases), W=1 clean, checkpatch --strict clean.

So on these Macs the eSE is reachable only through the controller's HCI network. Reading applets would mean creating an HCI pipe to the eSE's APDU gate, which writes the controller's HCI registry. This PR stops short of that on purpose. The APDU path stays for parts that offer a direct APDU NFCEE, but it hasn't run on hardware yet. Draft for review of that trade-off.

🤖 Generated with Claude Code

The controller fronts an embedded Secure Element whose card manager is
not ours. Add a way to look at it without being able to change it.

With se_probe=1 (default off, load time only) the driver creates, in
debugfs/apple-stockholm/<dev>/:

  nfcee           power up, CORE_RESET/CORE_INIT, NFCEE discovery, park
  se_probe        the same, then, if an NFCEE takes ISO 7816 APDUs
                  directly, a logical connection to it and a fixed table
                  of SELECT by name and GET DATA (CPLC, card data, key
                  information), then park
  apdu_allowlist  the command table, without touching the hardware

Commands come only from the compiled-in table. Each one, including the
GET RESPONSE and corrected-Le retries the probe builds, passes
stockholm_se_apdu_allowed() right before it is sent: CLA 00 SELECT by DF
name, CLA 80 GET DATA of tags 9F7F, 0066 and 00E0, GET RESPONSE, nothing
else. No authentication, content or key management, life-cycle or
store command can be sent; a failed GlobalPlatform authentication can
lock a card for good. An NFCEE that the probe enables is disabled again.
The files are 0400 and need CAP_SYS_ADMIN. The report is wiped on
release because CPLC carries the chip serial number.

The receive handler now also queues a copy of every packet while a probe
runs, so notifications (NFCEE discovery, connection credits) and data
packets reach the probe; outside a run nothing changes.

On the J700 (firmware 37010160) the controller reports one NFCEE, 0x01:
the HCI network, disabled, HCI access only. No NFCEE takes APDUs
directly, so se_probe stops after discovery and nothing reaches the
Secure Element. Reaching applets there would need HCI pipes, which
change controller state that macOS shares; this does not do that.

KUnit: the table passes the allowlist; INITIALIZE UPDATE, EXTERNAL
AUTHENTICATE, INSTALL, DELETE, LOAD, PUT KEY, SET STATUS, STORE DATA,
PUT DATA, VERIFY, CHANGE REFERENCE DATA, GET STATUS, MANAGE CHANNEL and
GET CHALLENGE are refused, as are SELECT and GET DATA variants with
other classes, P1/P2, tags or lengths; NFCEE protocol parsing including
the J700 notification.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 10, 2026 07:25
@RyanTheTide
RyanTheTide merged commit 1347f0f into integration/aurora Nov 10, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the sedemo/stockholm-se-probe branch November 16, 2026 05:11
term-guy added a commit to term-guy/linux that referenced this pull request Nov 22, 2026
Scanout and PIODMA share the first register window of disp0's DART, as the
J813 tree already describes it. aura's T8142 display handoff admits a
display stream only on a DART with exactly one register window: with the
second window (0x286314000) it refuses the whole handoff, the internal
panel included, and Linux stays on the boot framebuffer.

Tested on the J704 (aurora-silicon#1180: refused with two windows; aurora-silicon#1181 on: handoff
okay, internal panel on the DCP).

Signed-off-by: termg <[email protected]>
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