hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/security/yama/yama_lsm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Yama Linux Security Module
34 *
....@@ -5,11 +6,6 @@
56 *
67 * Copyright (C) 2010 Canonical, Ltd.
78 * 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
- *
139 */
1410
1511 #include <linux/lsm_hooks.h>
....@@ -103,7 +99,7 @@
10399 info->access = access;
104100 info->target = target;
105101 info->agent = agent;
106
- if (task_work_add(current, &info->work, true) == 0)
102
+ if (task_work_add(current, &info->work, TWA_RESUME) == 0)
107103 return; /* success */
108104
109105 WARN(1, "report_access called from exiting task");
....@@ -206,7 +202,7 @@
206202 * yama_task_free - check for task_pid to remove from exception list
207203 * @task: task being removed
208204 */
209
-void yama_task_free(struct task_struct *task)
205
+static void yama_task_free(struct task_struct *task)
210206 {
211207 yama_ptracer_del(task, task);
212208 }
....@@ -222,7 +218,7 @@
222218 * Return 0 on success, -ve on error. -ENOSYS is returned when Yama
223219 * does not handle the given option.
224220 */
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,
226222 unsigned long arg4, unsigned long arg5)
227223 {
228224 int rc = -ENOSYS;
....@@ -401,7 +397,7 @@
401397 *
402398 * Returns 0 if following the ptrace is allowed, -ve on error.
403399 */
404
-int yama_ptrace_traceme(struct task_struct *parent)
400
+static int yama_ptrace_traceme(struct task_struct *parent)
405401 {
406402 int rc = 0;
407403
....@@ -434,7 +430,7 @@
434430
435431 #ifdef CONFIG_SYSCTL
436432 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)
438434 {
439435 struct ctl_table table_copy;
440436
....@@ -449,10 +445,9 @@
449445 return proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos);
450446 }
451447
452
-static int zero;
453448 static int max_scope = YAMA_SCOPE_NO_ATTACH;
454449
455
-struct ctl_path yama_sysctl_path[] = {
450
+static struct ctl_path yama_sysctl_path[] = {
456451 { .procname = "kernel", },
457452 { .procname = "yama", },
458453 { }
....@@ -465,7 +460,7 @@
465460 .maxlen = sizeof(int),
466461 .mode = 0644,
467462 .proc_handler = yama_dointvec_minmax,
468
- .extra1 = &zero,
463
+ .extra1 = SYSCTL_ZERO,
469464 .extra2 = &max_scope,
470465 },
471466 { }
....@@ -479,9 +474,15 @@
479474 static inline void yama_init_sysctl(void) { }
480475 #endif /* CONFIG_SYSCTL */
481476
482
-void __init yama_add_hooks(void)
477
+static int __init yama_init(void)
483478 {
484479 pr_info("Yama: becoming mindful.\n");
485480 security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks), "yama");
486481 yama_init_sysctl();
482
+ return 0;
487483 }
484
+
485
+DEFINE_LSM(yama) = {
486
+ .name = "yama",
487
+ .init = yama_init,
488
+};