aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2012-09-04 16:32:13 -0400
committerJames Morris <james.l.morris@oracle.com>2012-09-05 17:12:31 -0400
commitc6993e4ac002c92bc75379212e9179c36d4bf7ee (patch)
treecdb4c800ea3cf4003b07087166cc767dab79032f /security
parent81198078d7da4240f3cbfc2c6a8ea6cd417f51a7 (diff)
security: allow Yama to be unconditionally stacked
Unconditionally call Yama when CONFIG_SECURITY_YAMA_STACKED is selected, no matter what LSM module is primary. Ubuntu and Chrome OS already carry patches to do this, and Fedora has voiced interest in doing this as well. Instead of having multiple distributions (or LSM authors) carrying these patches, just allow Yama to be called unconditionally when selected by the new CONFIG. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com> Acked-by: Eric Paris <eparis@redhat.com> Acked-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'security')
-rw-r--r--security/security.c21
-rw-r--r--security/yama/Kconfig8
-rw-r--r--security/yama/yama_lsm.c14
3 files changed, 39 insertions, 4 deletions
diff --git a/security/security.c b/security/security.c
index 860aeb349cb3..68c1b9b45d93 100644
--- a/security/security.c
+++ b/security/security.c
@@ -136,11 +136,23 @@ int __init register_security(struct security_operations *ops)
136 136
137int security_ptrace_access_check(struct task_struct *child, unsigned int mode) 137int security_ptrace_access_check(struct task_struct *child, unsigned int mode)
138{ 138{
139#ifdef CONFIG_SECURITY_YAMA_STACKED
140 int rc;
141 rc = yama_ptrace_access_check(child, mode);
142 if (rc)
143 return rc;
144#endif
139 return security_ops->ptrace_access_check(child, mode); 145 return security_ops->ptrace_access_check(child, mode);
140} 146}
141 147
142int security_ptrace_traceme(struct task_struct *parent) 148int security_ptrace_traceme(struct task_struct *parent)
143{ 149{
150#ifdef CONFIG_SECURITY_YAMA_STACKED
151 int rc;
152 rc = yama_ptrace_traceme(parent);
153 if (rc)
154 return rc;
155#endif
144 return security_ops->ptrace_traceme(parent); 156 return security_ops->ptrace_traceme(parent);
145} 157}
146 158
@@ -761,6 +773,9 @@ int security_task_create(unsigned long clone_flags)
761 773
762void security_task_free(struct task_struct *task) 774void security_task_free(struct task_struct *task)
763{ 775{
776#ifdef CONFIG_SECURITY_YAMA_STACKED
777 yama_task_free(task);
778#endif
764 security_ops->task_free(task); 779 security_ops->task_free(task);
765} 780}
766 781
@@ -876,6 +891,12 @@ int security_task_wait(struct task_struct *p)
876int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, 891int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
877 unsigned long arg4, unsigned long arg5) 892 unsigned long arg4, unsigned long arg5)
878{ 893{
894#ifdef CONFIG_SECURITY_YAMA_STACKED
895 int rc;
896 rc = yama_task_prctl(option, arg2, arg3, arg4, arg5);
897 if (rc != -ENOSYS)
898 return rc;
899#endif
879 return security_ops->task_prctl(option, arg2, arg3, arg4, arg5); 900 return security_ops->task_prctl(option, arg2, arg3, arg4, arg5);
880} 901}
881 902
diff --git a/security/yama/Kconfig b/security/yama/Kconfig
index 51d6709d8bbd..20ef5143c0c0 100644
--- a/security/yama/Kconfig
+++ b/security/yama/Kconfig
@@ -11,3 +11,11 @@ config SECURITY_YAMA
11 Further information can be found in Documentation/security/Yama.txt. 11 Further information can be found in Documentation/security/Yama.txt.
12 12
13 If you are unsure how to answer this question, answer N. 13 If you are unsure how to answer this question, answer N.
14
15config SECURITY_YAMA_STACKED
16 bool "Yama stacked with other LSMs"
17 depends on SECURITY_YAMA
18 default n
19 help
20 When Yama is built into the kernel, force it to stack with the
21 selected primary LSM.
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index d51b7c76c37d..9ca43c1ea630 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -100,7 +100,7 @@ static void yama_ptracer_del(struct task_struct *tracer,
100 * yama_task_free - check for task_pid to remove from exception list 100 * yama_task_free - check for task_pid to remove from exception list
101 * @task: task being removed 101 * @task: task being removed
102 */ 102 */
103static void yama_task_free(struct task_struct *task) 103void yama_task_free(struct task_struct *task)
104{ 104{
105 yama_ptracer_del(task, task); 105 yama_ptracer_del(task, task);
106} 106}
@@ -116,7 +116,7 @@ static void yama_task_free(struct task_struct *task)
116 * Return 0 on success, -ve on error. -ENOSYS is returned when Yama 116 * Return 0 on success, -ve on error. -ENOSYS is returned when Yama
117 * does not handle the given option. 117 * does not handle the given option.
118 */ 118 */
119static int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, 119int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3,
120 unsigned long arg4, unsigned long arg5) 120 unsigned long arg4, unsigned long arg5)
121{ 121{
122 int rc; 122 int rc;
@@ -243,7 +243,7 @@ static int ptracer_exception_found(struct task_struct *tracer,
243 * 243 *
244 * Returns 0 if following the ptrace is allowed, -ve on error. 244 * Returns 0 if following the ptrace is allowed, -ve on error.
245 */ 245 */
246static int yama_ptrace_access_check(struct task_struct *child, 246int yama_ptrace_access_check(struct task_struct *child,
247 unsigned int mode) 247 unsigned int mode)
248{ 248{
249 int rc; 249 int rc;
@@ -296,7 +296,7 @@ static int yama_ptrace_access_check(struct task_struct *child,
296 * 296 *
297 * Returns 0 if following the ptrace is allowed, -ve on error. 297 * Returns 0 if following the ptrace is allowed, -ve on error.
298 */ 298 */
299static int yama_ptrace_traceme(struct task_struct *parent) 299int yama_ptrace_traceme(struct task_struct *parent)
300{ 300{
301 int rc; 301 int rc;
302 302
@@ -330,6 +330,7 @@ static int yama_ptrace_traceme(struct task_struct *parent)
330 return rc; 330 return rc;
331} 331}
332 332
333#ifndef CONFIG_SECURITY_YAMA_STACKED
333static struct security_operations yama_ops = { 334static struct security_operations yama_ops = {
334 .name = "yama", 335 .name = "yama",
335 336
@@ -338,6 +339,7 @@ static struct security_operations yama_ops = {
338 .task_prctl = yama_task_prctl, 339 .task_prctl = yama_task_prctl,
339 .task_free = yama_task_free, 340 .task_free = yama_task_free,
340}; 341};
342#endif
341 343
342#ifdef CONFIG_SYSCTL 344#ifdef CONFIG_SYSCTL
343static int yama_dointvec_minmax(struct ctl_table *table, int write, 345static int yama_dointvec_minmax(struct ctl_table *table, int write,
@@ -384,13 +386,17 @@ static struct ctl_table yama_sysctl_table[] = {
384 386
385static __init int yama_init(void) 387static __init int yama_init(void)
386{ 388{
389#ifndef CONFIG_SECURITY_YAMA_STACKED
387 if (!security_module_enable(&yama_ops)) 390 if (!security_module_enable(&yama_ops))
388 return 0; 391 return 0;
392#endif
389 393
390 printk(KERN_INFO "Yama: becoming mindful.\n"); 394 printk(KERN_INFO "Yama: becoming mindful.\n");
391 395
396#ifndef CONFIG_SECURITY_YAMA_STACKED
392 if (register_security(&yama_ops)) 397 if (register_security(&yama_ops))
393 panic("Yama: kernel registration failed.\n"); 398 panic("Yama: kernel registration failed.\n");
399#endif
394 400
395#ifdef CONFIG_SYSCTL 401#ifdef CONFIG_SYSCTL
396 if (!register_sysctl_paths(yama_sysctl_path, yama_sysctl_table)) 402 if (!register_sysctl_paths(yama_sysctl_path, yama_sysctl_table))