LoadPin: Allow filesystem switch when not enforcing
authorKees Cook <keescook@chromium.org>
Fri, 9 Dec 2022 19:57:45 +0000 (11:57 -0800)
committerKees Cook <keescook@chromium.org>
Thu, 19 Jan 2023 23:18:20 +0000 (15:18 -0800)
commiteba773596be9c21a8e979d7e653f721d1d0341a9
tree67399023bc733944444d4a8f749188e66ad712bf
parent2cfaa84efc25e52f116507a2e69781a40c4dda41
LoadPin: Allow filesystem switch when not enforcing

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: Kees Cook <keescook@chromium.org>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Link: https://lore.kernel.org/r/20221209195746.1366607-4-keescook@chromium.org
security/loadpin/loadpin.c