• Kees Cook's avatar
    LoadPin: Allow filesystem switch when not enforcing · eba77359
    Kees Cook authored
    For LoadPin to be used at all in a classic distro environment, it needs
    to allow for switching filesystems (from the initramfs to the "real"
    root filesystem). To allow for this, if the "enforce" mode is not set at
    boot, reset the pinned filesystem tracking when the pinned filesystem
    gets unmounted instead of invalidating further loads. Once enforcement
    is set, it cannot be unset, and the pinning will stick.
    
    This means that distros can build with CONFIG_SECURITY_LOADPIN=y, but with
    CONFIG_SECURITY_LOADPIN_ENFORCE disabled, but after boot is running,
    the system can enable enforcement:
    
      $ sysctl -w kernel.loadpin.enforced=1
    
    Cc: Paul Moore <paul@paul-moore.com>
    Cc: James Morris <jmorris@namei.org>
    Cc: "Serge E. Hallyn" <serge@hallyn.com>
    Cc: linux-security-module@vger.kernel.org
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Reviewed-by: default avatarSerge Hallyn <serge@hallyn.com>
    Link: https://lore.kernel.org/r/20221209195746.1366607-4-keescook@chromium.org
    eba77359
loadpin.c 10.8 KB