allow disabling IMA at runtime
Subsystems (4)
PATCH 1/1 allow disabling IMA at runtime
From: Kyle McMartin <[email protected]>
Due to a memory leak in IMA that we're currently debugging in Fedora rawhide, it would be nice to be able to disable that support at runtime. Currently it's only able to be built in, and there's no toggle to avoid initializing it.
Provide one, in order to enhance debuggability. If a user can reboot a machine and edit its command line, one can do a far sight worse things than disabling a security precaution.
---
Documentation/kernel-parameters.txt +5 -0
@@ -926,6 +926,11 @@ and is between 256 and 4096 characters. It is defined in the file ihash_entries= [KNL] Set number of hash buckets for inode cache. + ima= [IMA] + Format: { "0" | "1" } + 0 -- disable IMA. + 1 -- enable IMA. (default) + ima_audit= [IMA] Format: { "0" | "1" } 0 -- integrity auditing messages. (Default)
security/integrity/ima/ima_main.c +17 -0
@@ -339,10 +339,27 @@ int ima_bprm_check(struct linux_binprm *bprm)return 0 ; } +static int ima_disabled =0 ; +static int __init ima_enabled (char *str) +{ +unsigned long enabled; + +if (!strict_strtoul (str,0 , &enabled)) + ima_disabled = enabled ?0 :1 ; + +return 1 ; +} +__setup ("ima=" , ima_enabled); +static int __init init_ima (void ) {int error; +if (ima_disabled) { +pr_info ("IMA disabled at user request.\n" ); +return 0 ; + } +ima_iintcache_init (); error =ima_init (); ima_initialized =1 ;
Kyle McMartin <[email protected]> wrote on 08/25/2009 10:10:05 PM:
Quoted 7 lines
From: Kyle McMartin <[email protected]>
Due to a memory leak in IMA that we're currently debugging in Fedora rawhide, it would be nice to be able to disable that support at runtime. Currently it's only able to be built in, and there's no toggle to avoid initializing it.
Quoted 5 lines
Provide one, in order to enhance debuggability. If a user can reboot a machine and edit its command line, one can do a far sight worse things than disabling a security precaution.
Signed-off-by Kyle McMartin <[email protected]>
Have you tried using Eric's patch
"IMA: Minimal IMA policy and boot param for TCB IMA policy" (commit 5789ba3bd0a3cd20df5980ebf03358f2eb44fd67), which introduced the ima_tcb=1 command line option? It wasn't backported to 2.6.30.
Mimi
Review
Quoted 2 lines
---
(quoted diff) +0
-0
b/Documentation/kernel-parameters.txt
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is
Quoted 4 lines
index 7936b80..0d1b1ed 100644
Documentation/kernel-parameters.txt +0
-0@@ -926,6 +926,11 @@ and is between 256 and 4096 characters. It is
defined in the file
Review
Quoted 12 lines
Documentation/kernel-parameters.txt +5
-0ihash_entries= [KNL] Set number of hash buckets for inode cache. + ima= [IMA] + Format: { "0" | "1" } + 0 -- disable IMA. + 1 -- enable IMA. (default) + ima_audit= [IMA] Format: { "0" | "1" } 0 -- integrity auditing messages. (Default)(quoted diff) +0
-0
b/security/integrity/ima/ima_main.c
Quoted 31 lines
index 101c512..cc7603e 100644
security/integrity/ima/ima_main.c +17
-0@@ -339,10 +339,27 @@ int ima_bprm_check(struct linux_binprm *bprm)return 0 ; } +static int ima_disabled =0 ; +static int __init ima_enabled (char *str) +{ +unsigned long enabled; + +if (!strict_strtoul (str,0 , &enabled)) + ima_disabled = enabled ?0 :1 ; + +return 1 ; +} +__setup ("ima=" , ima_enabled); +static int __init init_ima (void ) {int error; +if (ima_disabled) { +pr_info ("IMA disabled at user request.\n" ); +return 0 ; + } +ima_iintcache_init (); error =ima_init (); ima_initialized =1 ;
Quoted 13 lines · Mimi Zohar
Kyle McMartin <[email protected]> wrote on 08/25/2009 10:10:05 PM:
Quoted 11 lines
From: Kyle McMartin <[email protected]>
Due to a memory leak in IMA that we're currently debugging in Fedora rawhide, it would be nice to be able to disable that support at runtime. Currently it's only able to be built in, and there's no toggle to avoid initializing it.
Provide one, in order to enhance debuggability. If a user can reboot a machine and edit its command line, one can do a far sight worse things than disabling a security precaution.
Quoted 6 lines
Quoted 1 line
Signed-off-by Kyle McMartin <[email protected]>Have you tried using Eric's patch
"IMA: Minimal IMA policy and boot param for TCB IMA policy" (commit5789ba3bd0a3cd20df5980ebf03358f2eb44fd67), which introduced the ima_tcb=1 command line option? It wasn't backported to 2.6.30.
Hey Mimi, I was going to get in touch with you today, I don't really think this patch is necessary. Kyle hacked it together because it was a quick and dirty 'fix' for a memory leak that he didn't want to hunt down and he knows I won't let him compile IMA out *smile*. Intended to try to track it down this morning, but I'm getting swamped already, maybe you can try to figure out what's going on before I get a chance to come back to it this afternoon?
nfs_inode_cache 34 34 1824 17 8 : tunables 0 0 0 : slabdata 2 2 0 fuse_inode 22 22 1472 22 8 : tunables 0 0 0 : slabdata 1 1 0 rpc_inode_cache 40 40 1600 20 8 : tunables 0 0 0 : slabdata 2 2 0 btrfs_inode_cache 10622 10668 2328 14 8 : tunables 0 0 0 : slabdata 762 762 0 iint_cache 369714 369720 312 26 2 : tunables 0 0 0 : slabdata 14220 14220 0 mqueue_inode_cache 19 19 1664 19 8 : tunables 0 0 0 : slabdata 1 1 0 isofs_inode_cache 0 0 1288 25 8 : tunables 0 0 0 : slabdata 0 0 0 hugetlbfs_inode_cache 24 24 1312 24 8 : tunables 0 0 0 : slabdata 1 1 0 ext4_inode_cache 0 0 1864 17 8 : tunables 0 0 0 : slabdata 0 0 0 ext3_inode_cache 19 19 1656 19 8 : tunables 0 0 0 : slabdata 1 1 0 inotify_inode_mark_entry 253 255 240 17 1 : tunables 0 0 0 : slabdata 15 15 0 shmem_inode_cache 2740 3003 1560 21 8 : tunables 0 0 0 : slabdata 143 143 0 sock_inode_cache 902 920 1408 23 8 : tunables 0 0 0 : slabdata 40 40 0 proc_inode_cache 3060 3075 1288 25 8 : tunables 0 0 0 : slabdata 123 123 0 inode_cache 9943 10192 1240 26 8 : tunables 0 0 0 : slabdata 392 392 0 selinux_inode_security 27237 27838 264 31 2 : tunables 0 0 0 : slabdata 898 898 0
So the iint_cache is a LOT larger than all of the inode caches put together. This is a 2.6.31-0.167.rc6.git6.fc12.x86_64 kernel without any kernel options.
-Eric
-Eric
Quoted 11 lines · On Tue, 25 Aug 2009 22:10:05 -0400 Kyle McMartin <[email protected]> wrote:
From: Kyle McMartin <[email protected]>
Due to a memory leak in IMA that we're currently debugging in Fedora rawhide, it would be nice to be able to disable that support at runtime. Currently it's only able to be built in, and there's no toggle to avoid initializing it.
Provide one, in order to enhance debuggability. If a user can reboot a machine and edit its command line, one can do a far sight worse things than disabling a security precaution.
nits:
Quoted 25 lines
---
Documentation/kernel-parameters.txt +5
-0@@ -926,6 +926,11 @@ and is between 256 and 4096 characters. It is defined in the file ihash_entries= [KNL] Set number of hash buckets for inode cache. + ima= [IMA] + Format: { "0" | "1" } + 0 -- disable IMA. + 1 -- enable IMA. (default) + ima_audit= [IMA] Format: { "0" | "1" } 0 -- integrity auditing messages. (Default)security/integrity/ima/ima_main.c +0
-0@@ -339,10 +339,27 @@ int ima_bprm_check(struct linux_binprm *bprm)return 0 ; }
security/integrity/ima/ima_main.c int ima_bprm_check(struct linux_binprm *bprm) · line 350
Quoted 10 lines
security/integrity/ima/ima_main.c +9
-0+static int ima_disabled =0 ; +static int __init ima_enabled (char *str) +{ +unsigned long enabled; + +if (!strict_strtoul (str,0 , &enabled)) + ima_disabled = enabled ?0 :1 ; +return 1 ; +}
- documentation says "0 or 1" but the implementation says "0 or non-zero".
- implementation returns `1' whether or not the argument was successfully parsed.
What happens if a __setup() functions returns non-1?
<spends a while fossicking through prehistory and RustyCode>
From my reading of kernel/params.c:parse_args(), every __setup() function which returns 1' should result in printk("%s: %s' invalid for parameter `%s'), so I'm all confused and giving up.
security/integrity/ima/ima_main.c int ima_bprm_check(struct linux_binprm *bprm) · line 352
Quoted 1 line
security/integrity/ima/ima_main.c +1
-0+__setup ("ima=" , ima_enabled);
Are we supposed to use core_param() nowadays?
Quoted 12 lines
security/integrity/ima/ima_main.c +5
-0static int __init init_ima (void ) {int error; +if (ima_disabled) { +pr_info ("IMA disabled at user request.\n" ); +return 0 ; + } +ima_iintcache_init (); error =ima_init (); ima_initialized =1 ;
James Morris
maintainerAlso, do we still need this now the memory leak is fixed upstream?
Signature · 2 lines
James Morris <[email protected]>
Quoted 3 lines · Andrew Morton
From my reading of kernel/params.c:parse_args(), every
__setup()function which returns1' should result in printk("%s:%s' invalid for parameter `%s'), so I'm all confused and giving up.
Nope, it's an "obsolete_param", so non-zero means success.
Quoted 3 lines
Quoted 1 line
+__setup("ima=",
ima_enabled);Are we supposed to use
core_param()nowadays?
Yeah, if this had backwards compatibility requirements. But for new, non-core params like this:
1) make sure the module is called "ima" (even if not a module: make the object ima.o)
2) use module_param(), and make your parameters "disable" and "audit" (ima_disable and ima_audit if must be nonstatic and use module_param_named). You don't need to write any parse functions at all!
3) Tell users to use ima.disable and ima.audit.
Thanks,
Rusty.