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