Skip to content

Commit

Permalink
tee-supplicant: add udev rule and systemd service file
Browse files Browse the repository at this point in the history
tee-supplicant startup with systemd init based
is non-trivial. Add needed udev rule and systemd
service files here so that distros can co-operate maintaining
them.

Files are from meta-arm https://git.yoctoproject.org/meta-arm
at commit 7cce43e632daa8650f683ac726f9124681b302a4 with license
MIT and authors:

Peter Griffin <[email protected]>
Joshua Watt <[email protected]>
Javier Tia <[email protected]>
Mikko Rapeli <[email protected]>

The udev rule starts tee-supplicant once optee has been
detected via /dev/teepriv[0-9]* device file. The startup
expects to find teeclnt system group on the running host.
systemd service starts before tpm2.target (new in systemd 256)
which starts in initramfs too. This covers firmware TPM
TA usecases, and possibly others which are started before
main rootfs is mounted. For stopping tee-supplicant, the
ftpm kernel modules are removed and only then the main
process stopped to avoid fTPM breakage. These workarounds
may be removed once RPMB kernel and optee patches
without tee-supplicant are merged.

Cc: Peter Griffin <[email protected]>
Cc: Joshua Watt <[email protected]>
Cc: Javier Tia <[email protected]>
Signed-off-by: Mikko Rapeli <[email protected]>
  • Loading branch information
mikkorapeli-linaro committed Oct 3, 2024
1 parent 49e646d commit 44e6a63
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tee-supplicant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ endif()
# Install targets
################################################################################
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
install(FILES optee-udev.rules DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/udev/rules.d)
configure_file([email protected] [email protected] @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/[email protected] DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system)
7 changes: 7 additions & 0 deletions tee-supplicant/optee-udev.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: MIT
KERNEL=="tee[0-9]*", MODE="0660", OWNER="root", GROUP="teeclnt", TAG+="systemd"

# If a /dev/teepriv[0-9]* device is detected, start an instance of
# tee-supplicant.service with the device name as parameter
KERNEL=="teepriv[0-9]*", MODE="0660", OWNER="root", GROUP="teeclnt", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="tee-supplicant@%k.service"
14 changes: 14 additions & 0 deletions tee-supplicant/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: MIT
[Unit]
Description=TEE Supplicant on %i
DefaultDependencies=no
After=dev-%i.device
Wants=dev-%i.device
Conflicts=shutdown.target
Before=tpm2.target sysinit.target shutdown.target

[Service]
Type=notify
EnvironmentFile=-@CMAKE_INSTALL_SYSCONFDIR@/default/tee-supplicant
ExecStart=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_SBINDIR@/tee-supplicant $OPTARGS
ExecStop=-/bin/sh -c "/sbin/modprobe -v -r tpm_ftpm_tee ; /bin/kill $MAINPID"

0 comments on commit 44e6a63

Please sign in to comment.