LSM: LoadPin for module and firmware loading restrictions
Subsystems (2)
PATCH 1/1 LSM: LoadPin for module and firmware loading restrictions
This LSM enforces that kernel-loaded modules and firmware must all come from the same filesystem, with the expectation that such a filesystem is backed by a read-only device such as dm-verity or CDROM. This allows systems that have a verified and/or unchangeable filesystem to enforce module and firmware loading restrictions without needing to sign the files individually.
--- MAINTAINERS | 6 + include/linux/lsm_hooks.h | 5 + security/Kconfig | 1 + security/Makefile | 2 + security/loadpin/Kconfig | 9 ++ security/loadpin/Makefile | 1 + security/loadpin/loadpin.c | 279 +++++++++++++++++++++++++++++++++++++++++++++ security/security.c | 2 + 8 files changed, 305 insertions(+) create mode 100644 security/loadpin/Kconfig create mode 100644 security/loadpin/Makefile create mode 100644 security/loadpin/loadpin.c
MAINTAINERS +6 -0
@@ -9101,6 +9101,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/jj/apparmor-dev.git S: Supported F: security/apparmor/ +LOADPIN SECURITY MODULE +M: Kees Cook <[email protected]> +T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git lsm/loadpin +S: Supported +F: security/loadpin/ + SENSABLE PHANTOM M: Jiri Slaby <[email protected]> S: Maintained
include/linux/lsm_hooks.h +5 -0
@@ -1884,5 +1884,10 @@ extern void __init capability_add_hooks(void);#ifdef CONFIG_SECURITY_YAMA_STACKED void __init yama_add_hooks (void );#endif +#ifdef CONFIG_SECURITY_LOADPIN +void __init loadpin_add_hooks (void ); +#else +static inline void loadpin_add_hooks (void ) { }; +#endif #endif /* ! __LINUX_LSM_HOOKS_H */
security/Kconfig +1 -0
@@ -122,6 +122,7 @@ source security/selinux/Kconfig source security/smack/Kconfig source security/tomoyo/Kconfig source security/apparmor/Kconfig +source security/loadpin/Kconfig source security/yama/Kconfig source security/integrity/Kconfig
security/Makefile +2 -0
@@ -8,6 +8,7 @@ subdir-$(CONFIG_SECURITY_SMACK) += smack subdir-$(CONFIG_SECURITY_TOMOYO) += tomoyo subdir-$(CONFIG_SECURITY_APPARMOR) += apparmor subdir-$(CONFIG_SECURITY_YAMA) += yama +subdir-$(CONFIG_SECURITY_LOADPIN) += loadpin # always enable default capabilities obj-y += commoncap.o
@@ -22,6 +23,7 @@ obj-$(CONFIG_AUDIT) += lsm_audit.o obj-$(CONFIG_SECURITY_TOMOYO) += tomoyo/ obj-$(CONFIG_SECURITY_APPARMOR) += apparmor/ obj-$(CONFIG_SECURITY_YAMA) += yama/ +obj-$(CONFIG_SECURITY_LOADPIN) += loadpin/ obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o # Object integrity file lists
security/loadpin/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config SECURITY_LOADPIN + bool "Pin loading of kernel modules and firmware to one filesystem" + depends on SECURITY && BLOCK + help + Kernel module and firmware loading will be pinned to the first + filesystem used for loading. Any files that come from other + filesystems will be rejected. This is best used on systems + without an initrd that have a root filesystem backed by a + read-only device such as dm-verity or a CDROM.
security/loadpin/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SECURITY_LOADPIN) += loadpin.o
security/loadpin/loadpin.c new file +279 -0
279 lines not on this page · raw message
security/security.c +2 -0
@@ -65,6 +65,8 @@ int __init security_init(void)*/ yama_add_hooks ();#endif +loadpin_add_hooks (); +/* * Load the chosen module if there is one. * This will also find yama if it is stacking
Signature · 6 lines
1.9.1 -- Kees Cook Chrome OS Security
James Morris
maintainersecurity/loadpin/loadpin.c line 35
Quoted 7 lines · Kees Cook
security/loadpin/loadpin.c new file +7
-0+ +/* +* Return an allocated string that has been escaped of special characters +* and double quotes, making it safe to log in quotes. +*/ +static char *kstrdup_quotable (char *src) +{
Do you think these should go into a library?
Signature · 2 lines
James Morris <[email protected]>
Quoted 11 lines · James Morris
security/loadpin/loadpin.c line 35
Quoted 7 lines · Kees Cook
security/loadpin/loadpin.c new file +7
-0+ +/* +* Return an allocated string that has been escaped of special characters +* and double quotes, making it safe to log in quotes. +*/ +static char *kstrdup_quotable (char *src) +{Do you think these should go into a library?
Possibly. There are some other areas of code that almost do the same thing, but not exactly. Perhaps I'll first change Yama around to use it, then send these again.
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
James Morris
maintainerQuoted 13 lines · Kees Cook
Quoted 11 lines · James Morris
security/loadpin/loadpin.c line 35
Quoted 7 lines · Kees Cook
security/loadpin/loadpin.c new file +7
-0+ +/* +* Return an allocated string that has been escaped of special characters +* and double quotes, making it safe to log in quotes. +*/ +static char *kstrdup_quotable (char *src) +{Do you think these should go into a library?
Quoted 3 lines
Possibly. There are some other areas of code that almost do the same thing, but not exactly. Perhaps I'll first change Yama around to use it, then send these again.
Ok. Is this the same code being used in ChromeOS?
Signature · 2 lines
James Morris <[email protected]>
Quoted 15 lines · James Morris
Quoted 13 lines · Kees Cook
Quoted 11 lines · James Morris
security/loadpin/loadpin.c line 35
Quoted 7 lines · Kees Cook
security/loadpin/loadpin.c new file +7
-0+ +/* +* Return an allocated string that has been escaped of special characters +* and double quotes, making it safe to log in quotes. +*/ +static char *kstrdup_quotable (char *src) +{Do you think these should go into a library?
Quoted 5 lines
Quoted 3 lines
Possibly. There are some other areas of code that almost do the same thing, but not exactly. Perhaps I'll first change Yama around to use it, then send these again.
Ok. Is this the same code being used in ChromeOS?
Essentially, yes. As the kernels used by Chrome OS don't have LSM stacking, we merged a bunch of functionality into a single LSM. LoadPin is a logical subset of that LSM.
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security