1 |
commit: c4d506d919d9584fb61e3ebfce7ee718eb866b27 |
2 |
Author: Chris PeBenito <pebenito <AT> ieee <DOT> org> |
3 |
AuthorDate: Fri Mar 19 19:50:06 2021 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 2 18:54:58 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=c4d506d9 |
7 |
|
8 |
kernel: Add dontaudits when secure_mode_insmod is enabled. |
9 |
|
10 |
Signed-off-by: Chris PeBenito <pebenito <AT> ieee.org> |
11 |
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org> |
12 |
|
13 |
policy/modules/kernel/files.if | 19 +++++++++++++++++++ |
14 |
policy/modules/kernel/kernel.te | 15 ++++++++++++++- |
15 |
2 files changed, 33 insertions(+), 1 deletion(-) |
16 |
|
17 |
diff --git a/policy/modules/kernel/files.if b/policy/modules/kernel/files.if |
18 |
index 0687a435..349b8696 100644 |
19 |
--- a/policy/modules/kernel/files.if |
20 |
+++ b/policy/modules/kernel/files.if |
21 |
@@ -4369,6 +4369,25 @@ interface(`files_load_kernel_modules',` |
22 |
allow $1 modules_object_t:system module_load; |
23 |
') |
24 |
|
25 |
+######################################## |
26 |
+## <summary> |
27 |
+## Load kernel module files. |
28 |
+## </summary> |
29 |
+## <param name="domain"> |
30 |
+## <summary> |
31 |
+## Domain allowed access. |
32 |
+## </summary> |
33 |
+## </param> |
34 |
+# |
35 |
+interface(`files_dontaudit_load_kernel_modules',` |
36 |
+ gen_require(` |
37 |
+ type modules_object_t; |
38 |
+ ') |
39 |
+ |
40 |
+ dontaudit $1 modules_object_t:file read_file_perms; |
41 |
+ dontaudit $1 modules_object_t:system module_load; |
42 |
+') |
43 |
+ |
44 |
######################################## |
45 |
## <summary> |
46 |
## List world-readable directories. |
47 |
|
48 |
diff --git a/policy/modules/kernel/kernel.te b/policy/modules/kernel/kernel.te |
49 |
index c44f49ed..2bd3f924 100644 |
50 |
--- a/policy/modules/kernel/kernel.te |
51 |
+++ b/policy/modules/kernel/kernel.te |
52 |
@@ -497,7 +497,20 @@ optional_policy(` |
53 |
# Kernel module loading policy |
54 |
# |
55 |
|
56 |
-if( ! secure_mode_insmod ) { |
57 |
+if(secure_mode_insmod) { |
58 |
+ dontaudit can_load_kernmodule self:capability sys_module; |
59 |
+ dontaudit can_load_kernmodule self:system module_load; |
60 |
+ |
61 |
+ files_dontaudit_load_kernel_modules(can_load_kernmodule) |
62 |
+ |
63 |
+ # load_module() calls stop_machine() which |
64 |
+ # calls sched_setscheduler() |
65 |
+ # gt: there seems to be no trace of the above, at |
66 |
+ # least in kernel versions greater than 2.6.37... |
67 |
+ dontaudit can_load_kernmodule self:capability sys_nice; |
68 |
+ dontaudit can_load_kernmodule kernel_t:process setsched; |
69 |
+ dontaudit can_load_kernmodule kernel_t:key search; |
70 |
+} else { |
71 |
allow can_load_kernmodule self:capability sys_module; |
72 |
allow can_load_kernmodule self:system module_load; |