| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Yama Linux Security Module |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (C) 2010 Canonical, Ltd. |
|---|
| 7 | 8 | * Copyright (C) 2011 The Chromium OS Authors. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2, as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | | - * |
|---|
| 13 | 9 | */ |
|---|
| 14 | 10 | |
|---|
| 15 | 11 | #include <linux/lsm_hooks.h> |
|---|
| .. | .. |
|---|
| 103 | 99 | info->access = access; |
|---|
| 104 | 100 | info->target = target; |
|---|
| 105 | 101 | info->agent = agent; |
|---|
| 106 | | - if (task_work_add(current, &info->work, true) == 0) |
|---|
| 102 | + if (task_work_add(current, &info->work, TWA_RESUME) == 0) |
|---|
| 107 | 103 | return; /* success */ |
|---|
| 108 | 104 | |
|---|
| 109 | 105 | WARN(1, "report_access called from exiting task"); |
|---|
| .. | .. |
|---|
| 206 | 202 | * yama_task_free - check for task_pid to remove from exception list |
|---|
| 207 | 203 | * @task: task being removed |
|---|
| 208 | 204 | */ |
|---|
| 209 | | -void yama_task_free(struct task_struct *task) |
|---|
| 205 | +static void yama_task_free(struct task_struct *task) |
|---|
| 210 | 206 | { |
|---|
| 211 | 207 | yama_ptracer_del(task, task); |
|---|
| 212 | 208 | } |
|---|
| .. | .. |
|---|
| 222 | 218 | * Return 0 on success, -ve on error. -ENOSYS is returned when Yama |
|---|
| 223 | 219 | * does not handle the given option. |
|---|
| 224 | 220 | */ |
|---|
| 225 | | -int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
|---|
| 221 | +static int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
|---|
| 226 | 222 | unsigned long arg4, unsigned long arg5) |
|---|
| 227 | 223 | { |
|---|
| 228 | 224 | int rc = -ENOSYS; |
|---|
| .. | .. |
|---|
| 401 | 397 | * |
|---|
| 402 | 398 | * Returns 0 if following the ptrace is allowed, -ve on error. |
|---|
| 403 | 399 | */ |
|---|
| 404 | | -int yama_ptrace_traceme(struct task_struct *parent) |
|---|
| 400 | +static int yama_ptrace_traceme(struct task_struct *parent) |
|---|
| 405 | 401 | { |
|---|
| 406 | 402 | int rc = 0; |
|---|
| 407 | 403 | |
|---|
| .. | .. |
|---|
| 434 | 430 | |
|---|
| 435 | 431 | #ifdef CONFIG_SYSCTL |
|---|
| 436 | 432 | static int yama_dointvec_minmax(struct ctl_table *table, int write, |
|---|
| 437 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
|---|
| 433 | + void *buffer, size_t *lenp, loff_t *ppos) |
|---|
| 438 | 434 | { |
|---|
| 439 | 435 | struct ctl_table table_copy; |
|---|
| 440 | 436 | |
|---|
| .. | .. |
|---|
| 449 | 445 | return proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos); |
|---|
| 450 | 446 | } |
|---|
| 451 | 447 | |
|---|
| 452 | | -static int zero; |
|---|
| 453 | 448 | static int max_scope = YAMA_SCOPE_NO_ATTACH; |
|---|
| 454 | 449 | |
|---|
| 455 | | -struct ctl_path yama_sysctl_path[] = { |
|---|
| 450 | +static struct ctl_path yama_sysctl_path[] = { |
|---|
| 456 | 451 | { .procname = "kernel", }, |
|---|
| 457 | 452 | { .procname = "yama", }, |
|---|
| 458 | 453 | { } |
|---|
| .. | .. |
|---|
| 465 | 460 | .maxlen = sizeof(int), |
|---|
| 466 | 461 | .mode = 0644, |
|---|
| 467 | 462 | .proc_handler = yama_dointvec_minmax, |
|---|
| 468 | | - .extra1 = &zero, |
|---|
| 463 | + .extra1 = SYSCTL_ZERO, |
|---|
| 469 | 464 | .extra2 = &max_scope, |
|---|
| 470 | 465 | }, |
|---|
| 471 | 466 | { } |
|---|
| .. | .. |
|---|
| 479 | 474 | static inline void yama_init_sysctl(void) { } |
|---|
| 480 | 475 | #endif /* CONFIG_SYSCTL */ |
|---|
| 481 | 476 | |
|---|
| 482 | | -void __init yama_add_hooks(void) |
|---|
| 477 | +static int __init yama_init(void) |
|---|
| 483 | 478 | { |
|---|
| 484 | 479 | pr_info("Yama: becoming mindful.\n"); |
|---|
| 485 | 480 | security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks), "yama"); |
|---|
| 486 | 481 | yama_init_sysctl(); |
|---|
| 482 | + return 0; |
|---|
| 487 | 483 | } |
|---|
| 484 | + |
|---|
| 485 | +DEFINE_LSM(yama) = { |
|---|
| 486 | + .name = "yama", |
|---|
| 487 | + .init = yama_init, |
|---|
| 488 | +}; |
|---|