Skip to content

Commit 730daa1

Browse files
keesJames Morris
authored andcommitted
Yama: remove needless CONFIG_SECURITY_YAMA_STACKED
Now that minor LSMs can cleanly stack with major LSMs, remove the unneeded config for Yama to be made to explicitly stack. Just selecting the main Yama CONFIG will allow it to work, regardless of the major LSM. Since distros using Yama are already forcing it to stack, this is effectively a no-op change. Additionally add MAINTAINERS entry. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent fe6c59d commit 730daa1

8 files changed

Lines changed: 28 additions & 52 deletions

File tree

‎Documentation/security/Yama.txt‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
Yama is a Linux Security Module that collects a number of system-wide DAC
2-
security protections that are not handled by the core kernel itself. To
3-
select it at boot time, specify "security=yama" (though this will disable
4-
any other LSM).
5-
6-
Yama is controlled through sysctl in /proc/sys/kernel/yama:
1+
Yama is a Linux Security Module that collects system-wide DAC security
2+
protections that are not handled by the core kernel itself. This is
3+
selectable at build-time with CONFIG_SECURITY_YAMA, and can be controlled
4+
at run-time through sysctls in /proc/sys/kernel/yama:
75

86
- ptrace_scope
97

‎MAINTAINERS‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9102,6 +9102,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/jj/apparmor-dev.git
91029102
S: Supported
91039103
F: security/apparmor/
91049104

9105+
YAMA SECURITY MODULE
9106+
M: Kees Cook <keescook@chromium.org>
9107+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git yama/tip
9108+
S: Supported
9109+
F: security/yama/
9110+
91059111
SENSABLE PHANTOM
91069112
M: Jiri Slaby <jirislaby@gmail.com>
91079113
S: Maintained

‎arch/mips/configs/pistachio_defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ CONFIG_KEYS=y
320320
CONFIG_SECURITY=y
321321
CONFIG_SECURITY_NETWORK=y
322322
CONFIG_SECURITY_YAMA=y
323-
CONFIG_SECURITY_YAMA_STACKED=y
324323
CONFIG_DEFAULT_SECURITY_DAC=y
325324
CONFIG_CRYPTO_AUTHENC=y
326325
CONFIG_CRYPTO_HMAC=y

‎include/linux/lsm_hooks.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,10 @@ static inline void security_delete_hooks(struct security_hook_list *hooks,
18811881

18821882
extern int __init security_module_enable(const char *module);
18831883
extern void __init capability_add_hooks(void);
1884-
#ifdef CONFIG_SECURITY_YAMA_STACKED
1885-
void __init yama_add_hooks(void);
1884+
#ifdef CONFIG_SECURITY_YAMA
1885+
extern void __init yama_add_hooks(void);
1886+
#else
1887+
static inline void __init yama_add_hooks(void) { }
18861888
#endif
18871889

18881890
#endif /* ! __LINUX_LSM_HOOKS_H */

‎security/Kconfig‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ choice
132132
default DEFAULT_SECURITY_SMACK if SECURITY_SMACK
133133
default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO
134134
default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR
135-
default DEFAULT_SECURITY_YAMA if SECURITY_YAMA
136135
default DEFAULT_SECURITY_DAC
137136

138137
help
@@ -151,9 +150,6 @@ choice
151150
config DEFAULT_SECURITY_APPARMOR
152151
bool "AppArmor" if SECURITY_APPARMOR=y
153152

154-
config DEFAULT_SECURITY_YAMA
155-
bool "Yama" if SECURITY_YAMA=y
156-
157153
config DEFAULT_SECURITY_DAC
158154
bool "Unix Discretionary Access Controls"
159155

@@ -165,7 +161,6 @@ config DEFAULT_SECURITY
165161
default "smack" if DEFAULT_SECURITY_SMACK
166162
default "tomoyo" if DEFAULT_SECURITY_TOMOYO
167163
default "apparmor" if DEFAULT_SECURITY_APPARMOR
168-
default "yama" if DEFAULT_SECURITY_YAMA
169164
default "" if DEFAULT_SECURITY_DAC
170165

171166
endmenu

‎security/security.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,13 @@ int __init security_init(void)
5656
pr_info("Security Framework initialized\n");
5757

5858
/*
59-
* Always load the capability module.
59+
* Load minor LSMs, with the capability module always first.
6060
*/
6161
capability_add_hooks();
62-
#ifdef CONFIG_SECURITY_YAMA_STACKED
63-
/*
64-
* If Yama is configured for stacking load it next.
65-
*/
6662
yama_add_hooks();
67-
#endif
63+
6864
/*
69-
* Load the chosen module if there is one.
70-
* This will also find yama if it is stacking
65+
* Load all the remaining security modules.
7166
*/
7267
do_security_initcalls();
7368

‎security/yama/Kconfig‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ config SECURITY_YAMA
66
This selects Yama, which extends DAC support with additional
77
system-wide security settings beyond regular Linux discretionary
88
access controls. Currently available is ptrace scope restriction.
9+
Like capabilities, this security module stacks with other LSMs.
910
Further information can be found in Documentation/security/Yama.txt.
1011

1112
If you are unsure how to answer this question, answer N.
12-
13-
config SECURITY_YAMA_STACKED
14-
bool "Yama stacked with other LSMs"
15-
depends on SECURITY_YAMA
16-
default n
17-
help
18-
When Yama is built into the kernel, force it to stack with the
19-
selected primary LSM.

‎security/yama/yama_lsm.c‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,6 @@ static struct security_hook_list yama_hooks[] = {
353353
LSM_HOOK_INIT(task_free, yama_task_free),
354354
};
355355

356-
void __init yama_add_hooks(void)
357-
{
358-
security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks));
359-
}
360-
361356
#ifdef CONFIG_SYSCTL
362357
static int yama_dointvec_minmax(struct ctl_table *table, int write,
363358
void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -396,25 +391,18 @@ static struct ctl_table yama_sysctl_table[] = {
396391
},
397392
{ }
398393
};
399-
#endif /* CONFIG_SYSCTL */
400-
401-
static __init int yama_init(void)
394+
static void __init yama_init_sysctl(void)
402395
{
403-
#ifndef CONFIG_SECURITY_YAMA_STACKED
404-
/*
405-
* If yama is being stacked this is already taken care of.
406-
*/
407-
if (!security_module_enable("yama"))
408-
return 0;
409-
#endif
410-
pr_info("Yama: becoming mindful.\n");
411-
412-
#ifdef CONFIG_SYSCTL
413396
if (!register_sysctl_paths(yama_sysctl_path, yama_sysctl_table))
414397
panic("Yama: sysctl registration failed.\n");
415-
#endif
416-
417-
return 0;
418398
}
399+
#else
400+
static inline void yama_init_sysctl(void) { }
401+
#endif /* CONFIG_SYSCTL */
419402

420-
security_initcall(yama_init);
403+
void __init yama_add_hooks(void)
404+
{
405+
pr_info("Yama: becoming mindful.\n");
406+
security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks));
407+
yama_init_sysctl();
408+
}

0 commit comments

Comments
 (0)