LSM: Ignore "security=" when "lsm=" is specified
PATCH 1/1 LSM: Ignore "security=" when "lsm=" is specified
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
--- security/security.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
security/security.c +6 -2
@@ -288,9 +288,13 @@ static void __init ordered_lsm_init(void) ordered_lsms =kcalloc (LSM_COUNT +1 ,sizeof (*ordered_lsms),GFP_KERNEL ); -if (chosen_lsm_order) +if (chosen_lsm_order) { +if (chosen_major_lsm) { +pr_info ("security= is ignored because of lsm=\n" ); + chosen_major_lsm =NULL ; + }ordered_lsm_parse (chosen_lsm_order,"cmdline" ); -else + }else ordered_lsm_parse (builtin_lsm_order,"builtin" );for (lsm = ordered_lsms; *lsm; lsm++)
Signature · 5 lines
2.17.1 -- Kees Cook
Quoted 14 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
Suggested-by Tetsuo Handa <[email protected]>Signed-off-by Kees Cook <[email protected]>--- security/security.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)security/security.c +0
-0
security/security.c static void __init ordered_lsm_init(void) · line 293
Quoted 7 lines
security/security.c +3
-1@@ -288,9 +288,13 @@ static void __init ordered_lsm_init(void) ordered_lsms =kcalloc (LSM_COUNT +1 ,sizeof (*ordered_lsms),GFP_KERNEL ); -if (chosen_lsm_order) +if (chosen_lsm_order) { +if (chosen_major_lsm) { +pr_info ("security= is ignored because of lsm=\n" );
This is a little awkward. How about "lsm= supersedes security=".
Quoted 8 lines
security/security.c +3
-1+ chosen_major_lsm =NULL ; + }ordered_lsm_parse (chosen_lsm_order,"cmdline" ); - else + }else ordered_lsm_parse (builtin_lsm_order,"builtin" );for (lsm = ordered_lsms; *lsm; lsm++)
Quoted 19 lines · Casey Schaufler
Quoted 17 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
Suggested-by Tetsuo Handa <[email protected]>Signed-off-by Kees Cook <[email protected]>--- security/security.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)security/security.c +0
-0@@ -288,9 +288,13 @@ static void __init ordered_lsm_init(void) ordered_lsms =kcalloc (LSM_COUNT +1 ,sizeof (*ordered_lsms),GFP_KERNEL );
Quoted 6 lines
security/security.c static void __init ordered_lsm_init(void) · line 293
Quoted 4 lines
security/security.c +3
-1-if (chosen_lsm_order) +if (chosen_lsm_order) { +if (chosen_major_lsm) { +pr_info ("security= is ignored because of lsm=\n" );This is a little awkward. How about "lsm= supersedes security=".
Fine by me. James? What would you like here?
Signature · 1 line
Kees Cook
James Morris
maintainerQuoted 20 lines · Kees Cook
Quoted 19 lines · Casey Schaufler
Quoted 17 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
Suggested-by Tetsuo Handa <[email protected]>Signed-off-by Kees Cook <[email protected]>--- security/security.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)security/security.c +0
-0@@ -288,9 +288,13 @@ static void __init ordered_lsm_init(void) ordered_lsms =kcalloc (LSM_COUNT +1 ,sizeof (*ordered_lsms),GFP_KERNEL );
Quoted 8 lines
Quoted 6 lines
security/security.c static void __init ordered_lsm_init(void) · line 293
Quoted 4 lines
security/security.c +3
-1-if (chosen_lsm_order) +if (chosen_lsm_order) { +if (chosen_major_lsm) { +pr_info ("security= is ignored because of lsm=\n" );This is a little awkward. How about "lsm= supersedes security=".
Fine by me. James? What would you like here?
How about security= is ignored because it is superseded by lsm= ?
Signature · 2 lines
James Morris <[email protected]>
Quoted 2 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
To maintain the existing behavior of CONFIG_DEFAULT_SECURITY, I also suggest this change. This saves e.g. Ubuntu users who are using only AppArmor from explicitly specifying security=apparmor when they don't want to enable other LSM_FLAG_LEGACY_MAJOR modules.
--- security/Kconfig | 37 +++++++++++++++++++++++++++++++++++++ security/security.c | 5 ++++- 2 files changed, 41 insertions(+), 1 deletion(-)
security/Kconfig +37 -0
@@ -250,5 +250,42 @@ config LSM If unsure, leave this as the default. +choice + prompt "Default exclusive security module" + default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX + default DEFAULT_SECURITY_SMACK if SECURITY_SMACK + default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO + default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR + default DEFAULT_SECURITY_DAC + + help + The security module where only one of these modules should be enabled if + neither the "security=" parameter nor the "lsm=" parameter is specified. + + config DEFAULT_SECURITY_SELINUX + bool "SELinux" if SECURITY_SELINUX=y + + config DEFAULT_SECURITY_SMACK + bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y + + config DEFAULT_SECURITY_TOMOYO + bool "TOMOYO" if SECURITY_TOMOYO=y + + config DEFAULT_SECURITY_APPARMOR + bool "AppArmor" if SECURITY_APPARMOR=y + + config DEFAULT_SECURITY_DAC + bool "Unix Discretionary Access Controls" + +endchoice + +config DEFAULT_SECURITY + string + default "selinux" if DEFAULT_SECURITY_SELINUX + default "smack" if DEFAULT_SECURITY_SMACK + default "tomoyo" if DEFAULT_SECURITY_TOMOYO + default "apparmor" if DEFAULT_SECURITY_APPARMOR + default "" if DEFAULT_SECURITY_DAC + endmenu
security/security.c +4 -1
@@ -294,8 +294,11 @@ static void __init ordered_lsm_init(void) chosen_major_lsm =NULL ; }ordered_lsm_parse (chosen_lsm_order,"cmdline" ); - }else + }else { +if (!chosen_major_lsm) + chosen_major_lsm =CONFIG_DEFAULT_SECURITY ;ordered_lsm_parse (builtin_lsm_order,"builtin" ); + }for (lsm = ordered_lsms; *lsm; lsm++)prepare_lsm (*lsm);
Signature · 1 line
1.8.3.1
Quoted 8 lines · Tetsuo Handa
Quoted 2 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
To maintain the existing behavior of
CONFIG_DEFAULT_SECURITY, I also suggest this change. This saves e.g. Ubuntu users who are using only AppArmor from explicitly specifying security=apparmor when they don't want to enable otherLSM_FLAG_LEGACY_MAJORmodules.
No, this completely disables the purpose of lsm=
I don't understand the use-case you're concerned about?
-Kees
Quoted 73 lines
--- security/Kconfig | 37 +++++++++++++++++++++++++++++++++++++ security/security.c | 5 ++++- 2 files changed, 41 insertions(+), 1 deletion(-)security/Kconfig +37
-0@@ -250,5 +250,42 @@ config LSM If unsure, leave this as the default. +choice + prompt "Default exclusive security module" + default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX + default DEFAULT_SECURITY_SMACK if SECURITY_SMACK + default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO + default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR + default DEFAULT_SECURITY_DAC + + help + The security module where only one of these modules should be enabled if + neither the "security=" parameter nor the "lsm=" parameter is specified. + + config DEFAULT_SECURITY_SELINUX + bool "SELinux" if SECURITY_SELINUX=y + + config DEFAULT_SECURITY_SMACK + bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y + + config DEFAULT_SECURITY_TOMOYO + bool "TOMOYO" if SECURITY_TOMOYO=y + + config DEFAULT_SECURITY_APPARMOR + bool "AppArmor" if SECURITY_APPARMOR=y + + config DEFAULT_SECURITY_DAC + bool "Unix Discretionary Access Controls" + +endchoice + +config DEFAULT_SECURITY + string + default "selinux" if DEFAULT_SECURITY_SELINUX + default "smack" if DEFAULT_SECURITY_SMACK + default "tomoyo" if DEFAULT_SECURITY_TOMOYO + default "apparmor" if DEFAULT_SECURITY_APPARMOR + default "" if DEFAULT_SECURITY_DAC + endmenusecurity/security.c +4
-2@@ -294,8 +294,11 @@ static void __init ordered_lsm_init(void) chosen_major_lsm =NULL ; }ordered_lsm_parse (chosen_lsm_order,"cmdline" ); - }else + }else { +if (!chosen_major_lsm) + chosen_major_lsm =CONFIG_DEFAULT_SECURITY ;ordered_lsm_parse (builtin_lsm_order,"builtin" ); + }for (lsm = ordered_lsms; *lsm; lsm++)prepare_lsm (*lsm); --1.8.3.1
Signature · 1 line
Kees Cook
Quoted 7 lines · Kees Cook
Quoted 5 lines · Tetsuo Handa
Quoted 2 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
Quoted 7 lines
Quoted 3 lines
To maintain the existing behavior of
CONFIG_DEFAULT_SECURITY, I also suggest this change. This saves e.g. Ubuntu users who are using only AppArmor from explicitly specifying security=apparmor when they don't want to enable otherLSM_FLAG_LEGACY_MAJORmodules.No, this completely disables the purpose of lsm=
I don't understand the use-case you're concerned about?
The purpose of lsm= remains.
I worry that distro users who don't explicitly specify security= parameter suddenly find TOMOYO messages because TOMOYO is no longer exclusive. There are two ways for avoiding it. One is to explicitly specify security= parameter. The other is to remove tomoyo from CONFIG_LSM. This change adds the third way; preserve current security= behavior until they start explicitly specifying lsm= parameter.
Quoted 12 lines · Tetsuo Handa
Quoted 11 lines · Kees Cook
Quoted 8 lines · Tetsuo Handa
Quoted 2 lines · Kees Cook
To avoid potential confusion, explicitly ignore "security=" when "lsm=" is used on the command line, and report that it is happening.
To maintain the existing behavior of
CONFIG_DEFAULT_SECURITY, I also suggest this change. This saves e.g. Ubuntu users who are using only AppArmor from explicitly specifying security=apparmor when they don't want to enable otherLSM_FLAG_LEGACY_MAJORmodules.
Quoted 8 lines
Quoted 3 lines
No, this completely disables the purpose of lsm=
I don't understand the use-case you're concerned about?
The purpose of lsm= remains.
I worry that distro users who don't explicitly specify security= parameter suddenly find TOMOYO messages because TOMOYO is no longer exclusive.
What's wrong with that? TOMOYO will start, see there is no policy, and not do anything else.
Quoted 4 lines
There are two ways for avoiding it. One is to explicitly specify security= parameter. The other is to remove tomoyo from
CONFIG_LSM. This change adds the third way; preserve current security= behavior until they start explicitly specifying lsm= parameter.
"security=" has been deprecated due to the many many threads about how it won't work moving forward. Leaving the CONFIG settings confuses the situation and needlessly drags out the transition for no real gain.
But yes, if someone selects a "legacy major" LSM, the others (including TOMOYO) will be disabled, which matches the old behavior. Also, yes, removing it from CONFIG_LSM works; this is up to the distro to decide.
Signature · 1 line
Kees Cook