162306a36Sopenharmony_ci======= 262306a36Sopenharmony_ciLoadPin 362306a36Sopenharmony_ci======= 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciLoadPin is a Linux Security Module that ensures all kernel-loaded files 662306a36Sopenharmony_ci(modules, firmware, etc) all originate from the same filesystem, with 762306a36Sopenharmony_cithe expectation that such a filesystem is backed by a read-only device 862306a36Sopenharmony_cisuch as dm-verity or CDROM. This allows systems that have a verified 962306a36Sopenharmony_ciand/or unchangeable filesystem to enforce module and firmware loading 1062306a36Sopenharmony_cirestrictions without needing to sign the files individually. 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciThe LSM is selectable at build-time with ``CONFIG_SECURITY_LOADPIN``, and 1362306a36Sopenharmony_cican be controlled at boot-time with the kernel command line option 1462306a36Sopenharmony_ci"``loadpin.enforce``". By default, it is enabled, but can be disabled at 1562306a36Sopenharmony_ciboot ("``loadpin.enforce=0``"). 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciLoadPin starts pinning when it sees the first file loaded. If the 1862306a36Sopenharmony_ciblock device backing the filesystem is not read-only, a sysctl is 1962306a36Sopenharmony_cicreated to toggle pinning: ``/proc/sys/kernel/loadpin/enabled``. (Having 2062306a36Sopenharmony_cia mutable filesystem means pinning is mutable too, but having the 2162306a36Sopenharmony_cisysctl allows for easy testing on systems with a mutable filesystem.) 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciIt's also possible to exclude specific file types from LoadPin using kernel 2462306a36Sopenharmony_cicommand line option "``loadpin.exclude``". By default, all files are 2562306a36Sopenharmony_ciincluded, but they can be excluded using kernel command line option such 2662306a36Sopenharmony_cias "``loadpin.exclude=kernel-module,kexec-image``". This allows to use 2762306a36Sopenharmony_cidifferent mechanisms such as ``CONFIG_MODULE_SIG`` and 2862306a36Sopenharmony_ci``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while 2962306a36Sopenharmony_cistill use LoadPin to protect the integrity of other files kernel loads. The 3062306a36Sopenharmony_cifull list of valid file types can be found in ``kernel_read_file_str`` 3162306a36Sopenharmony_cidefined in ``include/linux/kernel_read_file.h``. 32