diff options
author | Kees Cook <keescook@chromium.org> | 2012-09-04 16:32:13 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2012-09-05 17:12:31 -0400 |
commit | c6993e4ac002c92bc75379212e9179c36d4bf7ee (patch) | |
tree | cdb4c800ea3cf4003b07087166cc767dab79032f /security/yama/yama_lsm.c | |
parent | 81198078d7da4240f3cbfc2c6a8ea6cd417f51a7 (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/yama/yama_lsm.c')
-rw-r--r-- | security/yama/yama_lsm.c | 14 |
1 files changed, 10 insertions, 4 deletions
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 | */ |
103 | static void yama_task_free(struct task_struct *task) | 103 | void 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 | */ |
119 | static int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 119 | int 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 | */ |
246 | static int yama_ptrace_access_check(struct task_struct *child, | 246 | int 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 | */ |
299 | static int yama_ptrace_traceme(struct task_struct *parent) | 299 | int 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 | ||
333 | static struct security_operations yama_ops = { | 334 | static 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 |
343 | static int yama_dointvec_minmax(struct ctl_table *table, int write, | 345 | static int yama_dointvec_minmax(struct ctl_table *table, int write, |
@@ -384,13 +386,17 @@ static struct ctl_table yama_sysctl_table[] = { | |||
384 | 386 | ||
385 | static __init int yama_init(void) | 387 | static __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)) |