From: Bruno E. O. Meneguele <hidden> Date: 2017-10-20 19:19:26
This patchset ensure that IMA's modules checking policy:
measure func=MODULE_CHECK uid=0
rely on the correct value of CONFIG_MODULE_SIG_FORCE, since the way it
is today the code completely ignores the module.sig_enforce cmdline
param, which behaves in a OR logic with the CONFIG value
(CONFIG_MODULE_SIG_FORCE || module.sig_enforce). That said, everytime a
module would load, in the current checking code, when the kernel was not
compiled with the CONFIG set the call to init_module syscall fails with
-EACCES:
# strace -f -v modprobe <any-module> | grep init_module
init_module(0x55b9bcc9bba0, 17763, "") = -1 EACCES (Permission denied)
With this patchset the result would rely on the module.sig_enforce
cmdline as well. Once the CONFIG is not set, but the param is, the
result would be 'success', as it should be:
# strace -f -v modprobe <any-module> | grep init_module
init_module(0x7f9602d6e010, 386646, "") = 0
The patchset was tested in two different kernels: 4.13.6 (Fedora 27) and
4.14.0-rc4 (integrity-next tree)
Bruno E. O. Meneguele (2):
module: export module signature enforcement status
ima: check signature enforcement against cmdline param instead of
CONFIG
include/linux/module.h | 2 ++
kernel/module.c | 8 ++++++++
security/integrity/ima/ima_main.c | 6 +++---
3 files changed, 13 insertions(+), 3 deletions(-)
--
2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Bruno E. O. Meneguele <hidden> Date: 2017-10-20 19:19:29
When the user requests MODULE_CHECK policy and its kernel is compiled
with CONFIG_MODULE_SIG_FORCE not set, all modules would not load, just
those loaded in initram time. One option the user would have would be
set a kernel cmdline param (module.sig_enforce) to true, but the IMA
module check code doesn't rely on this value, it checks just
CONFIG_MODULE_SIG_FORCE.
This patch solves this problem checking for the exported value of
module.sig_enforce cmdline param intead of CONFIG_MODULE_SIG_FORCE,
which holds the effective value (CONFIG || param).
Signed-off-by: Bruno E. O. Meneguele <redacted>
---
security/integrity/ima/ima_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -356,12 +356,12 @@ void ima_post_path_mknod(struct dentry *dentry)*/intima_read_file(structfile*file,enumkernel_read_file_idread_id){+boolsig_enforce=is_module_sig_enforced();+if(!file&&read_id==READING_MODULE){-#ifndef CONFIG_MODULE_SIG_FORCE-if((ima_appraise&IMA_APPRAISE_MODULES)&&+if(!sig_enforce&&(ima_appraise&IMA_APPRAISE_MODULES)&&(ima_appraise&IMA_APPRAISE_ENFORCE))return-EACCES;/* INTEGRITY_UNKNOWN */-#endifreturn0;/* We rely on module signature checking */}return0;
--
2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 2017-10-20 at 17:19 -0200, Bruno E. O. Meneguele wrote:
When the user requests MODULE_CHECK policy and its kernel is compiled
with CONFIG_MODULE_SIG_FORCE not set, all modules would not load, just
those loaded in initram time. One option the user would have would be
set a kernel cmdline param (module.sig_enforce) to true, but the IMA
module check code doesn't rely on this value, it checks just
CONFIG_MODULE_SIG_FORCE.
This patch solves this problem checking for the exported value of
module.sig_enforce cmdline param intead of CONFIG_MODULE_SIG_FORCE,
which holds the effective value (CONFIG || param).
Signed-off-by: Bruno E. O. Meneguele <redacted>
@@ -356,12 +356,12 @@ void ima_post_path_mknod(struct dentry *dentry)*/intima_read_file(structfile*file,enumkernel_read_file_idread_id){+boolsig_enforce=is_module_sig_enforced();+if(!file&&read_id==READING_MODULE){-#ifndef CONFIG_MODULE_SIG_FORCE-if((ima_appraise&IMA_APPRAISE_MODULES)&&+if(!sig_enforce&&(ima_appraise&IMA_APPRAISE_MODULES)&&(ima_appraise&IMA_APPRAISE_ENFORCE))return-EACCES;/* INTEGRITY_UNKNOWN */-#endifreturn0;/* We rely on module signature checking */}return0;
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Bruno E. O. Meneguele <hidden> Date: 2017-10-20 19:20:11
A static variable sig_enforce is used as status var to indicate the real
value of CONFIG_MODULE_SIG_FORCE, once this one is set the var will hold
true, but if the CONFIG is not set the status var will hold whatever
value is present in the module.sig_enforce kernel cmdline param: true
when =1 and false when =0 or not present.
Considering this cmdline param take place over the CONFIG value when
it's not set, other places in the kernel could missbehave since they
would have only the CONFIG_MODULE_SIG_FORCE value to rely on. Exporting
this status var allows the kernel to rely in the effective value of
module signature enforcement, being it from CONFIG value or cmdline
param.
Signed-off-by: Bruno E. O. Meneguele <redacted>
---
include/linux/module.h | 2 ++
kernel/module.c | 8 ++++++++
2 files changed, 10 insertions(+)
--
2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 2017-10-20 at 17:19 -0200, Bruno E. O. Meneguele wrote:
A static variable sig_enforce is used as status var to indicate the real
value of CONFIG_MODULE_SIG_FORCE, once this one is set the var will hold
true, but if the CONFIG is not set the status var will hold whatever
value is present in the module.sig_enforce kernel cmdline param: true
when =1 and false when =0 or not present.
Considering this cmdline param take place over the CONFIG value when
it's not set, other places in the kernel could missbehave since they
^misbehave
would have only the CONFIG_MODULE_SIG_FORCE value to rely on. Exporting
this status var allows the kernel to rely in the effective value of
module signature enforcement, being it from CONFIG value or cmdline
param.
Thanks! There's a minor checkpatch warning below.
quoted hunk
Signed-off-by: Bruno E. O. Meneguele <redacted>
---
include/linux/module.h | 2 ++
kernel/module.c | 8 ++++++++
2 files changed, 10 insertions(+)
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html