1*4882a593Smuzhiyun======= 2*4882a593SmuzhiyunLoadPin 3*4882a593Smuzhiyun======= 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunLoadPin is a Linux Security Module that ensures all kernel-loaded files 6*4882a593Smuzhiyun(modules, firmware, etc) all originate from the same filesystem, with 7*4882a593Smuzhiyunthe expectation that such a filesystem is backed by a read-only device 8*4882a593Smuzhiyunsuch as dm-verity or CDROM. This allows systems that have a verified 9*4882a593Smuzhiyunand/or unchangeable filesystem to enforce module and firmware loading 10*4882a593Smuzhiyunrestrictions without needing to sign the files individually. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunThe LSM is selectable at build-time with ``CONFIG_SECURITY_LOADPIN``, and 13*4882a593Smuzhiyuncan be controlled at boot-time with the kernel command line option 14*4882a593Smuzhiyun"``loadpin.enabled``". By default, it is enabled, but can be disabled at 15*4882a593Smuzhiyunboot ("``loadpin.enabled=0``"). 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunLoadPin starts pinning when it sees the first file loaded. If the 18*4882a593Smuzhiyunblock device backing the filesystem is not read-only, a sysctl is 19*4882a593Smuzhiyuncreated to toggle pinning: ``/proc/sys/kernel/loadpin/enabled``. (Having 20*4882a593Smuzhiyuna mutable filesystem means pinning is mutable too, but having the 21*4882a593Smuzhiyunsysctl allows for easy testing on systems with a mutable filesystem.) 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunIt's also possible to exclude specific file types from LoadPin using kernel 24*4882a593Smuzhiyuncommand line option "``loadpin.exclude``". By default, all files are 25*4882a593Smuzhiyunincluded, but they can be excluded using kernel command line option such 26*4882a593Smuzhiyunas "``loadpin.exclude=kernel-module,kexec-image``". This allows to use 27*4882a593Smuzhiyundifferent mechanisms such as ``CONFIG_MODULE_SIG`` and 28*4882a593Smuzhiyun``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while 29*4882a593Smuzhiyunstill use LoadPin to protect the integrity of other files kernel loads. The 30*4882a593Smuzhiyunfull list of valid file types can be found in ``kernel_read_file_str`` 31*4882a593Smuzhiyundefined in ``include/linux/fs.h``. 32