Skip to content

Publish the T2 SEP boot state through macsmc on Linux 7.3+ - #26

Open
mgodwin wants to merge 2 commits into
macintog:mainfrom
mgodwin:macsmc-boot-state
Open

mgodwin wants to merge 2 commits into
macintog:mainfrom
mgodwin:macsmc-boot-state

Conversation

@mgodwin

@mgodwin mgodwin commented Nov 16, 2026

Copy link
Copy Markdown

Summary

On Linux 7.3 T2 kernels, the installer can't satisfy the applesmc boot-state prerequisite, so fresh installs stop before any product setup. This PR moves the one-shot EFMV/EFMS/EFBS boot-state transaction to userspace, through the macsmc /dev/smc interface. It also fixes a /run/t2-touchid permission bug found during the same install.

Two commits, which can be reviewed or merged separately:

  1. cfeb917 Keep /run/t2-touchid root-private on Linux-native installs: 2 files, +6 lines. This applies to any kernel.
  2. ec22e05 Publish the T2 SEP boot state through macsmc on Linux 7.3+: 8 files.

Problem

macsmc replaces applesmc. Linux 7.3 removed struct acpi_driver and acpi_bus_register_driver(). T2 kernels (seen on linux-t2 7.3.4) now bind the SMC (APP0001:00) to the macsmc MFD stack: macsmc-acpi, -hwmon, -power, -rtc and -wdt. Effects:

  • packaging/applesmc-t2touch fails to compile ('struct acpi_driver' has no member named 'drv', implicit acpi_bus_register_driver).
  • Even a ported applesmc would contend with macsmc-acpi for the same device. On this machine, macsmc also supplies the battery and AC power_supply devices.
  • The prerequisite gate therefore cannot pass, and installation stops at applesmc-t2touch DKMS build failed.

/run/t2-touchid is world-readable on fresh Linux-native installs.

  • install -d -m 0700 /run/t2-touchid/workers applies the mode only to the leaf directory, so the parent is created 0755.
  • t2-keybag-load.sh is the only other creator of the parent as 0700, and it is disabled in Linux-native mode.
  • fprintd.service's RuntimeDirectory=t2-touchid/workers also creates the parent as 0755 at boot.
  • As a result, t2-native-first-run.service stops with replacement runtime directory is not root-private.

Change

Boot-state publisher (macsmc kernels only)

  • src/t2-smc-boot-state.c runs the same transaction as linux_native/patches/applesmc-t2-sep-boot-state.patch, through the IOCTL_SMC_GET_KEY_INFO, IOCTL_SMC_READ and IOCTL_SMC_WRITE ioctls on /dev/smc:
    • It checks the key sizes (EFMV 32 bytes, EFMS 1, EFBS 1) and requires a pristine EFMV (fe followed by zeros).
    • It parses the bridgeOS version from the DMI BIOS string with the same format as the patch.
    • It clears EFMS, commits EFBS 0x11, then polls EFMS for up to 40 s.
    • It records the result in the existing vocabulary (response-received:N, rejected, failed, commit-uncertain, not-applicable) at /run/t2touch/t2_sep_boot_state.
    • It runs at most once per boot, using a lock plus that result file. A commit-uncertain result is never retried.
    • --probe is read-only.
    • The epoch defaults to 1.0. T2_TOUCHID_SEP_EPOCH_MAJOR and T2_TOUCHID_SEP_EPOCH_MINOR from /etc/t2-touchid.conf override it.
  • systemd/system/t2-smc-boot-state.service is a oneshot ordered before t2-sep-transport.service and t2-biometric-port-refresh.service.
    • Its sandbox is DevicePolicy=closed with only /dev/smc allowed, no capabilities, PrivateNetwork=yes, and RuntimeDirectory=t2touch (preserved).
    • It has no [Install] section.
  • udev/90-t2-smc-boot-state.rules starts the unit when /dev/smc appears.
    • A unit-level device dependency is not usable: misc devices are not tagged for systemd, so dev-smc.device never activates, and a dependency on it would time out.
    • On applesmc kernels the rule never matches, so there is no boot delay.
  • tools/installer-kernel.sh:
    • macsmc_active requires a character device at /dev/smc and macsmc-acpi bound to APP0001:*.
    • When it is active, ensure_applesmc_on_disk installs the helper, unit and udev rule instead of staging applesmc DKMS.
    • The absent path skips enable_applesmc_next_boot.
    • applesmc_boot_result also reads the userspace result. If both a sysfs result and the userspace result are present, the outcome is ambiguous, which fails closed as before.
  • install.sh: on macsmc kernels it does not write the applesmc options/softdep file. That softdep would make modprobe t2_sep_transport pull the in-tree applesmc in next to macsmc.
  • applesmc kernels are unchanged.

Permissions fix

  • install.sh creates /run/t2-touchid as 0700, and chmods it if it already exists, before creating workers.
  • systemd/tmpfiles.d/t2-touchid.conf adds d /run/t2-touchid 0700 root root -.

Files T2Touch now owns

  • /usr/local/sbin/t2-smc-boot-state
  • /etc/systemd/system/t2-smc-boot-state.service
  • /etc/udev/rules.d/90-t2-smc-boot-state.rules
  • /run/t2touch/t2_sep_boot_state (runtime)
  • the /run/t2-touchid mode, via the existing tmpfiles file

uninstall.sh removes the first three and reloads udev. It also removes the sysinit.target.wants link that an intermediate revision of this branch created. Reinstalling overwrites only these files.

Hardware risk

Kernel/SMC boundary, writes. The helper writes the same three SMC keys, with the same values and preconditions, as the existing applesmc patch, through a different driver. It writes nothing unless EFMV is pristine. On failure it records a status, and boot continues.

Tests

  • Unit tests:
    • python3 -m unittest tests.test_installer tests.test_installer_kernel: 50 tests OK.
    • The gate harness now stubs macsmc_active and ensure_macsmc_publisher, so the tests stay hermetic on macsmc hosts. Before this change they failed there.
    • New coverage: the macsmc absent → install publisher → stop path, macsmc response → continue without applesmc staging, publisher install failure blocking readiness, detection needing both the device node and the bound driver, and reading the userspace result (including ambiguous when the sysfs attribute is also present).
  • Full suite: python3 -m unittest discover -s tests, 1502 tests. The same 27 errors occur on the unmodified base 5934b05; they come from Python dependencies absent outside the venv. No new failures.
  • Other checks:
    • tools/privacy-check.sh and enrollment_research/scripts/check-public-tree.sh pass.
    • systemd-analyze verify and udevadm verify pass.
    • The helper builds with the project's -Werror hardening flags.
  • Not run: ShellCheck (not installed on the test host).

Hardware observations

Platform: MacBookPro15,1 (J680AP), bridgeOS 23.16.15067.0.0,0, linux-t2 7.3.4-arch1-2, Omarchy, Linux-only (no Apple partitions), fresh install, T2_TOUCHID_AUTHORITY_MODE=linux-native.

  1. t2-smc-boot-state --probe (read-only): EFMV is 32 bytes with flags 0xc4, EFMS is 1 byte (ui8, 0xc0), EFBS is 1 byte (ui8, 0xd0). EFMV read fe 00… (pristine).
  2. Publish: response-received:1.
    • The first boot attempt failed at 226/NAMESPACE because of a ReadWritePaths= on a missing /run/t2touch; this is fixed by RuntimeDirectory=. That failure happened before the helper executed, and a re-probe confirmed EFMV was still pristine before publishing.
    • The first success was started by hand in the same boot (systemctl start) after that fix.
    • Boot path confirmed on a later cold boot: udev started the unit 19.27 s into boot, and it logged received T2 SEP boot-policy response 1 for bridgeOS 23.16.15067.0.0,0 epoch 1.0 0.21 s later. t2-native-first-run and fprintd came up active, and t2-touchid-status reported ready with the enrolled finger intact.
    • EFMS already read 01 before the transaction (stale) and the response arrived within milliseconds. I can't fully rule out reading back the stale value, but readiness was proven independently by the service chain below.
  3. Services: t2-sep-transport, t2-biometric-ready, t2-native-first-run and fprintd are active. t2-native-first-run succeeded after the permissions fix (before it, it stopped with replacement runtime directory is not root-private).
  4. Enrollment: t2-touchid-enroll enrolled 1 finger, and t2-touchid-status reports Touch ID service: ready.
  5. Positive control: sudo -k && sudo true authenticated by Touch ID with no password typed. fprintd logged native_match outcome: ok, request_total 10.7 s including the wait for the touch.
  6. Negative control: fprintd-verify with an unenrolled finger returned verify-no-match (done), exit 1. The native match request completed normally (request_total 11.2 s, including the wait for the touch) and the verdict was a rejection.

Not verified

  • Negative control through sudo: the wrong-finger test went through fprintd-verify, not through sudo/PAM.
  • Repeated boots: the boot path was observed once; reliability across many cold boots is not yet established.
  • Other hardware: other boards and bridgeOS builds; applesmc kernels with this branch installed (the code path is unchanged and tests cover it, but there is no hardware run).
  • Graphical authentication: the Omarchy lock-UI patch was skipped by the existing installer ("lock source differs"), and graphical lock was not tested.
  • Sleep: suspend/resume is unchanged and still unqualified.

External, not changed here

  • Boot-menu selection: the machine's Limine menu had hand-made entries booting an older 7.2.11 image, so the installer saw an unowned running kernel. This is local machine configuration and was resolved by booting the packaged entry. No T2Touch change.
  • Kernel change: the macsmc stack replacing applesmc comes from the kernel/linux-t2 packaging. This PR adapts T2Touch to it and does not change kernel policy.

Recovery

  • Uninstall: ./uninstall.sh removes the publisher files.
  • Commit-uncertain: if publication reports commit-uncertain, the helper refuses to retry until reboot, and the existing gate stops installation before product setup.
  • Password fallback: password authentication remains available throughout, unchanged.

🤖 Generated with Claude Code

mgodwin and others added 2 commits November 16, 2026 15:53
`install -d -m 0700 /run/t2-touchid/workers` applies the mode only to the
leaf, so a fresh Linux-native install created the parent as 0755. The only
other creator of the parent with 0700 is t2-keybag-load.sh, which is
disabled in Linux-native mode, and fprintd.service's
RuntimeDirectory=t2-touchid/workers also creates the parent as 0755 at boot.

t2-native-first-run then stopped with "replacement runtime directory is not
root-private". Create the parent explicitly as 0700 in the installer and add
a tmpfiles.d entry so it is root-private before fprintd starts on every boot.

Observed on MacBookPro15,1, linux-t2 7.3.4, fresh Linux-only install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Linux 7.3 removed struct acpi_driver, and T2 kernels now bind the SMC
(APP0001) to the macsmc MFD stack (macsmc-acpi, -hwmon, -power, -rtc,
-wdt). The bundled applesmc-t2touch prerequisite no longer compiles, and
even a ported applesmc would contend with macsmc for the same device.

The macsmc core exposes /dev/smc with key read/write/info ioctls, so the
one-shot EFMV/EFMS/EFBS boot-state transaction can run from userspace:

- src/t2-smc-boot-state.c performs the same transaction as the applesmc
  patch (pristine EFMV check, bridgeOS version from DMI, EFMS clear, EFBS
  commit, 40 s EFMS poll) and records the result in the existing
  vocabulary at /run/t2touch/t2_sep_boot_state. --probe is read-only.
  Runs at most once per boot; commit-uncertain is never retried.
- t2-smc-boot-state.service runs it sandboxed to /dev/smc, ordered before
  t2-sep-transport.service. udev starts it when /dev/smc appears, because
  misc devices are not visible to systemd and a device dependency would
  time out (and delay boot on applesmc kernels).
- The installer detects macsmc (character /dev/smc plus macsmc-acpi bound
  to APP0001), installs the helper, unit and udev rule instead of staging
  applesmc DKMS, skips the applesmc modprobe options/softdep, and reads the
  userspace result alongside the sysfs attribute. applesmc kernels are
  unchanged. uninstall.sh removes the new files.
- Tests stub macsmc detection so they stay hermetic on macsmc hosts, and
  cover the macsmc gate, detection and result reading.

Verified on MacBookPro15,1 (J680, bridgeOS 23.16.15067.0.0,0), linux-t2
7.3.4, Linux-only: response-received:1, first-run identity created, finger
enrolled, sudo authenticated by Touch ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@denisvmedia

Copy link
Copy Markdown

A heads-up from a MacBookAir9,1 on Ubuntu. On linux-t2 7.3.4-3 the helper's probe works here too, but 7.3.5-1 closes the /dev/smc route. The patch set changed on 2026-11-17 (linux-t2-patches 60a3b5e):

  • struct ioctl_smc_rw_payload now has __u32 size where it had size_t, so the READ and WRITE ioctl numbers are different and the kernel no longer recognizes the helper's calls.
  • IOCTL_SMC_WRITE only accepts HE0N, HE2N, HI0N, MSTS, MSPC and QENA now. Every other key gets EPERM, and EFMV, EFMS and EFBS are not on the list.

I checked both in the 7.3.5-1 package (the header and macsmc-core.ko), not on a running 7.3.5.

I went another way: a small kernel module that runs the same transaction through apple_smc_read() and apple_smc_write(): https://github.com/denisvmedia/t2-sep-boot-state. On my machine it gets response-received:1 at boot, and t2touch comes up on top of it. The change on the t2touch side is small: read /sys/module/t2_sep_boot_state/parameters/result, and write the options and a softdep line. I can send it as a pull request if you want it.

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.

2 participants