Skip to content

Commit 2623c4f

Browse files
keesJames Morris
authored andcommitted
LSM: Revive CONFIG_DEFAULT_SECURITY_* for "make oldconfig"
Commit 70b62c2 ("LoadPin: Initialize as ordered LSM") removed CONFIG_DEFAULT_SECURITY_{SELINUX,SMACK,TOMOYO,APPARMOR,DAC} from security/Kconfig and changed CONFIG_LSM to provide a fixed ordering as a default value. That commit expected that existing users (upgrading from Linux 5.0 and earlier) will edit CONFIG_LSM value in accordance with their CONFIG_DEFAULT_SECURITY_* choice in their old kernel configs. But since users might forget to edit CONFIG_LSM value, this patch revives the choice (only for providing the default value for CONFIG_LSM) in order to make sure that CONFIG_LSM reflects CONFIG_DEFAULT_SECURITY_* from their old kernel configs. Note that since TOMOYO can be fully stacked against the other legacy major LSMs, when it is selected, it explicitly disables the other LSMs to avoid them also initializing since TOMOYO does not expect this currently. Reported-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reported-by: Randy Dunlap <rdunlap@infradead.org> Fixes: 70b62c2 ("LoadPin: Initialize as ordered LSM") Co-developed-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: James Morris <james.morris@microsoft.com>
1 parent 1aa176e commit 2623c4f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

security/Kconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,46 @@ source "security/safesetid/Kconfig"
239239

240240
source "security/integrity/Kconfig"
241241

242+
choice
243+
prompt "First legacy 'major LSM' to be initialized"
244+
default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX
245+
default DEFAULT_SECURITY_SMACK if SECURITY_SMACK
246+
default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO
247+
default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR
248+
default DEFAULT_SECURITY_DAC
249+
250+
help
251+
This choice is there only for converting CONFIG_DEFAULT_SECURITY
252+
in old kernel configs to CONFIG_LSM in new kernel configs. Don't
253+
change this choice unless you are creating a fresh kernel config,
254+
for this choice will be ignored after CONFIG_LSM has been set.
255+
256+
Selects the legacy "major security module" that will be
257+
initialized first. Overridden by non-default CONFIG_LSM.
258+
259+
config DEFAULT_SECURITY_SELINUX
260+
bool "SELinux" if SECURITY_SELINUX=y
261+
262+
config DEFAULT_SECURITY_SMACK
263+
bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y
264+
265+
config DEFAULT_SECURITY_TOMOYO
266+
bool "TOMOYO" if SECURITY_TOMOYO=y
267+
268+
config DEFAULT_SECURITY_APPARMOR
269+
bool "AppArmor" if SECURITY_APPARMOR=y
270+
271+
config DEFAULT_SECURITY_DAC
272+
bool "Unix Discretionary Access Controls"
273+
274+
endchoice
275+
242276
config LSM
243277
string "Ordered list of enabled LSMs"
278+
default "yama,loadpin,safesetid,integrity,smack,selinux,tomoyo,apparmor" if DEFAULT_SECURITY_SMACK
279+
default "yama,loadpin,safesetid,integrity,apparmor,selinux,smack,tomoyo" if DEFAULT_SECURITY_APPARMOR
280+
default "yama,loadpin,safesetid,integrity,tomoyo" if DEFAULT_SECURITY_TOMOYO
281+
default "yama,loadpin,safesetid,integrity" if DEFAULT_SECURITY_DAC
244282
default "yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor"
245283
help
246284
A comma-separated list of LSMs, in initialization order.

0 commit comments

Comments
 (0)