Add module_load permission to can_load_kernmodule
PATCH 1/1 Add module_load permission to can_load_kernmodule
The "module_load" permission has been recently added to the "system" class (kernel 4.7).
The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
--- policy/modules/kernel/kernel.te | 4 ++++ 1 file changed, 4 insertions(+)
policy/modules/kernel/kernel.te +4 -0
@@ -18,6 +18,7 @@ attribute can_receive_kernel_messages; attribute can_dump_kernel; neverallow ~can_load_kernmodule self:capability sys_module; +neverallow ~can_load_kernmodule modules_object_t:system module_load; # domains with unconfined access to kernel resources attribute kern_unconfined;
@@ -216,6 +217,8 @@ allow kernel_t self:fd use; allow kernel_t debugfs_t:dir search_dir_perms; +allow kernel_t modules_object_t:system ~module_load; + allow kernel_t proc_t:dir list_dir_perms; allow kernel_t proc_t:file read_file_perms; allow kernel_t proc_t:lnk_file read_lnk_file_perms;
@@ -428,6 +431,7 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; + allow can_load_kernmodule modules_object_t:system module_load; # load_module() calls stop_machine() which # calls sched_setscheduler()
PATCH v2 1/1 Add module_load permission to can_load_kernmodule
The "module_load" permission has been recently added to the "system" class (kernel 4.7).
The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
--- policy/modules/kernel/kernel.te | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
policy/modules/kernel/kernel.te +4 -5
@@ -18,6 +18,7 @@ attribute can_receive_kernel_messages; attribute can_dump_kernel; neverallow ~can_load_kernmodule self:capability sys_module; +neverallow ~can_load_kernmodule modules_object_t:system module_load; # domains with unconfined access to kernel resources attribute kern_unconfined;
@@ -216,6 +217,8 @@ allow kernel_t self:fd use; allow kernel_t debugfs_t:dir search_dir_perms; +allow kernel_t modules_object_t:system ~module_load; + allow kernel_t proc_t:dir list_dir_perms; allow kernel_t proc_t:file read_file_perms; allow kernel_t proc_t:lnk_file read_lnk_file_perms;
@@ -428,11 +431,7 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule) + allow can_load_kernmodule modules_object_t:system module_load; } ########################################
PATCH v2 1/1 Add module_load permission to can_load_kernmodule
Quoted 17 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/kernel.te | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
policy/modules/kernel/kernel.te attribute can_receive_kernel_messages; · line 21
Quoted 4 lines
policy/modules/kernel/kernel.te +1
-0@@ -18,6 +18,7 @@ attribute can_receive_kernel_messages; attribute can_dump_kernel; neverallow ~can_load_kernmodule self:capability sys_module; +neverallow ~can_load_kernmodule modules_object_t:system module_load;
Problematic, as modules_object_t is not owned by this module.
Quoted 29 lines
policy/modules/kernel/kernel.te +3
-5# domains with unconfined access to kernel resources attribute kern_unconfined;@@ -216,6 +217,8 @@ allow kernel_t self:fd use; allow kernel_t debugfs_t:dir search_dir_perms; +allow kernel_t modules_object_t:system ~module_load; + allow kernel_t proc_t:dir list_dir_perms; allow kernel_t proc_t:file read_file_perms; allow kernel_t proc_t:lnk_file read_lnk_file_perms;@@ -428,11 +431,7 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule) + allow can_load_kernmodule modules_object_t:system module_load; } ########################################_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 1 line
Chris PeBenito
PATCH v3 1/1 Add module_load permission to can_load_kernmodule
The "module_load" permission has been recently added to the "system" class (kernel 4.7).
The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions (probably obsolete) are removed from the kernel module loading section.
--- policy/modules/kernel/files.te | 11 +++++++++++ policy/modules/kernel/kernel.te | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-)
--- refpolicy-git-06082016-orig/policy/modules/kernel/files.te 2016-08-06
21:26:43.284774157 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/files.te 2016-08-14
22:35:30.602463332 +0200
@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile)
########################################
#
+# Kernel module loading policy
+#
+
+neverallow ~can_load_kernmodule modules_object_t:system module_load; +
+if( ! secure_mode_insmod ) {
+ allow can_load_kernmodule modules_object_t:system module_load;
+}
+
+########################################
+#
# Unconfined access to this module
#
--- refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te 2016-08-09
16:09:48.811753763 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2016-08-14
22:35:47.997714250 +0200
@@ -216,6 +216,8 @@ allow kernel_t self:fd use;
allow kernel_t debugfs_t:dir search_dir_perms;
+allow kernel_t modules_object_t:system ~module_load; +
allow kernel_t proc_t:dir list_dir_perms; allow kernel_t proc_t:file read_file_perms; allow kernel_t proc_t:lnk_file read_lnk_file_perms;
@@ -428,11 +430,6 @@ optional_policy(`
if( ! secure_mode_insmod ) {
allow can_load_kernmodule self:capability sys_module;
-
- # load_module() calls stop_machine() which
- # calls sched_setscheduler()
- allow can_load_kernmodule self:capability sys_nice;
- kernel_setsched(can_load_kernmodule)
}
########################################
PATCH v3 1/1 Add module_load permission to can_load_kernmodule
Quoted 42 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions (probably obsolete) are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.te | 11 +++++++++++ policy/modules/kernel/kernel.te | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-)--- refpolicy-git-06082016-orig/policy/modules/kernel/files.te 2016-08-06
21:26:43.284774157 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/files.te 2016-08-14
22:35:30.602463332 +0200(quoted diff) +11
-1@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile) ######################################## # +# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system module_load; + +if( ! secure_mode_insmod ) { + allow can_load_kernmodule modules_object_t:system module_load; +} + +######################################## +# # Unconfined access to this module # --- refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te 2016-08-0916:09:48.811753763 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2016-08-14
22:35:47.997714250 +0200
policy/modules/kernel/kernel.te allow kernel_t self:fd use; · line 219
Quoted 4 lines
policy/modules/kernel/kernel.te +1
-0@@ -216,6 +216,8 @@ allow kernel_t self:fd use; allow kernel_t debugfs_t:dir search_dir_perms; +allow kernel_t modules_object_t:system ~module_load;
I can't make sense of this rule
policy/modules/kernel/kernel.te optional_policy(` · line 435
Quoted 13 lines
policy/modules/kernel/kernel.te +1
-5+ allow kernel_t proc_t:dir list_dir_perms; allow kernel_t proc_t:file read_file_perms; allow kernel_t proc_t:lnk_file read_lnk_file_perms;@@ -428,11 +430,6 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule)
I would not remove the above. Might break compatibility
Quoted 8 lines
policy/modules/kernel/kernel.te +0
-0} ########################################_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 648 bytes Desc: OpenPGP digital signature Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20160814/1de00de3/attachment.bin
PATCH v3 1/1 Add module_load permission to can_load_kernmodule
Hello Dominick.
Quoted 48 lines · Dominick Grift
Quoted 47 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system"
class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions (probably obsolete) are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>---
?policy/modules/kernel/files.te??|???11 +++++++++++ ?policy/modules/kernel/kernel.te |????7 ++----- ?2 files changed, 13 insertions(+), 5 deletions(-)--- refpolicy-git-06082016-orig/policy/modules/kernel/files.te 2016-08-06
21:26:43.284774157 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/files.te 20
16-08-14
22:35:30.602463332 +0200(quoted diff) +0
-0@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile)?
?########################################
?#(quoted diff) +4
-0+# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system
module_load;(quoted diff) +3
-0+ +if( ! secure_mode_insmod ) { + allow can_load_kernmodule modules_object_t:system
module_load;(quoted diff) +4
-0+} + +######################################## +#?# Unconfined access to this module
?#
?
--- refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te 2016-08-09
16:09:48.811753763 +0200
+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2
016-08-14
Quoted 8 lines
Quoted 6 lines
22:35:47.997714250 +0200
(quoted diff) +0
-0@@ -216,6 +216,8 @@ allow kernel_t self:fd use;?
?allowkernel_tdebugfs_t:dirsearch_dir_perms; ?
+allowkernel_tmodules_object_t:system ~module_load;I can't make sense of this rule
It's a mistake and it has been removed in the latest forthcoming version of this patch.
Quoted 7 lines
Quoted 7 lines
+
?allowkernel_tproc_t:dirlist_dir_perms; ?allowkernel_tproc_t:fileread_file_perms; ?allowkernel_tproc_t:lnk_fileread_lnk_file_perms;(quoted diff) +0
-0@@ -428,11 +430,6 @@ optional_policy(`?
?if( !secure_mode_insmod) {
Quoted 8 lines
policy/modules/kernel/kernel.te optional_policy(` · line 435
Quoted 6 lines
? allow
can_load_kernmoduleself:capabilitysys_module;policy/modules/kernel/kernel.te +0
-5- - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule)I would not remove the above. Might break compatibility
I have checked backwards up to kernel version 2.6.37 and there is no trace of calls to sched_setsched().
Also, even if there was such a call, it was most probably something wrong !
Therefore, I oppose reverting that (sys_nice + kernel_setsched()).
Regards,
Guido
PATCH v4 1/1 Add module_load permission to can_load_kernmodule
In reply to Guido TrentalanciaThe "module_load" permission has been recently added to the "system" class (kernel 4.7).
The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
--- policy/modules/kernel/files.te | 11 +++++++++++ policy/modules/kernel/kernel.te | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-)
policy/modules/kernel/files.te +11 -0
@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile) ######################################## # +# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system module_load; + +if( ! secure_mode_insmod ) { + allow can_load_kernmodule modules_object_t:system module_load; +} + +######################################## +# # Unconfined access to this module #
policy/modules/kernel/kernel.te +0 -5
@@ -428,11 +428,6 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule) } ########################################
PATCH v4 1/1 Add module_load permission to can_load_kernmodule
Quoted 19 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.te | 11 +++++++++++ policy/modules/kernel/kernel.te | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-)policy/modules/kernel/files.te +0
-0@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile)
policy/modules/kernel/files.te fs_associate_tmpfs(tmpfsfile) · line 218
Quoted 10 lines
policy/modules/kernel/files.te +8
-0######################################## # +# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system module_load; + +if( ! secure_mode_insmod ) { + allow can_load_kernmodule modules_object_t:system module_load; +}
Now we have the problem where can_load_kernmodule isn't owned by this module. You'll have to create the first neverallow interface I think.
Quoted 9 lines
policy/modules/kernel/files.te +2
-0+######################################## +# # Unconfined access to this module #policy/modules/kernel/kernel.te +0
-0@@ -428,11 +428,6 @@ optional_policy(`
policy/modules/kernel/kernel.te optional_policy(` · line 433
Quoted 10 lines
policy/modules/kernel/kernel.te +0
-5if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule) } ########################################
I also agree with Dominick on this. These are relatively uninteresting permissions compared to the sys_module, so until we have some explanation, I'd prefer to keep it. I tried looked at Red Hat bugzilla, as this came from Dan Walsh, but it's all the way back from 2011, so it's not coming up easily for me.
Signature · 1 line
Chris PeBenito
PATCH v4 1/1 Add module_load permission to can_load_kernmodule
Hello Christopher,
thanks for your feedback on this patch !
Quoted 32 lines · Chris PeBenito
Quoted 31 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system"
class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>---
?policy/modules/kernel/files.te??|???11 +++++++++++ ?policy/modules/kernel/kernel.te |????5 ----- ?2 files changed, 11 insertions(+), 5 deletions(-)--- refpolicy-git-06082016-orig/policy/modules/kernel/files.te
2016-08-06 21:26:43.284774157 +0200+++ refpolicy-git-06082016/policy/modules/kernel/files.te 20
16-08-14 22:35:30.602463332 +0200(quoted diff) +0
-0@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile)?########################################
?#policy/modules/kernel/files.te +4
-0+# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system
module_load;(quoted diff) +2
-0+ +if( ! secure_mode_insmod ) {
Quoted 8 lines
Quoted 3 lines
(quoted diff) +1
-0+ allow can_load_kernmodule modules_object_t:system
module_load;
+}Now we have the problem where
can_load_kernmoduleisn't owned by this?
module.??You'll have to create the first neverallow interface I think.
I am sorry but I do not understand what you mean.
It compiles fine. What change do you propose exactly ?
Quoted 20 lines
Quoted 20 lines
policy/modules/kernel/files.te +2
-0+######################################## +#?# Unconfined access to this module
?#--- refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te
2016-08-09 16:09:48.811753763 +0200+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2
016-08-16 00:09:58.411688357 +0200policy/modules/kernel/kernel.te +0
-5@@ -428,11 +428,6 @@ optional_policy(` ?if( ! secure_mode_insmod ) { ? allow can_load_kernmodule self:capability sys_module; - - # load_module() calls stop_machine() which - # calls sched_setscheduler() - allow can_load_kernmodule self:capability sys_nice; - kernel_setsched(can_load_kernmodule) ?}
Quoted 9 lines
Quoted 1 line
?########################################
I also agree with Dominick on this.??These are relatively uninteresting?
permissions compared to thesys_module, so until we have some? explanation, I'd prefer to keep it.??I tried looked at Red Hat bugzilla,?
as this came from Dan Walsh, but it's all the way back from 2011, so? it's not coming up easily for me.
That's fine, I'll recreate the patch with the sys_nice permission back in, although I still think it is much better to avoid granting that.
I will add a short note so that hopefully we'll be able to get an explanation one day...
Best regards,
Guido
PATCH v4 1/1 Add module_load permission to can_load_kernmodule
Quoted 46 lines · Guido Trentalancia
Hello Christopher,
thanks for your feedback on this patch !
Quoted 32 lines · Chris PeBenito
Quoted 31 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system"
class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
A couple of unneeded permissions are removed from the kernel module loading section.
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.te | 11 +++++++++++ policy/modules/kernel/kernel.te | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-)--- refpolicy-git-06082016-orig/policy/modules/kernel/files.te
2016-08-06 21:26:43.284774157 +0200+++ refpolicy-git-06082016/policy/modules/kernel/files.te 20
16-08-14 22:35:30.602463332 +0200policy/modules/kernel/files.te +6
-0@@ -208,6 +208,17 @@ fs_associate_tmpfs(tmpfsfile) ######################################## # +# Kernel module loading policy +# + +neverallow ~can_load_kernmodule modules_object_t:system module_load; + +if( ! secure_mode_insmod ) {Quoted 8 lines
Review fs_associate_tmpfs(tmpfsfile) · line 220
Quoted 3 lines
(quoted diff) +2
-0+ allow can_load_kernmodule modules_object_t:system module_load; +}Now we have the problem where
can_load_kernmoduleisn't owned by this
module. You'll have to create the first neverallow interface I think.
Quoted 3 lines
I am sorry but I do not understand what you mean.
It compiles fine. What change do you propose exactly ?
It compiles fine because the kernel and files modules are always in the base.pp. However the refpolicy module encapsulation should be preserved. The difficulty is can_load_kernmodule is owned by the kernel module and modules_object_t is owned by the files module, so you can't have a raw rule by itself, so you need an interface.
Signature · 1 line
Chris PeBenito
PATCH v5 1/1 Add module_load permission to can_load_kernmodule
In reply to Guido TrentalanciaThe "module_load" permission has been recently added to the "system" class (kernel 4.7).
The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
To preserve the module encapsulation, a new interface is defined in the kernel files module and that interface is then used in the kernel module.
A short note is added about unneeded permissions that set the kernel scheduling parameters (might lead to service disruption).
--- policy/modules/kernel/files.if | 19 +++++++++++++++++++ policy/modules/kernel/kernel.te | 4 ++++ 2 files changed, 23 insertions(+)
policy/modules/kernel/files.if +19 -0
@@ -4158,6 +4158,25 @@ interface(`files_kernel_modules_filetran ######################################## ## <summary> +## Load kernel module files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`files_load_kernel_modules',` + gen_require(` + type modules_object_t; + ') + + files_read_kernel_modules($1) + allow $1 modules_object_t:system module_load; +') + +######################################## +## <summary> ## List world-readable directories. ## </summary> ## <param name="domain">
policy/modules/kernel/kernel.te +4 -0
@@ -429,8 +429,12 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; + files_load_kernel_modules(can_load_kernmodule) + # load_module() calls stop_machine() which # calls sched_setscheduler() + # gt: there seems to be no trace of the above, at + # least in kernel versions greater than 2.6.37... allow can_load_kernmodule self:capability sys_nice; kernel_setsched(can_load_kernmodule) }
PATCH v5 1/1 Add module_load permission to can_load_kernmodule
Quoted 6 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
Quoted 6 lines
To preserve the module encapsulation, a new interface is defined in the kernel files module and that interface is then used in the kernel module.
A short note is added about unneeded permissions that set the kernel scheduling parameters (might lead to service disruption).
The policy change is fine, but I want to think about the name of the interface. The name doesn't seem right, but I can't immediately come up with a better one.
Quoted 50 lines
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.if | 19 +++++++++++++++++++ policy/modules/kernel/kernel.te | 4 ++++ 2 files changed, 23 insertions(+)policy/modules/kernel/files.if +19
-0@@ -4158,6 +4158,25 @@ interface(`files_kernel_modules_filetran ######################################## ## <summary> +## Load kernel module files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`files_load_kernel_modules',` + gen_require(` + type modules_object_t; + ') + + files_read_kernel_modules($1) + allow $1 modules_object_t:system module_load; +') + +######################################## +## <summary> ## List world-readable directories. ## </summary> ## <param name="domain">policy/modules/kernel/kernel.te +4
-0@@ -429,8 +429,12 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; + files_load_kernel_modules(can_load_kernmodule) + # load_module() calls stop_machine() which # calls sched_setscheduler() + # gt: there seems to be no trace of the above, at + # least in kernel versions greater than 2.6.37... allow can_load_kernmodule self:capability sys_nice; kernel_setsched(can_load_kernmodule) }
Signature · 1 line
Chris PeBenito
PATCH v5 1/1 Add module_load permission to can_load_kernmodule
Hello Christopher.
Quoted 12 lines · Chris PeBenito
Quoted 11 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system"
class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
To preserve the module encapsulation, a new interface is defined in the kernel files module and that interface is then used in the kernel module.
Quoted 7 lines
Quoted 2 lines
A short note is added about unneeded permissions that set the kernel scheduling parameters (might lead to service disruption).
The policy change is fine, but I want to think about the name of the? interface.??The name doesn't seem right, but I can't immediately come up?
with a better one.
An alternative name could be:
files_kernel_module_load()
Quoted 44 lines
Quoted 44 lines
Signed-off-by Guido Trentalancia <[email protected]>---
?policy/modules/kernel/files.if??|???19 +++++++++++++++++++ ?policy/modules/kernel/kernel.te |????4 ++++
?2 files changed, 23 insertions(+)--- refpolicy-git-06082016-orig/policy/modules/kernel/files.if
2016-08-06 21:26:43.284774157 +0200+++ refpolicy-git-06082016/policy/modules/kernel/files.if 20
16-08-19 15:05:34.503054733 +0200(quoted diff) +0
-0@@ -4158,6 +4158,25 @@ interface(`files_kernel_modules_filetran?########################################
?## <summary>policy/modules/kernel/files.if +19
-0+## Load kernel module files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`files_load_kernel_modules',` + gen_require(` + type modules_object_t; + ') + + files_read_kernel_modules($1) + allow $1 modules_object_t:system module_load; +') + +######################################## +## <summary>?## List world-readable directories.
?## </summary>
?## <param name="domain">
--- refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te2016-08-09 16:09:48.811753763 +0200+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2
016-08-19 15:07:21.169666858 +0200(quoted diff) +0
-0@@ -429,8 +429,12 @@ optional_policy(` ?if( ! secure_mode_insmod ) { ? allow can_load_kernmodule self:capability sys_module;
Quoted 10 lines
Quoted 10 lines
policy/modules/kernel/kernel.te +2
-0+ files_load_kernel_modules(can_load_kernmodule) +? #
load_module()callsstop_machine()which
? # callssched_setscheduler()policy/modules/kernel/kernel.te +2
-0+ # gt: there seems to be no trace of the above, at + # least in kernel versions greater than 2.6.37...? allow
can_load_kernmoduleself:capabilitysys_nice;
?kernel_setsched(can_load_kernmodule)
?}
?
Best regards,
Guido
PATCH v5 1/1 Add module_load permission to can_load_kernmodule
In reply to Guido TrentalanciaQuoted 6 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
Quoted 6 lines
To preserve the module encapsulation, a new interface is defined in the kernel files module and that interface is then used in the kernel module.
A short note is added about unneeded permissions that set the kernel scheduling parameters (might lead to service disruption).
I couldn't come up with a better interface name, so I've merged this patch.
Quoted 50 lines
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.if | 19 +++++++++++++++++++ policy/modules/kernel/kernel.te | 4 ++++ 2 files changed, 23 insertions(+)policy/modules/kernel/files.if +19
-0@@ -4158,6 +4158,25 @@ interface(`files_kernel_modules_filetran ######################################## ## <summary> +## Load kernel module files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`files_load_kernel_modules',` + gen_require(` + type modules_object_t; + ') + + files_read_kernel_modules($1) + allow $1 modules_object_t:system module_load; +') + +######################################## +## <summary> ## List world-readable directories. ## </summary> ## <param name="domain">policy/modules/kernel/kernel.te +4
-0@@ -429,8 +429,12 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; + files_load_kernel_modules(can_load_kernmodule) + # load_module() calls stop_machine() which # calls sched_setscheduler() + # gt: there seems to be no trace of the above, at + # least in kernel versions greater than 2.6.37... allow can_load_kernmodule self:capability sys_nice; kernel_setsched(can_load_kernmodule) }
Signature · 1 line
Chris PeBenito
PATCH v5 1/1 Add module_load permission to can_load_kernmodule
Hello Christopher.
You've done the right thing.
Thanks for sorting this out.
I am finally seeing the light with the gnome and dbus modules! It comes at the cost of confining the whole desktop, but so far so good...
I have removed the variable types $1_dbusd_t: it doesn't work, end of the story, it's poor design in my opinion because it leads to an unmanageable situation (conflicting type rules).
Regards,
Guido
Quoted 74 lines · Chris PeBenito
Quoted 6 lines · Guido Trentalancia
The "
module_load" permission has been recently added to the "system" class (kernel 4.7).The following patch updates the Reference Policy so that the new permission is allowed when a kernel module should be loaded.
Quoted 6 lines
To preserve the module encapsulation, a new interface is defined in the kernel files module and that interface is then used in the kernel module.
A short note is added about unneeded permissions that set the kernel scheduling parameters (might lead to service disruption).
I couldn't come up with a better interface name, so I've merged this patch.
Quoted 7 lines
Signed-off-by Guido Trentalancia <[email protected]>--- policy/modules/kernel/files.if | 19 +++++++++++++++++++ policy/modules/kernel/kernel.te | 4 ++++ 2 files changed, 23 insertions(+)---
refpolicy-git-06082016-orig/policy/modules/kernel/files.if 2016-08-06
21:26:43.284774157 +0200Quoted 1 line
+++ refpolicy-git-06082016/policy/modules/kernel/files.if 2016-08-19
15:05:34.503054733 +0200
Quoted 17 lines
policy/modules/kernel/files.if +13
-0@@ -4158,6 +4158,25 @@ interface(`files_kernel_modules_filetran ######################################## ## <summary> +## Load kernel module files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`files_load_kernel_modules',` + gen_require(` + type modules_object_t; + ') +policy/modules/kernel/files.if interface(`files_kernel_modules_filetran
Quoted 10 lines
policy/modules/kernel/files.if +6
-1+ files_read_kernel_modules($1) + allow $1 modules_object_t:system module_load; +') + +######################################## +## <summary> ## List world-readable directories. ## </summary> ## <param name="domain"> ---refpolicy-git-06082016-orig/policy/modules/kernel/kernel.te 2016-08-09
16:09:48.811753763 +0200Quoted 1 line
+++ refpolicy-git-06082016/policy/modules/kernel/kernel.te 2016-08-19
15:07:21.169666858 +0200
Quoted 14 lines
policy/modules/kernel/kernel.te +4
-0@@ -429,8 +429,12 @@ optional_policy(` if( ! secure_mode_insmod ) { allow can_load_kernmodule self:capability sys_module; + files_load_kernel_modules(can_load_kernmodule) + # load_module() calls stop_machine() which # calls sched_setscheduler() + # gt: there seems to be no trace of the above, at + # least in kernel versions greater than 2.6.37... allow can_load_kernmodule self:capability sys_nice; kernel_setsched(can_load_kernmodule) }