implement-file-posix-capabilities.patch
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20070617135239.GA17689@sergelap
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines · Chris Wright
[folks, this is getting much too long-winded to stay a private thread]
Quoted 17 lines · * Serge E. Hallyn ([email protected]) wrote:
Quoted 15 lines · Chris Wright
Quoted 5 lines · * Andrew Morgan ([email protected]) wrote:
I share Casey's view that what's in the kernel now appears to have evolved because of the absence of filesystem capabilities and not in preparation for them. I'm not at all clear that they offer any real improvement over the more macroscopic, but much simpler to understand, superuser model.
Presently they offer next to nothing. From the POV of kernel code, they've added an extremely coarse grained way to check privs for actions (
CAP_SYS_ADMINrenders much of this useless for least priv).Quoted 1 line
From userspace POV, there's basically one well-known program that uses
the existing crippled model to drop privs. And from end-users' POV, there's no end of frustrated attempts to make something useful out of it. From a security POV, there's missing functionality (which has been addressed in Andrew's older patches and Serge's current patchset).
Quoted 6 lines
Quoted 3 lines
I'm sorry I'm not sure what your conclusion is then. Are you saying that my patch does add functionality, or arguing that it shouldn't be included?
It does add functionality, it is existing capabilities which are not particularly useful.
Ah, ok.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
I think the implementation (the patch) adds support for storing capabilities in the filesystem. But, I don't believe it is as a step towards 'POSIX' capability support, but just adding another incrementa twist to the Linux capability implementation - its hard to reason about such a thing, in terms of security or otherwise. (Have you thought about whether
LD_LIBRARY_PATHis ignored by capability aware, but non-setuid-0 programs? To voice one example. There are many system consequences to this model that will only become apparent when people start to seriously implement and use it.)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The classic argument has been one of administration. Tools know how to search for setuid programs,
Sure, but 'find' plus a 5-line program to check for security.capability xattrs will find capability programs, right?
Yes. I'm not 100% sold on the administration issue, but it is real, and unfortunately the extra 5-line program isn't a great solution.
It might not be :), but surely once people see what the actual administration challenges turn out to be, they/we can write the tools to satisfy those needs? I don't believe they will be insurmountable.
You had in the past played with caps quite a bit, do you already have a sense of what kinds of admin problems people will have?
Quoted 15 lines
Quoted 9 lines
Are there popular gui's in
widespread use which depend on programs granting extra privilege doing so using setuid?Quoted 2 lines
and mainline MAC is not adding caps based on
security domain during exec, etc.I don't understand what you're saying - could you explain? Which 'mainline MAC', what sort of domains (TE?)?
mainline MAC meaning basically SELinux. IOW, while LIDS and Apparmor had/have models for handling capabilities (don't recall if it was grant or restrict only), SELinux is just now talking about doing something like this, but nothing is upstream and in wide distribution.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My biggest concern is leaking caps to
programs which are meant to be unprivileged.Would it help if we place
CONFIG_SECURITY_FILE_CAPABILITIESunderCONFIG_EXPERIMENTAlfor a bit?Would not hurt ;-)
Ok, here's a patch on top of 2.6.22-rc4-mm2 to do so,
thanks,
-serge
Quoted 1 line
From
bf1566bb34ed47ffadfe9289ba2f1a85df5dc36fMon Sep 17 00:00:00 2001
From: Serge E. Hallyn <[email protected]>
Date: Thu, 21 Jun 2007 11:40:23 -0400
Subject: [PATCH 1/1] file capabilities: make file capabilities option EXPERIMENTAL
Make file capabilities depend upon CONFIG_EXPERIMENTAL, as few people have used them to date.
--- security/Kconfig | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
security/Kconfig +2 -2
@@ -81,8 +81,8 @@ config SECURITY_CAPABILITIES If you are unsure how to answer this question, answer Y. config SECURITY_FILE_CAPABILITIES - bool "File POSIX Capabilities" - depends on SECURITY=n || SECURITY_CAPABILITIES!=n + bool "File POSIX Capabilities (EXPERIMENTAL)" + depends on (SECURITY=n || SECURITY_CAPABILITIES!=n) && EXPERIMENTAL default n help This enables filesystem capabilities, allowing you to give
Signature · 1 line
1.5.1.1.GIT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Serge,
[time passes]
I'm a little better up to speed on all the kernel now. I don't feel that I conceptually object so much to this patch-series any more.... :-)
I do, however, think the patch needs some work:
1) As previously discussed, fE should be an all or nothing single bit:
How about?:
#define VFS_CAP_REVISION_MASK 0xFF000000
#define VFS_CAP_REVISION 0x01000000
#define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK
#define VFS_CAP_FLAGS_EFFECTIVE 0x000001
struct vfs_cap_data {
__u32 magic_etc;
struct {
__u32 permitted; /* Little endian */
__u32 inheritable; /* Little endian */
} data[1];
};2) Allocate capability bit-31 for CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not. CAP_SYS_ADMIN is way too overloaded and this functionality is special.
3) The cap_from_disk() interface checking needs some work.... Most notably, size must be greater than sizeof(u32) or the very first line will do something nasty... I'd recommend you use code like this:
[...] cap_from_disk(...)
{
if (size != sizeof(struct vfs_cap_data)) {
printk(KERN_WARNING "%s: invalid cap size %d for file %s\n",
__FUNCTION__, size, bprm->filename);
return -EINVAL;}
switch ((version & VFS_CAP_REVISION_MASK)) {
case VFS_CAP_REVISION:
bprm->cap_effective = (version & VFS_CAP_FLAGS_EFFECTIVE)
? CAP_FULL_SET : CAP_EMPTY_SET;
bprm->cap_permitted =
to_cap_t( le32_to_cpu(dcap->data[0].permitted) );
bprm->cap_inheritable =
to_cap_t( le32_to_cpu(dcap->data[0].inheritable) );
return 0;
default:
return -EINVAL; }
}
Basically, I don't believe in designing a secure interface to be forward compatible - things never work out that way and the legacy you are implicitly committing to will haunt you in the future... FWIW I've known a few x86 MSR designers over the years and each one has made this mistake at least once... The future is uncertain, so don't trust it will look the way you want it to. ;-)
5) I would rename 'set_file_caps' to 'get_file_caps' since this is what the function actually does. If you must use 'set' then call the function 'set_bprm_caps'.
6) I also don't see the value of explicitly zero'ing the capabilities (in cap_bprm_set_security()) only to override them elsewhere.
I'd move the 'cap_clear (bprm->cap_...)' code from cap_bprm_set_security() into the 'out:' code at the end of 'get_file_caps()' (sic). Put rc=0 at the top of the function, and replace the return 0; at the top of that function with a 'goto clear_out;' then replace the out: code as follows:
out:
dput(dentry);
if ((void *)dcaps != (void *)&v1caps)
kfree(dcaps);
if (rc) {
clear_out:
cap_clear (bprm->cap_inheritable);
cap_clear (bprm->cap_permitted);
cap_clear (bprm->cap_effective);
}
return rc;7) This one is subtle, and to my mind not well appreciated. In cap_bprm_apply_creds(), the wart of the global 'cap_bset' masking permitted bits can lead to problems like the one we saw a few years back with sendmail and capabilities. There is an assumption in setting permitted (they are called 'forced' in some documents) capabilities on a file that the file will execute with at least these. The inheritable ones are optional.
The long and the short of it is there needs to be a check somewhere that:
current->cap_permitted is a superset of file->cap_permitted
That is, what cap_bset takes away, current->cap_inheritable gives back. If the above is not true, then the executable should fail to execute;
- -EPERM. On the surface I don't see how to do this with the LSM framework because the relevant function is a 'void' one and can't return an error.
8) There are a number of (massive) cleanups that I would like to see done, but they are more related to the non-file capabilities support in the kernel and I won't pollute this present discussion any more with those.
I hope that was helpful. FWIW I did set up a git repostitory on kernel.org to port my old patches, but in the process of porting them better understood what you had done. If you do the above I think I'd be happy to work from that...
Cheers
Andrew
PS. If anyone is touching file with my transmeta email in them, feel free to replace them with the @kernel.org address. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGfNYwQheEq9QabfIRAgQ2AJ9q3+BgOPlZvTboqEyM3O845xKZOQCcCLQm zKVfemAw2F5h43rApDXuJ4o=
=OJWn
-----END PGP SIGNATURE-----
Serge E. Hallyn
maintainerQuoted 22 lines · Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Serge,
[time passes]
I'm a little better up to speed on all the kernel now. I don't feel that I conceptually object so much to this patch-series any more.... :-)
I do, however, think the patch needs some work:
1) As previously discussed, fE should be an all or nothing single bit:
How about?:
#define
VFS_CAP_REVISION_MASK0xFF000000
#defineVFS_CAP_REVISION0x01000000#define
VFS_CAP_FLAGS_MASK~VFS_CAP_REVISION_MASK
#defineVFS_CAP_FLAGS_EFFECTIVE0x000001
Quoted 7 lines
struct vfs_cap_data {
__u32 magic_etc;
struct {
__u32 permitted; /* Little endian */
__u32 inheritable; /* Little endian */
} data[1];
};I don't particularly mind, but can you point out any case where it is an advantage to have the one bit for f'E rather than just drop f'E altogether? Instead of having
f'I=something f'P=something f'E=off
we can always just remove the security.capability xattr. Right?
If there's a case where that does not suffice, then I have no objection to doing it this way.
Quoted 3 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.
The functionality is special, but someone with CAP_SYS_ADMIN can always unload the capability module and create the security.capability xattr using the dummy module.
If we do add this cap, do we want to make it apply to all security.* xattrs?
Quoted 26 lines
3) The
cap_from_disk()interface checking needs some work.... Most notably, size must be greater than sizeof(u32) or the very first line will do something nasty... I'd recommend you use code like this:[...]
cap_from_disk(...){ if (size != sizeof(struct vfs_cap_data)) { printk(KERN_WARNING "%s: invalid cap size %d for file %s\n", __FUNCTION__, size, bprm->filename); return -EINVAL; } switch ((version & VFS_CAP_REVISION_MASK)) { case VFS_CAP_REVISION: bprm->cap_effective = (version & VFS_CAP_FLAGS_EFFECTIVE) ? CAP_FULL_SET : CAP_EMPTY_SET; bprm->cap_permitted = to_cap_t( le32_to_cpu(dcap->data[0].permitted) ); bprm->cap_inheritable = to_cap_t( le32_to_cpu(dcap->data[0].inheritable) ); return 0; default: return -EINVAL; } }
Quoted 6 lines
Basically, I don't believe in designing a secure interface to be forward compatible - things never work out that way and the legacy you are implicitly committing to will haunt you in the future... FWIW I've known a few x86 MSR designers over the years and each one has made this mistake at least once... The future is uncertain, so don't trust it will look the way you want it to. ;-)
Ok, so you're saying that when we do switch to 64-bit caps or some other evolution, we switch to completely separate logic based on the VFS_CAP_REVISION?
That seems sane to me.
Quoted 3 lines
5) I would rename '
set_file_caps' to 'get_file_caps' since this is what the function actually does. If you must use 'set' then call the function 'set_bprm_caps'.
set_bprm_caps actually sounds best to me.
Quoted 16 lines
6) I also don't see the value of explicitly zero'ing the capabilities (in
cap_bprm_set_security()) only to override them elsewhere.I'd move the '
cap_clear(bprm->cap_...)' code fromcap_bprm_set_security()into the 'out:' code at the end of 'get_file_caps()' (sic). Put rc=0 at the top of the function, and replace the return 0; at the top of that function with a 'gotoclear_out;' then replace the out: code as follows:out: dput(dentry); if ((void *)dcaps != (void *)&v1caps) kfree(dcaps); if (rc) { clear_out:
cap_clear(bprm->cap_inheritable);
Review
Quoted 4 lines
(quoted diff) +0
-0cap_clear (bprm->cap_permitted); cap_clear (bprm->cap_effective); } return rc;
Sounds sane. If it looks less sane when I try to write the patch I'll get back to you :)
Quoted 7 lines
7) This one is subtle, and to my mind not well appreciated. In
cap_bprm_apply_creds(), the wart of the global 'cap_bset' masking permitted bits can lead to problems like the one we saw a few years back with sendmail and capabilities. There is an assumption in setting permitted (they are called 'forced' in some documents) capabilities on a file that the file will execute with at least these. The inheritable ones are optional.
Hmm, changing the behavior of the cap_bset is something that seems to belong in 8), though I see what you're saying, it does affect the behavior of vfs caps.
One gets a cozy feeling from the fact that cap_bset is set to (~0 & ~~CAP_TO_MASK(CAP_SETPCAP)), but since it's sysctl controllable that seems like it could present a real security problem.
So yeah, I think you're right - but the question is whose word do we take here? The admin who set the vfs caps on the binary, or the admin who set cap_bset through sysctl?
I wonder whether anyone actually uses the cap_bset sysctl...
Quoted 9 lines
The long and the short of it is there needs to be a check somewhere that:
current->cap_permitted is a superset of file->cap_permittedThat is, what
cap_bsettakes away,current->cap_inheritablegives back. If the above is not true, then the executable should fail to execute;
--EPERM. On the surface I don't see how to do this with the LSM framework because the relevant function is a 'void' one and can't return an error.
Quoted 8 lines
8) There are a number of (massive) cleanups that I would like to see done, but they are more related to the non-file capabilities support in the kernel and I won't pollute this present discussion any more with those.
I hope that was helpful. FWIW I did set up a git repostitory on kernel.org to port my old patches, but in the process of porting them better understood what you had done. If you do the above I think I'd be happy to work from that...
If you have a list of such cleanups you could send out, we can then decide whether those all are safe to apply to the current capability module, or whether it makes sense to fork off a shiny new capabiltyv2 module :)
many thanks for all the suggestions,
-serge
Quoted 17 lines
Cheers
Andrew
PS. If anyone is touching file with my transmeta email in them, feel free to replace them with the @kernel.org address. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)iD8DBQFGfNYwQheEq9QabfIRAgQ2AJ9q3+BgOPlZvTboqEyM3O845xKZOQCcCLQm zKVfemAw2F5h43rApDXuJ4o=
=OJWn
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
James Morris
maintainerQuoted 10 lines · Serge E. Hallyn
Quoted 3 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.The functionality is special, but someone with
CAP_SYS_ADMINcan always unload the capability module and create the security.capability xattr using the dummy module.If we do add this cap, do we want to make it apply to all security.* xattrs?
The underlying issue here is the notion of security mechanisms which are built as loadable modules. It's not useful for any in-tree users, and introduces several unnecessary problems which then need to be addressed.
A better approach would be to make LSM a statically linked interface.
This would also allow us to unexport the LSM symbols and reduce the API abuse by third-party modules.
- James
Signature · 2 lines
James Morris <[email protected]>
James Morris
maintainerRFC PATCH 1/1 security: Convert LSM into a static interface
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Module parameters for the capability and root_plug modules have been converted to kernel parameters.
The SECURITY_FRAMEWORK_VERSION macro has also been removed.
---
Please review & let me know if anything is broken.
Documentation/kernel-parameters.txt | 17 +++++++++++ security/Kconfig | 4 +- security/capability.c | 32 ++++---------------- security/commoncap.c | 3 -- security/dummy.c | 1 - security/root_plug.c | 53 +++++++++++++--------------------- security/security.c | 9 +---- security/selinux/hooks.c | 1 - security/selinux/xfrm.c | 1 - 9 files changed, 48 insertions(+), 73 deletions(-)
Documentation/kernel-parameters.txt +17 -0
@@ -74,10 +74,12 @@ parameter is applicable: PPT Parallel port support is enabled. PS2 Appropriate PS/2 support is enabled. RAM RAM disk support is enabled. + ROOTPLUG The example Root Plug LSM is enabled. S390 S390 architecture is enabled. SCSI Appropriate SCSI support is enabled. A lot of drivers has their options described inside of Documentation/scsi/. + SECURITY Different security models are enabled. SELINUX SELinux support is enabled. SERIAL Serial support is enabled. SH SuperH architecture is enabled.
@@ -376,6 +378,12 @@ and is between 256 and 4096 characters. It is defined in the file possible to determine what the correct size should be. This option provides an override for these situations. + capability_disable= + [SECURITY] Disable capabilities. This would normally + be used only if an alternative security model is to be + configured. Potentially dangerous and should only be + used if you are entirely sure of the consequences. + cdu31a= [HW,CD] Format: <io>,<irq>[,PAS] See header of drivers/cdrom/cdu31a.c.
@@ -1541,6 +1549,15 @@ and is between 256 and 4096 characters. It is defined in the file rootfstype= [KNL] Set root filesystem type + root_plug_vendor_id= + [ROOTPLUG] Override the default vendor ID + + root_plug_product_id= + [ROOTPLUG] Override the default product ID + + root_plug_debug= + [ROOTPLUG] Enable debugging output + rw [KNL] Mount root device read-write on boot S [KNL] Run init in single mode
security/Kconfig +2 -2
@@ -74,14 +74,14 @@ config SECURITY_NETWORK_XFRM If you are unsure how to answer this question, answer N. config SECURITY_CAPABILITIES - tristate "Default Linux Capabilities" + bool "Default Linux Capabilities" depends on SECURITY help This enables the "default" Linux capabilities functionality. If you are unsure how to answer this question, answer Y. config SECURITY_ROOTPLUG - tristate "Root Plug Support" + bool "Root Plug Support" depends on USB && SECURITY help This is a sample LSM module that should only be used as such.
security/capability.c +7 -25
@@ -8,7 +8,6 @@* */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/security.h>
@@ -51,8 +50,13 @@ static struct security_operations capability_ops = {static int secondary;static int capability_disable; -module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" ); + +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);static int __init capability_init (void ) {
@@ -75,26 +79,4 @@ static int __init capability_init (void)return 0 ; } -static void __exit capability_exit (void) -{ -if (capability_disable) -return ; -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (KBUILD_MODNAME , &capability_ops)) -printk (KERN_INFO "Failure unregistering capabilities " -"with primary module.\n" ); -return ; - } - -if (unregister_security (&capability_ops)) { -printk (KERN_INFO -"Failure unregistering capabilities with the kernel\n" ); - } -} -security_initcall (capability_init); -module_exit (capability_exit); - -MODULE_DESCRIPTION ("Standard Linux Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/commoncap.c +0 -3
@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid);EXPORT_SYMBOL (cap_task_reparent_to_init);EXPORT_SYMBOL (cap_syslog);EXPORT_SYMBOL (cap_vm_enough_memory); - -MODULE_DESCRIPTION ("Standard Linux Common Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/dummy.c +0 -1
@@ -15,7 +15,6 @@#undef DEBUG#include <linux/capability.h> -#include <linux/module.h> #include <linux/kernel.h> #include <linux/mman.h> #include <linux/pagemap.h>
security/root_plug.c +20 -33
77 lines not on this page · raw message
security/security.c +2 -7
@@ -17,7 +17,6 @@#include <linux/kernel.h> #include <linux/security.h> -#define SECURITY_FRAMEWORK_VERSION "1.0.0"/* things that live in dummy.c */ extern struct security_operations dummy_security_ops;
@@ -51,8 +50,7 @@ static void __init do_security_initcalls(void)*/ int __init security_init (void ) { -printk (KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION -" initialized\n" ); +printk (KERN_INFO "Security Framework initialized\n" );if (verify (&dummy_security_ops)) { printk(KERN_ERR "%s could not verify "
@@ -172,8 +170,5 @@ int mod_unreg_security(const char *name, struct security_operations *ops)return security_ops->unregister_security (name, ops); } -EXPORT_SYMBOL_GPL (register_security); -EXPORT_SYMBOL_GPL (unregister_security); -EXPORT_SYMBOL_GPL (mod_reg_security); -EXPORT_SYMBOL_GPL (mod_unreg_security); +/* Export required for modular use of security.h inlines */ EXPORT_SYMBOL (security_ops);
security/selinux/hooks.c +0 -1
@@ -20,7 +20,6 @@* as published by the Free Software Foundation. */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/ptrace.h>
security/selinux/xfrm.c +0 -1
@@ -31,7 +31,6 @@* 2. Emulating a reasonable SO_PEERSEC across machines * 3. Testing addition of sk_policy's with security context via setsockopt */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h>
Signature · 1 line
1.5.2.1
Re: [PATCH][RFC] security: Convert LSM into a static interface
security/capability.c static struct security_operations capability_ops = { · line 59
Quoted 9 lines · * James Morris ([email protected]) wrote:
security/capability.c +7
-2-module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" ); + +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);
This changes the command line argument. Other than that and a some sanity testing I'll take this.
thanks,
-chris
James Morris
maintainerRe: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 13 lines · Chris Wright
security/capability.c static struct security_operations capability_ops = { · line 59
Quoted 9 lines · * James Morris ([email protected]) wrote:
security/capability.c +7
-2-module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" ); + +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);This changes the command line argument. Other than that and a some sanity testing I'll take this.
Do you mean the name change, or the logic?
The name needs to change because kernel parameters are in a global namespace.
If the logic has changed, I'm missing something :-)
Signature · 2 lines
James Morris <[email protected]>
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 16 lines · * James Morris ([email protected]) wrote:
Quoted 13 lines · Chris Wright
security/capability.c static struct security_operations capability_ops = { · line 59
Quoted 9 lines · * James Morris ([email protected]) wrote:
security/capability.c +7
-2-module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" ); + +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);This changes the command line argument. Other than that and a some sanity testing I'll take this.
Quoted 4 lines
Do you mean the name change, or the logic?
The name needs to change because kernel parameters are in a global namespace.
Sorry, I mean it's currently capability.disable (and the only reason it matters is that at one point I know there were users of it).
thanks,
-chris
Re: [PATCH][RFC] security: Convert LSM into a static interface
In reply to Chris WrightQuoted 4 lines · --- Chris Wright
Review
Quoted 2 lines · * James Morris ([email protected]) wrote:
(quoted diff) +0
-2-module_param_named(disable, capability_disable, int, 0); -MODULE_PARM_DESC(disable, "To disable capabilities module set disable =1");
Quoted 10 lines
security/capability.c static struct security_operations capability_ops = { · line 59
Quoted 7 lines
security/capability.c +7
-0+ +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);This changes the command line argument. Other than that and a some sanity testing I'll take this.
Sigh. So much for my schedule.
So, for planning purposes, when ought I expect to have to start dealing with this?
Casey Schaufler
[email protected]
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 2 lines · * Casey Schaufler ([email protected]) wrote:
So, for planning purposes, when ought I expect to have to start dealing with this?
What is your specific concern or use case?
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 5 lines · --- Chris Wright
Quoted 2 lines · * Casey Schaufler ([email protected]) wrote:
So, for planning purposes, when ought I expect to have to start dealing with this?
What is your specific concern or use case?
Just hoping to avoid a change collision. If I have to deal with this today it's easy, if it doesn't show up anywhere until 2.6.28 I'm breezing, but if it all hits in two weeks I have some scrambling and yet another delay to deal with. Not your problem, a little information would be helpful though.
BTW, I reviewed my notes from the early days of LSM and it turns out that I agree with the notion that loadable modules don't make a whole lot of sense. So long as I can choose security models as easily as I can change file systems, I'm reasonably happy. That, and that the "default" "regular" policy isn't too terribly different from the traditional Unix policy.
Casey Schaufler
[email protected]
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 5 lines · * Casey Schaufler ([email protected]) wrote:
Just hoping to avoid a change collision. If I have to deal with this today it's easy, if it doesn't show up anywhere until 2.6.28 I'm breezing, but if it all hits in two weeks I have some scrambling and yet another delay to deal with. Not your problem, a little information would be helpful though.
Assuming no issues, 2.6.23 (which is months away, although merge window isn't).
Quoted 7 lines
BTW, I reviewed my notes from the early days of LSM and it turns out that I agree with the notion that loadable modules don't make a whole lot of sense. So long as I can choose security models as easily as I can change file systems, I'm reasonably happy. That, and that the "default" "regular" policy isn't too terribly different from the traditional Unix policy.
The default will continue to be capabilities.
thanks,
-chris
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 9 lines · --- Chris Wright
Quoted 5 lines · * Casey Schaufler ([email protected]) wrote:
Just hoping to avoid a change collision. If I have to deal with this today it's easy, if it doesn't show up anywhere until 2.6.28 I'm breezing, but if it all hits in two weeks I have some scrambling and yet another delay to deal with. Not your problem, a little information would be helpful though.
Assuming no issues, 2.6.23 (which is months away, although merge window isn't).
Thank you.
Quoted 9 lines
Quoted 7 lines
BTW, I reviewed my notes from the early days of LSM and it turns out that I agree with the notion that loadable modules don't make a whole lot of sense. So long as I can choose security models as easily as I can change file systems, I'm reasonably happy. That, and that the "default" "regular" policy isn't too terribly different from the traditional Unix policy.
The default will continue to be capabilities.
Good. Thank you again.
Casey Schaufler
[email protected]
Re: [PATCH][RFC] security: Convert LSM into a static interface
In reply to Casey SchauflerIl giorno dom, 24/06/2007 alle 20.37 -0700, Casey Schaufler ha scritto:
Quoted 6 lines
Quoted 4 lines · --- Chris Wright
Quoted 2 lines · * Casey Schaufler ([email protected]) wrote:
So, for planning purposes, when ought I expect to have to start dealing with this?
Quoted 7 lines
Quoted 1 line
What is your specific concern or use case?
Just hoping to avoid a change collision. If I have to deal with this today it's easy, if it doesn't show up anywhere until 2.6.28 I'm breezing, but if it all hits in two weeks I have some scrambling and yet another delay to deal with. Not your problem, a little information would be helpful though.
I think you will not have too much problem with this patch. After all, you will only need to remove a couple of functions (for the unloading) and take rid of 'old' module parameters (if you use it)
Signature · 3 lines
Roberto De Ioris http://unbit.it JID: [email protected]
James Morris
maintainerPATCH 1/1 security: Convert LSM into a static interface
In reply to Chris WrightConvert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Parameters for the capability and root_plug modules are now specified at boot.
The SECURITY_FRAMEWORK_VERSION macro has also been removed.
---
Changes:
- retain capability.disable kernel param name
Documentation/kernel-parameters.txt | 17 +++++++++++ security/Kconfig | 4 +- security/capability.c | 24 ---------------- security/commoncap.c | 3 -- security/dummy.c | 1 - security/root_plug.c | 53 +++++++++++++--------------------- security/security.c | 9 +---- security/selinux/hooks.c | 1 - security/selinux/xfrm.c | 1 - 9 files changed, 41 insertions(+), 72 deletions(-)
Documentation/kernel-parameters.txt +17 -0
@@ -74,10 +74,12 @@ parameter is applicable: PPT Parallel port support is enabled. PS2 Appropriate PS/2 support is enabled. RAM RAM disk support is enabled. + ROOTPLUG The example Root Plug LSM is enabled. S390 S390 architecture is enabled. SCSI Appropriate SCSI support is enabled. A lot of drivers has their options described inside of Documentation/scsi/. + SECURITY Different security models are enabled. SELINUX SELinux support is enabled. SERIAL Serial support is enabled. SH SuperH architecture is enabled.
@@ -376,6 +378,12 @@ and is between 256 and 4096 characters. It is defined in the file possible to determine what the correct size should be. This option provides an override for these situations. + capability.disable= + [SECURITY] Disable capabilities. This would normally + be used only if an alternative security model is to be + configured. Potentially dangerous and should only be + used if you are entirely sure of the consequences. + cdu31a= [HW,CD] Format: <io>,<irq>[,PAS] See header of drivers/cdrom/cdu31a.c.
@@ -1541,6 +1549,15 @@ and is between 256 and 4096 characters. It is defined in the file rootfstype= [KNL] Set root filesystem type + root_plug_vendor_id= + [ROOTPLUG] Override the default vendor ID + + root_plug_product_id= + [ROOTPLUG] Override the default product ID + + root_plug_debug= + [ROOTPLUG] Enable debugging output + rw [KNL] Mount root device read-write on boot S [KNL] Run init in single mode
security/Kconfig +2 -2
@@ -74,14 +74,14 @@ config SECURITY_NETWORK_XFRM If you are unsure how to answer this question, answer N. config SECURITY_CAPABILITIES - tristate "Default Linux Capabilities" + bool "Default Linux Capabilities" depends on SECURITY help This enables the "default" Linux capabilities functionality. If you are unsure how to answer this question, answer Y. config SECURITY_ROOTPLUG - tristate "Root Plug Support" + bool "Root Plug Support" depends on USB && SECURITY help This is a sample LSM module that should only be used as such.
security/capability.c +0 -24
@@ -8,7 +8,6 @@* */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/security.h>
@@ -52,7 +51,6 @@ static int secondary;static int capability_disable;module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" );static int __init capability_init (void ) {
@@ -75,26 +73,4 @@ static int __init capability_init (void)return 0 ; } -static void __exit capability_exit (void) -{ -if (capability_disable) -return ; -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (KBUILD_MODNAME , &capability_ops)) -printk (KERN_INFO "Failure unregistering capabilities " -"with primary module.\n" ); -return ; - } - -if (unregister_security (&capability_ops)) { -printk (KERN_INFO -"Failure unregistering capabilities with the kernel\n" ); - } -} -security_initcall (capability_init); -module_exit (capability_exit); - -MODULE_DESCRIPTION ("Standard Linux Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/commoncap.c +0 -3
@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid);EXPORT_SYMBOL (cap_task_reparent_to_init);EXPORT_SYMBOL (cap_syslog);EXPORT_SYMBOL (cap_vm_enough_memory); - -MODULE_DESCRIPTION ("Standard Linux Common Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/dummy.c +0 -1
@@ -15,7 +15,6 @@#undef DEBUG#include <linux/capability.h> -#include <linux/module.h> #include <linux/kernel.h> #include <linux/mman.h> #include <linux/pagemap.h>
security/root_plug.c +20 -33
77 lines not on this page · raw message
security/security.c +2 -7
@@ -17,7 +17,6 @@#include <linux/kernel.h> #include <linux/security.h> -#define SECURITY_FRAMEWORK_VERSION "1.0.0"/* things that live in dummy.c */ extern struct security_operations dummy_security_ops;
@@ -51,8 +50,7 @@ static void __init do_security_initcalls(void)*/ int __init security_init (void ) { -printk (KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION -" initialized\n" ); +printk (KERN_INFO "Security Framework initialized\n" );if (verify (&dummy_security_ops)) { printk(KERN_ERR "%s could not verify "
@@ -172,8 +170,5 @@ int mod_unreg_security(const char *name, struct security_operations *ops)return security_ops->unregister_security (name, ops); } -EXPORT_SYMBOL_GPL (register_security); -EXPORT_SYMBOL_GPL (unregister_security); -EXPORT_SYMBOL_GPL (mod_reg_security); -EXPORT_SYMBOL_GPL (mod_unreg_security); +/* Export required for modular use of security.h inlines */ EXPORT_SYMBOL (security_ops);
security/selinux/hooks.c +0 -1
@@ -20,7 +20,6 @@* as published by the Free Software Foundation. */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/ptrace.h>
security/selinux/xfrm.c +0 -1
@@ -31,7 +31,6 @@* 2. Emulating a reasonable SO_PEERSEC across machines * 3. Testing addition of sk_policy's with security context via setsockopt */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h>
Signature · 1 line
1.5.2.1
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 1 line · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Hello,
security/root_plug.c static int secondary; · line 60
Quoted 8 lines
security/root_plug.c +6
-2-module_param (debug, bool,0600 ); -MODULE_PARM_DESC (debug,"Debug enabled or not" ); +static int __init root_plug_debug (char *str) +{ + debug =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("root_plug_debug=" , root_plug_debug);
is this necessary? What about just documenting root_plug.{vendor_id,product_id,debug}, so it won't break existing root_plug users (if there are any) ? I thought that typed module_param() is prefered over untyped __setup()...
Thanks,
Petr
James Morris
maintainerRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 5 lines · Petr Vandrovec
Quoted 5 lines
security/root_plug.c +3
-2-module_param (debug, bool,0600 ); -MODULE_PARM_DESC (debug,"Debug enabled or not" ); +static int __init root_plug_debug (char *str) +{ + debug =simple_strtol (str,NULL ,0 );
Quoted 8 lines
security/root_plug.c static int secondary; · line 60
Quoted 3 lines
security/root_plug.c +3
-0+return 1 ; +} +__setup ("root_plug_debug=" , root_plug_debug);is this necessary? What about just documenting root_plug.{vendor_id,product_id,debug}, so it won't break existing
root_plugusers (if there are any) ? I thought that typedmodule_param()is prefered over untyped__setup()...
I didn't know module_param was preferred.
The idea was that root_plug is example code, and should do the typical thing, which I thought would be __setup.
I can easily change it if needed.
Signature · 2 lines
James Morris <[email protected]>
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to James MorrisQuoted 20 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Parameters for the capability and
root_plugmodules are now specified at boot.The
SECURITY_FRAMEWORK_VERSIONmacro has also been removed.Signed-off-by James Morris <[email protected]>---
security/security.c +0
-0
security/security.c int mod_unreg_security(const char *name, struct security_operations *ops) · line 174
Quoted 9 lines
security/security.c +1
-4@@ -172,8 +170,5 @@ int mod_unreg_security(const char *name, struct security_operations *ops)return security_ops->unregister_security (name, ops); } -EXPORT_SYMBOL_GPL (register_security); -EXPORT_SYMBOL_GPL (unregister_security); -EXPORT_SYMBOL_GPL (mod_reg_security); -EXPORT_SYMBOL_GPL (mod_unreg_security); +/* Export required for modular use of security.h inlines */ EXPORT_SYMBOL (security_ops);
I think you want to eliminate that last export too, by taking the security hooks that are called by modules into out-of-line wrapper functions in security.c rather than directly referencing security_ops.
Signature · 2 lines
Stephen Smalley National Security Agency
James Morris
maintainerPATCH 1/1 security: Convert LSM into a static interface
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Parameters for the capability and root_plug modules are now specified at boot.
The SECURITY_FRAMEWORK_VERSION macro has also been removed.
---
Changes in this version:
- retained module params for root_plug
- unexorted security_ops, moved inlines to security.c, exported some needed security hooks
Please review, I've done quite a bit of testing, but it's a large change now.
Documentation/kernel-parameters.txt | 17 + include/linux/security.h | 1171 ++++++----------------------------- security/Kconfig | 4 +- security/capability.c | 24 - security/commoncap.c | 3 - security/dummy.c | 1 - security/root_plug.c | 31 +- security/security.c | 954 ++++++++++++++++++++++++++++- security/selinux/hooks.c | 1 - security/selinux/xfrm.c | 1 - 10 files changed, 1168 insertions(+), 1039 deletions(-)
Documentation/kernel-parameters.txt +17 -0
@@ -74,10 +74,12 @@ parameter is applicable: PPT Parallel port support is enabled. PS2 Appropriate PS/2 support is enabled. RAM RAM disk support is enabled. + ROOTPLUG The example Root Plug LSM is enabled. S390 S390 architecture is enabled. SCSI Appropriate SCSI support is enabled. A lot of drivers has their options described inside of Documentation/scsi/. + SECURITY Different security models are enabled. SELINUX SELinux support is enabled. SERIAL Serial support is enabled. SH SuperH architecture is enabled.
@@ -376,6 +378,12 @@ and is between 256 and 4096 characters. It is defined in the file possible to determine what the correct size should be. This option provides an override for these situations. + capability.disable= + [SECURITY] Disable capabilities. This would normally + be used only if an alternative security model is to be + configured. Potentially dangerous and should only be + used if you are entirely sure of the consequences. + cdu31a= [HW,CD] Format: <io>,<irq>[,PAS] See header of drivers/cdrom/cdu31a.c.
@@ -1541,6 +1549,15 @@ and is between 256 and 4096 characters. It is defined in the file rootfstype= [KNL] Set root filesystem type + root_plug.vendor_id= + [ROOTPLUG] Override the default vendor ID + + root_plug.product_id= + [ROOTPLUG] Override the default product ID + + root_plug.debug= + [ROOTPLUG] Enable debugging output + rw [KNL] Mount root device read-write on boot S [KNL] Run init in single mode
include/linux/security.h +202 -969
1,209 lines not on this page · raw message
security/Kconfig +2 -2
@@ -74,14 +74,14 @@ config SECURITY_NETWORK_XFRM If you are unsure how to answer this question, answer N. config SECURITY_CAPABILITIES - tristate "Default Linux Capabilities" + bool "Default Linux Capabilities" depends on SECURITY help This enables the "default" Linux capabilities functionality. If you are unsure how to answer this question, answer Y. config SECURITY_ROOTPLUG - tristate "Root Plug Support" + bool "Root Plug Support" depends on USB && SECURITY help This is a sample LSM module that should only be used as such.
security/capability.c +0 -24
@@ -8,7 +8,6 @@* */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/security.h>
@@ -52,7 +51,6 @@ static int secondary;static int capability_disable;module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" );static int __init capability_init (void ) {
@@ -75,26 +73,4 @@ static int __init capability_init (void)return 0 ; } -static void __exit capability_exit (void) -{ -if (capability_disable) -return ; -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (KBUILD_MODNAME , &capability_ops)) -printk (KERN_INFO "Failure unregistering capabilities " -"with primary module.\n" ); -return ; - } - -if (unregister_security (&capability_ops)) { -printk (KERN_INFO -"Failure unregistering capabilities with the kernel\n" ); - } -} -security_initcall (capability_init); -module_exit (capability_exit); - -MODULE_DESCRIPTION ("Standard Linux Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/commoncap.c +0 -3
@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid);EXPORT_SYMBOL (cap_task_reparent_to_init);EXPORT_SYMBOL (cap_syslog);EXPORT_SYMBOL (cap_vm_enough_memory); - -MODULE_DESCRIPTION ("Standard Linux Common Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );
security/dummy.c +0 -1
@@ -15,7 +15,6 @@#undef DEBUG#include <linux/capability.h> -#include <linux/module.h> #include <linux/kernel.h> #include <linux/mman.h> #include <linux/pagemap.h>
security/root_plug.c +1 -30
@@ -22,11 +22,11 @@* License. */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h> #include <linux/usb.h> +#include <linux/moduleparam.h> /* flag to keep track of how we were registered */ static int secondary;
@@ -36,22 +36,14 @@ static int vendor_id = 0x0557;static int product_id =0x2008 ;module_param (vendor_id, uint,0400 ); -MODULE_PARM_DESC (vendor_id,"USB Vendor ID of device to look for" ); -module_param (product_id, uint,0400 ); -MODULE_PARM_DESC (product_id,"USB Product ID of device to look for" );/* should we print out debug messages */ static int debug =0 ;module_param (debug, bool,0600 ); -MODULE_PARM_DESC (debug,"Debug enabled or not" ); -#if defined(CONFIG_SECURITY_ROOTPLUG_MODULE ) -#define MY_NAME THIS_MODULE->name -#else #define MY_NAME "root_plug" -#endif #define root_dbg(fmt, arg...) \ do { \
@@ -117,25 +109,4 @@ static int __init rootplug_init (void)return 0 ; } -static void __exit rootplug_exit (void) -{ -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (MY_NAME , &rootplug_security_ops)) -printk (KERN_INFO "Failure unregistering Root Plug " -" module with primary module.\n" ); - }else { -if (unregister_security (&rootplug_security_ops)) { -printk (KERN_INFO "Failure unregistering Root Plug " -"module with the kernel\n" ); - } - } -printk (KERN_INFO "Root Plug module removed\n" ); -} -security_initcall (rootplug_init); -module_exit (rootplug_exit); - -MODULE_DESCRIPTION ("Root Plug sample LSM module, written for Linux Journal article" ); -MODULE_LICENSE ("GPL" ); -
security/security.c +946 -8
969 lines not on this page · raw message
security/selinux/hooks.c +0 -1
@@ -20,7 +20,6 @@* as published by the Free Software Foundation. */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/ptrace.h>
security/selinux/xfrm.c +0 -1
@@ -31,7 +31,6 @@* 2. Emulating a reasonable SO_PEERSEC across machines * 3. Testing addition of sk_policy's with security context via setsockopt */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h>
Signature · 1 line
1.5.2.1
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to James MorrisQuoted 3 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all. The mere fact that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.
Thanks,
Andreas
James Morris
maintainerRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.
That's not the argument. Please review the thread.
- James
Signature · 2 lines
James Morris <[email protected]>
Serge E. Hallyn
maintainerRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
-serge
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting MODULE_LICENSE("GPL") into their binary-only modules and who ignore you and get away because noone sues them?
The spirit of the GPLv2 is to defend the freedom of the software (different from the spirit of the BSD licence), and considering that there aren't many people defending the GPLv2 copyright of the Linux kernel at court against abusers, making it harder for people to do the abuse might not be the worst choice...
Quoted 1 line
-serge
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 5 lines
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?
Do these really exist? Maybe noone sues them because noone knows who they are...
But - note that you've changed completely the meaning of 'abuse'. So mine was wrong?
Quoted 5 lines
The spirit of the GPLv2 is to defend the freedom of the software (different from the spirit of the BSD licence), and considering that there aren't many people defending the GPLv2 copyright of the Linux kernel at court against abusers, making it harder for people to do the abuse might not be the worst choice...
Well, but you seem to be saying that the license means squat, and resorting to making things inconvenient rather than illegal.
Now I guess if it really is accepted that that's the way it should be, then this patch will go in.
-serge
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 33 lines · Serge E. Hallyn
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 8 lines
Quoted 5 lines
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?Do these really exist? Maybe noone sues them because noone knows who they are...
http://lwn.net/Articles/82306/
Quoted 2 lines
But - note that you've changed completely the meaning of 'abuse'. So mine was wrong?
Technical and legal abuse are related.
For GPL'ed modules you might assume good faith and get the authors to do things in a proper way. Authors of legally questionable modules that cheat in many ways are quite a different issue.
Quoted 8 lines
Quoted 5 lines
The spirit of the GPLv2 is to defend the freedom of the software (different from the spirit of the BSD licence), and considering that there aren't many people defending the GPLv2 copyright of the Linux kernel at court against abusers, making it harder for people to do the abuse might not be the worst choice...
Well, but you seem to be saying that the license means squat, and resorting to making things inconvenient rather than illegal.
No, the point is that there's no reason for making illegal things convenient.
I'm not talking about removing things that are used inside the kernel, but what you call "freedom" can also be called "hooks for possible abuse".
Additionally, it both makes the kernel bigger for everyone and requires proper handling of loading/unloading in the security architecture.
Quoted 4 lines
Now I guess if it really is accepted that that's the way it should be, then this patch will go in.
-serge
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 36 lines · Adrian Bunk
Quoted 35 lines · Serge E. Hallyn
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 2 lines
For _some_ "wrong-doers" your approach works.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?Do these really exist? Maybe noone sues them because noone knows who they are...
http://lwn.net/Articles/82306/
LinuxAnt? Are they using LSM?
It looks to me like this patch will do nothing about them.
Quoted 4 lines
Quoted 2 lines
But - note that you've changed completely the meaning of 'abuse'. So mine was wrong?
Technical and legal abuse are related.
True but going by your logic we could remove support for modules period to prevent legal abuse by non-gpl modules.
Quoted 10 lines
For GPL'ed modules you might assume good faith and get the authors to do things in a proper way. Authors of legally questionable modules that cheat in many ways are quite a different issue.
Quoted 6 lines
Quoted 5 lines
The spirit of the GPLv2 is to defend the freedom of the software (different from the spirit of the BSD licence), and considering that there aren't many people defending the GPLv2 copyright of the Linux kernel at court against abusers, making it harder for people to do the abuse might not be the worst choice...
Quoted 5 lines
Quoted 2 lines
Well, but you seem to be saying that the license means squat, and resorting to making things inconvenient rather than illegal.
No, the point is that there's no reason for making illegal things convenient.
But no, the point is that that you are making legal things very inconvenient.
Quoted 1 line
I'm not talking about removing things that are used inside the kernel,
Since capabilities can currently be compiled as a module, you are. (Though that sounds weird, so maybe I'm misreading what you are saying)
Quoted 1 line
but what you call "freedom" can also be called "hooks for possible abuse".
Yup, that is true.
Quoted 10 lines
Additionally, it both makes the kernel bigger for everyone and requires proper handling of loading/unloading in the security architecture.
Quoted 4 lines
Now I guess if it really is accepted that that's the way it should be, then this patch will go in.
-serge
cu
Adrian
thanks,
-serge
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 41 lines · Serge E. Hallyn
Quoted 40 lines · Adrian Bunk
Quoted 39 lines · Serge E. Hallyn
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 5 lines
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do these really exist? Maybe noone sues them because noone knows who they are...
http://lwn.net/Articles/82306/LinuxAnt? Are they using LSM?
It looks to me like this patch will do nothing about them.
It was an example how creative "wrong-doers" sometimes are.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
But - note that you've changed completely the meaning of 'abuse'. So mine was wrong?
Technical and legal abuse are related.
True but going by your logic we could remove support for modules period to prevent legal abuse by non-gpl modules.
The problem is that this would result in distributions having to ship 50 MB kernel images.
Quoted 16 lines
Quoted 10 lines
For GPL'ed modules you might assume good faith and get the authors to do things in a proper way. Authors of legally questionable modules that cheat in many ways are quite a different issue.
Quoted 6 lines
Quoted 5 lines
The spirit of the GPLv2 is to defend the freedom of the software (different from the spirit of the BSD licence), and considering that there aren't many people defending the GPLv2 copyright of the Linux kernel at court against abusers, making it harder for people to do the abuse might not be the worst choice...
Quoted 5 lines
Quoted 2 lines
Well, but you seem to be saying that the license means squat, and resorting to making things inconvenient rather than illegal.
No, the point is that there's no reason for making illegal things convenient.
Quoted 7 lines
But no, the point is that that you are making legal things very inconvenient.
Quoted 1 line
I'm not talking about removing things that are used inside the kernel,
Since capabilities can currently be compiled as a module, you are. (Though that sounds weird, so maybe I'm misreading what you are saying)
If the LSM maintainer says non-modular capabilities is the way to go then there's no user left.
Quoted 4 lines
Quoted 1 line
but what you call "freedom" can also be called "hooks for possible abuse".
Yup, that is true.
Quoted 8 lines
Quoted 5 lines
Additionally, it both makes the kernel bigger for everyone and requires proper handling of loading/unloading in the security architecture.
Quoted 2 lines
Now I guess if it really is accepted that that's the way it should be, then this patch will go in.
thanks,
-serge
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedRe: [PATCH try #2] security: Convert LSM into a static interface
In reply to Serge E. HallynQuoted 33 lines · Serge E. Hallyn
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 7 lines
Quoted 5 lines
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?Do these really exist?
Yes they do.
Quoted 1 line
Maybe noone sues them because noone knows who they are...
Maybe no one knows because the people doing the legal action against them are trying to be nice and do it quietly.
And legal action takes time, it is quite slow going unfortunatly.
Heck, I've seen code that is even properly licensed under the GPL abuse this security layer for things it was not ment to do at all, and that stuff comes from _very_ big companies that really should know better...
So I agree that we should unexport it. It will make people who want to abuse the interface at least think twice about it.
thanks,
greg "I want to mark structures read-only" k-h
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 40 lines · Greg KH
Quoted 39 lines · Serge E. Hallyn
Quoted 21 lines · Adrian Bunk
Quoted 20 lines · Serge E. Hallyn
Quoted 5 lines · James Morris
Quoted 2 lines · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all.
Quoted 8 lines
Which LSMs? Upstream, there are SELinux and capabilty, and they're not safe as loadable modules.
Quoted 3 lines
The mere fact
that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.That's not the argument. Please review the thread.
The argument is 'abuse', right?
Abuse is defined as using the LSM hooks for non-security applications, right?
Quoted 8 lines
Quoted 6 lines
It seems to me that the community is doing a good job of discouraging such abuse - by redirecting the "wrong-doers" to implement proper upstream solutions, i.e. taskstats, the audit subsystem, etc.
Such encouragement seems a far better response than taking away freedoms and flexibility from everyone.
We are not living in a world where everyone had good intentions...
Oh no, i took a wrong turn somewhere :)
Quoted 5 lines
For _some_ "wrong-doers" your approach works.
But how do you convince the "wrong-doers" who do things like putting
MODULE_LICENSE("GPL")into their binary-only modules and who ignore you and get away because noone sues them?
Quoted 8 lines
Quoted 1 line
Do these really exist?
Yes they do.
Quoted 1 line
Maybe noone sues them because noone knows who they are...
Maybe no one knows because the people doing the legal action against them are trying to be nice and do it quietly.
So they're being nice to the violaters, and then clamping down on everyone...
Quoted 5 lines
And legal action takes time, it is quite slow going unfortunatly.
Heck, I've seen code that is even properly licensed under the GPL abuse this security layer for things it was not ment to do at all, and that stuff comes from _very_ big companies that really should know better...
But that's back to the other type of 'abuse' which i was originally talking about, and which IMO is being well addressed through education.
As for the others, I have no better suggestions. I wish I did.
Quoted 2 lines
So I agree that we should unexport it. It will make people who want to abuse the interface at least think twice about it.
And those who don't abuse it too.
Quoted 3 lines
thanks,
greg "I want to mark structures read-only" k-h
And I know I'm not the one who's going to stop you...
-serge
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to Andreas GruenbacherQuoted 4 lines · Andreas Gruenbacher
Quoted 1 line · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all. The mere fact that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.
Here are a few questions for you:
1) What do you expect to happen to all the megs of security data
when you "rmmod selinux"? Do you maintain a massive linked list of security data (with all the locking and performance problems) so that you can iterate over it calling kfree()? What synchronization primitive do we have right now which could safely stop all CPUs outside of security calls while we NULL out and free security data and disable security operations? Don't say "software suspend" and "process freezer", since those have whole order-of-magnitude-complexity problems of their own (and don't always work right either).
2) When you "modprobe my_custom_security_module", how exactly do
you expect that all the processes, files, shared memory segments, file descriptors, sockets, SYSV mutexes, packets, etc will get appropriate security pointers? This isn't even solvable the same way the "rmmod" problem is, since most of that isn't even accessible without iterating over the ENTIRE dcache, icache, every process, every process' file-descriptors, every socket, every unix socket, every anonymous socket, every SYSV shm object, every currently-in-process packet.
3) This sounds suspiciously like "The mere fact that the
Linux-2.6-VM cannot be built as a module is a rather weak argument for disabling VFS modules as a whole". We don't do "pluggable fundamental infrastructure" in Linux. If it's fundamental infrastructure then you eliminate as many differences as possible and leave the rest to CONFIG options (or delete it entirely).
So... Do you have a proposal for solving those rather fundamental design gotchas? If so, I'm sure everybody here would love to see your patch; though maybe not if it's a 32MB patch-zilla-of-doom (AKPM beware, the merge-conflict-from-hell is on its way). On the other hand, if you accept that these problems basically can't be solved and we make things static and rip out a bunch of code, we can probably improve our performance under larger security models (like SELinux/AppArmor/TOMOYO/MagicSecurityFlavorOfTheWeek(TM)) by a percent or two.
Cheers,
Kyle Moffett
Re: [PATCH try #2] security: Convert LSM into a static interface
Oops, typo:
Quoted 1 line · Kyle Moffett
This sounds suspiciously like "The mere fact that the Linux-2.6-VM cannot be built as a module is a rather weak argument for disabling VFS modules as a whole"
Meant to say: "...disabling VM modules as a whole."
Cheers,
Kyle Moffett
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to Kyle MoffettQuoted 12 lines · Kyle Moffett
Quoted 10 lines · Andreas Gruenbacher
Quoted 3 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all. The mere fact that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.
Quoted 4 lines
Here are a few questions for you:
1) What do you expect to happen to all the megs of security data
when you "rmmod selinux"?
Read the sentence right above yours again.
Noone is saying we should be able to rmmod selinux.
Quoted 9 lines
Do you maintain a massive linked list of
security data (with all the locking and performance problems) so that you can iterate over it callingkfree()? What synchronization primitive do we have right now which could safely stop all CPUs outside of security calls while we NULL out and free security data and disable security operations? Don't say "software suspend" and "process freezer", since those have whole order-of-magnitude- complexity problems of their own (and don't always work right either).
Quoted 4 lines
2) When you "modprobe
my_custom_security_module", how exactly do
you expect that all the processes, files, shared memory segments, file descriptors, sockets, SYSV mutexes, packets, etc will get appropriate security pointers?>
Those don't all need labels for capabilities, for instance. This question is as wrong as the last one.
Quoted 10 lines
This isn't even solvable the same way
the "rmmod" problem is, since most of that isn't even accessible without iterating over the ENTIRE dcache, icache, every process, every process' file-descriptors, every socket, every unix socket, every anonymous socket, every SYSV shm object, every currently-in- process packet.3) This sounds suspiciously like "The mere fact that the
Linux-2.6-VM cannot be built as a module is a rather weak argument for disabling VFS modules as a whole". We don't do "pluggable
No, your argument sounds like "my fs can't be a module so neither should any."
Quoted 22 lines
fundamental infrastructure" in Linux. If it's fundamental infrastructure then you eliminate as many differences as possible and leave the rest to CONFIG options (or delete it entirely).
So... Do you have a proposal for solving those rather fundamental design gotchas? If so, I'm sure everybody here would love to see your patch; though maybe not if it's a 32MB patch-zilla-of-doom (AKPM beware, the merge-conflict-from-hell is on its way). On the other hand, if you accept that these problems basically can't be solved and we make things static and rip out a bunch of code, we can probably improve our performance under larger security models (like SELinux/ AppArmor/TOMOYO/MagicSecurityFlavorOfTheWeek(TM)) by a percent or two.
Cheers,
Kyle Moffett-
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 4 lines · Serge E. Hallyn
Quoted 3 lines · Kyle Moffett
Quoted 1 line · Andreas Gruenbacher
It's useful for some LSMs to be modular, and LSMs which are y/n options won't have any security architecture issues with unloading at all. The mere fact that SELinux cannot be built as a module is a rather weak argument for disabling LSM modules as a whole, so please don't.
Quoted 8 lines
Quoted 4 lines
Here are a few questions for you:
1) What do you expect to happen to all the megs of security
data when you "rmmod selinux"?Read the sentence right above yours again.
Noone is saying we should be able to rmmod selinux.
Ok, so say we extend LSM to do what AppArmor or TOMOYO need, what do you expect to happen when you "rmmod tomoyo", "rmmod apparmor", or whatever? Each of those is also going to stick lots of context on various objects during the course of running, the same way that the VM subsystem sticks lots of context on filesystem pages while running. Besides, even the standard "capabilities" module wants to attach a list of capabilities to every process and defines inheritance rules for them. Ergo you have the problems described below:
Quoted 6 lines
Quoted 4 lines
Do you maintain a massive linked list of security data (with all the locking and performance problems) so that you can iterate over it calling
kfree()? What synchronization primitive do we have right now which could safely stop all CPUs outside of security calls while we NULL out and free security data and disable security operations? Don't say "software suspend" and "process freezer", since those have whole order-of-magnitude-complexity problems of their own (and don't always work right either).2) When you "modprobe
my_custom_security_module", how exactly
do you expect that all the processes, files, shared memory segments, file descriptors, sockets, SYSV mutexes, packets, etc will get appropriate security pointers?Those don't all need labels for capabilities, for instance. This question is as wrong as the last one.
Ok, so let's just restrict ourselves to the simple dumb-as-dirt capabilities module. Every process is "labeled" with capabilities while running under that LSM, right? What happens when you "rmmod capabilities"? Do you iterate over all the processes to remove their security data even while they may be using it? Or do you just let it leak? Some daemons test if capabilities are supported, and if so they modify their capability set instead of forking a high-priv and a low-priv process and doing IPC. When you remove the capabilities module, suddenly all those programs will lose that critical "low-privilege" data and become full root. What happens later when you "modprobe capabilities"? Do you suddenly have to stop the system while you iterate over EVERY process to set capabilities based on whether it's root or not? It's also impossible to determine from a given state in time what processes should have capabilities, as the model includes inheritance, which includes processes that don't even exist anymore.
Quoted 3 lines
Quoted 1 line
3) This sounds suspiciously like "The mere fact that the Linux-2.6-VM cannot be built as a module is a rather weak argument for disabling VFS modules as a whole".
No, your argument sounds like "my fs can't be a module so neither should any."
Let's go over the differences between "my fs" and "my LSM", and the similarities between "my VM" and "my LSM": Filesystems don't get hooked from virtually every userspace-initiated operation, whereas both VMs and LSMs do. VMs and LSMs attach anonymous state data to a large percentage of the allocated objects in the system, whereas filesystems allocate their own independent datastructure and use that. Would you want to "rmmod ext3" and then "modprobe ext2" while you have an ext2-as-ext3 filesystem *mounted*??? If you want a good analogy, that's a better one than the "my fs can't be a module" crap.
This whole discussion boils down to 2 points:
1) As currently implemented, no LSM may be safely rmmod-ed
2) Someone has submitted a patch which fixes that problem (you
can't rmmod them at all, so no crashes)
If you really want to do modular LSMs, then you need to submit a patch which fixes all the race conditions in LSM removal *without* adding much extra overhead. I'm sure if your solutions works then everyone will be much more open to modular LSMs. I said this before:
Quoted 1 line
Quoted 1 line
So... Do you have a proposal for solving those rather fundamental design gotchas? If so, I'm sure everybody here would love to see your patch
Cheers,
Kyle Moffett
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 15 lines · Kyle Moffett
Let's go over the differences between "my fs" and "my LSM", and the similarities between "my VM" and "my LSM": Filesystems don't get hooked from virtually every userspace-initiated operation, whereas both VMs and LSMs do. VMs and LSMs attach anonymous state data to a large percentage of the allocated objects in the system, whereas filesystems allocate their own independent datastructure and use that. Would you want to "rmmod ext3" and then "modprobe ext2" while you have an ext2-as-ext3 filesystem *mounted*??? If you want a good analogy, that's a better one than the "my fs can't be a module" crap.
This whole discussion boils down to 2 points:
1) As currently implemented, no LSM may be safely rmmod-ed
2) Someone has submitted a patch which fixes that problem (you can't
rmmod them at all, so no crashes)
Quoted 4 lines
If you really want to do modular LSMs, then you need to submit a patch which fixes all the race conditions in LSM removal *without* adding much extra overhead. I'm sure if your solutions works then everyone will be much more open to modular LSMs. I said this before:
Hmmm. You seem to be mostly concerned with safely rmmod'ing modules. In contrast, my main concern with the proposed patch is that it removes the ability to *insert* a module.
Consider the use case of joe admin who is running enterprise-supported RHEL or SLES, and wants to try some newfangled LSM FooSecureMod thingie. So he grabs a machine, config's selinux=0 or apparmor=0 and loads his own module on boot, and plays with it. He even likes FooSecure, better than SELinux or AppArmor, and wants to roll it out across his data center.
Without James's patch, he can do that, and at worst has a tainted kernel. RH or Novell or his favorite distro vendor can fix that with a wave of the hand and bless FooSecure as a module. With James's patch, he has to patch his kernels, and then enterprise support is hopeless, to say nothing of the barrier to entry that "patch and rebuild kernel" is more than many admins are willing to do.
So to solve the problem James & Kyle are concerned with, and preserve user choice, how about we *only* remove the ability to rmmod, and leave in place the ability to modprobe? Or even easier, LSMs that don't want to be unloaded can just block rmmod, and simple LSMs that can be unloaded safely can permit it.
Crispin
Signature · 3 lines
Crispin Cowan, Ph.D. http://crispincowan.com/~crispin/ Director of Software Engineering http://novell.com AppArmor Chat: irc.oftc.net/#apparmor
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 9 lines · Crispin Cowan
Quoted 8 lines · Kyle Moffett
Let's go over the differences between "my fs" and "my LSM", and the similarities between "my VM" and "my LSM": Filesystems don't get hooked from virtually every userspace-initiated operation, whereas both VMs and LSMs do. VMs and LSMs attach anonymous state data to a large percentage of the allocated objects in the system, whereas filesystems allocate their own independent datastructure and use that. Would you want to "rmmod ext3" and then "modprobe ext2" while you have an ext2-as-ext3 filesystem *mounted*??? If you want a good analogy, that's a better one than the "my fs can't be a module" crap.
This whole discussion boils down to 2 points:
1) As currently implemented, no LSM may be safely rmmod-ed
2) Someone has submitted a patch which fixes that problem (you
can't
rmmod them at all, so no crashes)
Quoted 3 lines
Quoted 1 line
If you really want to do modular LSMs, then you need to submit a patch which fixes all the race conditions in LSM removal *without* adding much extra overhead. I'm sure if your solutions works then everyone will be much more open to modular LSMs.
Hmmm. You seem to be mostly concerned with safely rmmod'ing modules. In contrast, my main concern with the proposed patch is that it removes the ability to *insert* a module.
You must have missed this in my emails:
Quoted 2 lines
Quoted 2 lines
2) When you "modprobe
my_custom_security_module", how exactly do
you expect that all the processes, files, shared memory segments, file descriptors, sockets, SYSV mutexes, packets, etc will get appropriate security pointers? This isn't even solvable the same way the "rmmod" problem is, since most of that isn't even accessible without iterating over the ENTIRE dcache, icache, every process, every process' file-descriptors, every socket, every unix socket, every anonymous socket, every SYSV shm object, every currently-in-process packet.
I'd argue that security-module-insertion is actually MORE complicated than removal. Here's one example: TOMOYO cares about the process execution tree, but you can't penalize the no-LSM case by a percent or two to add that kind of data. When TOMOYO is loaded, it wants to do access control based on process execution trees for which data DOES NOT EXIST!!! Not only that, but the processes which originally ran the one you care about (and which you'd need to recreate that data) may have exited anywhere from seconds to years before. It is fundamentally IMPOSSIBLE to recreate that data, even if you could solve the problems of how to do it while the system is running without racing with existing process operations. Imagine a process which hasn't had security data tagged to it yet which opens thousands of FIFOs per second, waits for your tagging code to assign security data to them in the filesystem, and then removes them; if you did it right you could prevent the code from EVER completely tagging every object (even assuming you could recreate enough information).
Such a need to add extra security data to multiple classes of objects is *fundamental* to any security module (isn't that the whole point?) As such, you can't just "modprobe" one and expect it to work. That's like mounting an ext2 filesystem, and then later trying to "modprobe ext3" and dynamically switch to the ext3 code and enable journalling all at once ON THE MOUNTED FILESYSTEM!!!
Sure, theoretically it *could* be done, but the code complexity is hardly worth it (plus nobody has yet even tried posting patches to make it happen).
Quoted 1 line
Consider the use case of joe admin who is running enterprise-supported RHEL or SLES, and wants to try some newfangled LSM FooSecureMod thingie. So he grabs a machine, config's selinux=0 or apparmor=0 and loads his own module on boot, and plays with it. He even likes FooSecure, better than SELinux or AppArmor, and wants to roll it out across his data center.
Flatly impossible. You simply cannot "load" a security module and hope to provide any useful information about the system's present state. If you want comprehensive security it has to be there before a single byte of userspace code is executed. SELinux sort-of handles unlabelled objects by treating them with a small set of initial "types", but that's only enough to get the system up enough to actually relabel objects with type-transitions (after init loads the selinux policy it reexecs itself, before doing anything else).
Quoted 1 line
So to solve the problem James & Kyle are concerned with, and preserve user choice, how about we *only* remove the ability to rmmod, and leave in place the ability to modprobe? Or even easier, LSMs that don't want to be unloaded can just block rmmod, and simple LSMs that can be unloaded safely can permit it.
An LSM simple enough to unload would be too simple for anybody to want to load in the first place (even capabilities can have this problem). What kind of security module would you load that doesn't need to add security data to objects?
Then of course there's also the -ENOPATCH problem.
Cheers,
Kyle Moffett
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to Crispin CowanQuoted 2 lines · * Crispin Cowan ([email protected]) wrote:
and simple LSMs that can be
unloaded safely can permit it.
there are none, and making the above possible is prohibitively expensive.
Re: [PATCH try #2] security: Convert LSM into a static interface
In reply to Kyle MoffettQuoted 1 line · Kyle Moffett
This whole discussion boils down to 2 points:
Yes it can, but not the two you list.
Quoted 1 line
1) As currently implemented, no LSM may be safely rmmod-ed
That's not the rationale for the patch, it's just some talking point you picked up. The rationale for the patch is to prevent abuse. So point 1 is
1) Is the LSM infrastructure being abused, and how detrimental is that abuse
As has come up, the abuse comes in two forms, and people seem to want to blur the two forms to make it seem especially relevant and heinous...
Quoted 2 lines
2) Someone has submitted a patch which fixes that problem (you
can't rmmod them at all, so no crashes)
2) Is the loss of flexibility in the LSM framework a worthwhile tradoff against the abuse prevention.
Clearly I and a very few others feel no, and a very vocal set (which sure sounds like a majority) says yes.
Now quit trying to give technical justifications for something which is technical only insofar as it is a technical roadblock to prevent a legal problem.
Quoted 2 lines
If you really want to do modular LSMs, then you need to submit a patch which fixes all the race conditions in LSM removal *without*
LSM is an infrastructure. It's up to the modules to provide that, and it can be done. DTE used to do it. Dirjail used to do it. Capability does it.
And since LSM won't be modular anymore it doesn't matter.
Quoted 2 lines
adding much extra overhead. I'm sure if your solutions works then everyone will be much more open to modular LSMs. I said this before:
Another blatant lie, not unlike "come to the table to upstream your LSM, and we'll help you, honest."
(The funny thing about that is, I actually like SELinux, more than the alternatives in general. I just can't stand the attitudes voice by much of its camp.)
-serge
PS - should we rename 'LSM' to 'LSI' - linux security infrastructure? Calling it LSM now is kind of moronic.
James Morris
maintainerRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 9 lines · Serge E. Hallyn
Quoted 1 line · Kyle Moffett
This whole discussion boils down to 2 points:
Yes it can, but not the two you list.
Quoted 1 line
1) As currently implemented, no LSM may be safely rmmod-ed
That's not the rationale for the patch, it's just some talking point you picked up. The rationale for the patch is to prevent abuse.
This is not correct. Reducing API abuse is simply a bonus.
The rationale for the patch is to remove unneeded infrastructure which complicates security by introducing the idea that the security module can be removed at all.
It was in response to your very own posting about the new capabilities code which would need to take this into account.
Recall:
Quoted 10 lines · Serge E. Hallyn
Quoted 3 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.The functionality is special, but someone with
CAP_SYS_ADMINcan always unload the capability module and create the security.capability xattr using the dummy module.If we do add this cap, do we want to make it apply to all security.* xattrs?
The underlying issue here is the notion of security mechanisms which are built as loadable modules. It's not useful for any in-tree users, and introduces several unnecessary problems which then need to be addressed.
A better approach would be to make LSM a statically linked interface.
This would also allow us to unexport the LSM symbols and reduce the API abuse by third-party modules.
- James
Signature · 2 lines
James Morris <[email protected]>
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 12 lines · James Morris
Quoted 9 lines · Serge E. Hallyn
Quoted 1 line · Kyle Moffett
This whole discussion boils down to 2 points:
Yes it can, but not the two you list.
Quoted 1 line
1) As currently implemented, no LSM may be safely rmmod-ed
That's not the rationale for the patch, it's just some talking point you picked up. The rationale for the patch is to prevent abuse.
Quoted 8 lines
This is not correct. Reducing API abuse is simply a bonus.
The rationale for the patch is to remove unneeded infrastructure which complicates security by introducing the idea that the security module can be removed at all.
It was in response to your very own posting about the new capabilities code which would need to take this into account.
It's (IMO) by far not the optimal "solution" :) If it is felt a solution is really needed, re-introduction of a security_ops->module_exit hook and introduction of CAP_SYS_CAPDISABLE would be better.
But I'm well aware there are far too many (separate and not so separate) agendas driving this, and have no expectations of being able to stop it.
James, FWIW, I'm sorry I haven't had a chance to actually test the patch. I'll try to get around to that today or at least this week.
-serge
Quoted 34 lines
Recall:
Quoted 10 lines · Serge E. Hallyn
Quoted 3 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.The functionality is special, but someone with
CAP_SYS_ADMINcan always unload the capability module and create the security.capability xattr using the dummy module.If we do add this cap, do we want to make it apply to all security.* xattrs?
The underlying issue here is the notion of security mechanisms which are built as loadable modules. It's not useful for any in-tree users, and introduces several unnecessary problems which then need to be addressed.
A better approach would be to make LSM a statically linked interface.
This would also allow us to unexport the LSM symbols and reduce the API abuse by third-party modules.
- James
Signature · 6 lines
James Morris <[email protected]> - To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 27 lines · Serge E. Hallyn
Quoted 12 lines · James Morris
Quoted 9 lines · Serge E. Hallyn
Quoted 1 line · Kyle Moffett
This whole discussion boils down to 2 points:
Yes it can, but not the two you list.
Quoted 1 line
1) As currently implemented, no LSM may be safely rmmod-ed
That's not the rationale for the patch, it's just some talking point you picked up. The rationale for the patch is to prevent abuse.
Quoted 8 lines
This is not correct. Reducing API abuse is simply a bonus.
The rationale for the patch is to remove unneeded infrastructure which complicates security by introducing the idea that the security module can be removed at all.
It was in response to your very own posting about the new capabilities code which would need to take this into account.
It's (IMO) by far not the optimal "solution" :) If it is felt a solution is really needed, re-introduction of a
security_ops->module_exithook and introduction ofCAP_SYS_CAPDISABLEwould be better.
Quoted 5 lines
But I'm well aware there are far too many (separate and not so separate) agendas driving this, and have no expectations of being able to stop it.
James, FWIW, I'm sorry I haven't had a chance to actually test the patch. I'll try to get around to that today or at least this week.
Patch tests fine for me for expected capability behavior with lsm=n, lsm=y, lsm=y+capability=y, lsm=y+selinux=y, and lsm=y+caps=y+selinux=y.
So while I'm opposed to the patch, it appears to be safe.
thanks,
-serge
James Morris
maintainerRe: [PATCH try #2] security: Convert LSM into a static interface
Quoted 4 lines · Serge E. Hallyn
Patch tests fine for me for expected capability behavior with lsm=n, lsm=y, lsm=y+capability=y, lsm=y+selinux=y, and lsm=y+caps=y+selinux=y.
So while I'm opposed to the patch, it appears to be safe.
I've also tested a bunch of scenarios: allmodconfig, lsm=y,cap=n, selinux=y,cap=n etc.
Signature · 2 lines
James Morris <[email protected]>
Re: [PATCH try #2] security: Convert LSM into a static interface
Quoted 9 lines · James Morris
Quoted 4 lines · Serge E. Hallyn
Patch tests fine for me for expected capability behavior with lsm=n, lsm=y, lsm=y+capability=y, lsm=y+selinux=y, and lsm=y+caps=y+selinux=y.
So while I'm opposed to the patch, it appears to be safe.
I've also tested a bunch of scenarios: allmodconfig, lsm=y,cap=n, selinux=y,cap=n etc.
I was wondering about the uninlining of all those functions, so did a set of performance runs. Found no statistically relevant change in dbench, tbench, or reaim. (tried to run kernbench too but the benchmark failed somewhere and i didn't care enough to look into it)
-serge
Serge E. Hallyn
maintainerRe: [PATCH][RFC] security: Convert LSM into a static interface
In reply to James MorrisQuoted 11 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Module parameters for the capability and
root_plugmodules have been converted to kernel parameters.The
SECURITY_FRAMEWORK_VERSIONmacro has also been removed.
Sigh, as much as I would *like* to stay out of this (I don't use modules at all on any system where I can avoid it), won't it make development - and especially testing - of new lsms much more painful and therefore less likely?
I realize there has been a dearth of new LSMs to date, but if for instance a new solaris 10 based capability module were written, well, people would want to be able to
rmmod capability
modprobe cap_prm
thanks,
-serge
Quoted 309 lines
Signed-off-by James Morris <[email protected]>---
Please review & let me know if anything is broken.
Documentation/kernel-parameters.txt | 17 +++++++++++ security/Kconfig | 4 +- security/capability.c | 32 ++++---------------- security/commoncap.c | 3 -- security/dummy.c | 1 - security/root_plug.c | 53 +++++++++++++--------------------- security/security.c | 9 +---- security/selinux/hooks.c | 1 - security/selinux/xfrm.c | 1 - 9 files changed, 48 insertions(+), 73 deletions(-)Documentation/kernel-parameters.txt +17
-0@@ -74,10 +74,12 @@ parameter is applicable: PPT Parallel port support is enabled. PS2 Appropriate PS/2 support is enabled. RAM RAM disk support is enabled. + ROOTPLUG The example Root Plug LSM is enabled. S390 S390 architecture is enabled. SCSI Appropriate SCSI support is enabled. A lot of drivers has their options described inside of Documentation/scsi/. + SECURITY Different security models are enabled. SELINUX SELinux support is enabled. SERIAL Serial support is enabled. SH SuperH architecture is enabled.@@ -376,6 +378,12 @@ and is between 256 and 4096 characters. It is defined in the file possible to determine what the correct size should be. This option provides an override for these situations. + capability_disable= + [SECURITY] Disable capabilities. This would normally + be used only if an alternative security model is to be + configured. Potentially dangerous and should only be + used if you are entirely sure of the consequences. + cdu31a= [HW,CD] Format: <io>,<irq>[,PAS] See header of drivers/cdrom/cdu31a.c.@@ -1541,6 +1549,15 @@ and is between 256 and 4096 characters. It is defined in the file rootfstype= [KNL] Set root filesystem type + root_plug_vendor_id= + [ROOTPLUG] Override the default vendor ID + + root_plug_product_id= + [ROOTPLUG] Override the default product ID + + root_plug_debug= + [ROOTPLUG] Enable debugging output + rw [KNL] Mount root device read-write on boot S [KNL] Run init in single modesecurity/Kconfig +2
-2@@ -74,14 +74,14 @@ config SECURITY_NETWORK_XFRM If you are unsure how to answer this question, answer N. config SECURITY_CAPABILITIES - tristate "Default Linux Capabilities" + bool "Default Linux Capabilities" depends on SECURITY help This enables the "default" Linux capabilities functionality. If you are unsure how to answer this question, answer Y. config SECURITY_ROOTPLUG - tristate "Root Plug Support" + bool "Root Plug Support" depends on USB && SECURITY help This is a sample LSM module that should only be used as such.security/capability.c +7
-25@@ -8,7 +8,6 @@* */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/security.h> @@ -51,8 +50,13 @@ static struct security_operations capability_ops = {static int secondary;static int capability_disable; -module_param_named (disable, capability_disable, int,0 ); -MODULE_PARM_DESC (disable,"To disable capabilities module set disable = 1" ); + +static int __init capability_disable_setup (char *str) +{ + capability_disable =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("capability_disable=" , capability_disable_setup);static int __init capability_init (void ) {@@ -75,26 +79,4 @@ static int __init capability_init (void)return 0 ; } -static void __exit capability_exit (void) -{ -if (capability_disable) -return ; -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (KBUILD_MODNAME , &capability_ops)) -printk (KERN_INFO "Failure unregistering capabilities " -"with primary module.\n" ); -return ; - } - -if (unregister_security (&capability_ops)) { -printk (KERN_INFO -"Failure unregistering capabilities with the kernel\n" ); - } -} -security_initcall (capability_init); -module_exit (capability_exit); - -MODULE_DESCRIPTION ("Standard Linux Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );security/commoncap.c +0
-3@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid);EXPORT_SYMBOL (cap_task_reparent_to_init);EXPORT_SYMBOL (cap_syslog);EXPORT_SYMBOL (cap_vm_enough_memory); - -MODULE_DESCRIPTION ("Standard Linux Common Capabilities Security Module" ); -MODULE_LICENSE ("GPL" );security/dummy.c +0
-1@@ -15,7 +15,6 @@#undef DEBUG#include <linux/capability.h> -#include <linux/module.h> #include <linux/kernel.h> #include <linux/mman.h> #include <linux/pagemap.h> security/root_plug.c +20
-33@@ -22,7 +22,6 @@* License. */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h> @@ -33,25 +32,34 @@ static int secondary;/* default is a generic type of usb to serial converter */ static int vendor_id =0x0557 ; -static int product_id =0x2008 ; -module_param (vendor_id, uint,0400 ); -MODULE_PARM_DESC (vendor_id,"USB Vendor ID of device to look for" ); +static int __init root_plug_vendor_id (char *str) +{ + vendor_id =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("root_plug_vendor_id=" , root_plug_vendor_id); + +static int product_id =0x2008 ; -module_param (product_id, uint,0400 ); -MODULE_PARM_DESC (product_id,"USB Product ID of device to look for" ); +static int __init root_plug_product_id (char *str) +{ + product_id =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("root_plug_product_id=" , root_plug_product_id);/* should we print out debug messages */ static int debug =0 ; -module_param (debug, bool,0600 ); -MODULE_PARM_DESC (debug,"Debug enabled or not" ); +static int __init root_plug_debug (char *str) +{ + debug =simple_strtol (str,NULL ,0 ); +return 1 ; +} +__setup ("root_plug_debug=" , root_plug_debug); -#if defined(CONFIG_SECURITY_ROOTPLUG_MODULE ) -#define MY_NAME THIS_MODULE->name -#else #define MY_NAME "root_plug" -#endif #define root_dbg(fmt, arg...) \ do { \@@ -117,25 +125,4 @@ static int __init rootplug_init (void)return 0 ; } -static void __exit rootplug_exit (void) -{ -/* remove ourselves from the security framework */ -if (secondary) { -if (mod_unreg_security (MY_NAME , &rootplug_security_ops)) -printk (KERN_INFO "Failure unregistering Root Plug " -" module with primary module.\n" ); - }else { -if (unregister_security (&rootplug_security_ops)) { -printk (KERN_INFO "Failure unregistering Root Plug " -"module with the kernel\n" ); - } - } -printk (KERN_INFO "Root Plug module removed\n" ); -} -security_initcall (rootplug_init); -module_exit (rootplug_exit); - -MODULE_DESCRIPTION ("Root Plug sample LSM module, written for Linux Journal article" ); -MODULE_LICENSE ("GPL" ); -security/security.c +2
-7@@ -17,7 +17,6 @@#include <linux/kernel.h> #include <linux/security.h> -#define SECURITY_FRAMEWORK_VERSION "1.0.0"/* things that live in dummy.c */ extern struct security_operations dummy_security_ops;@@ -51,8 +50,7 @@ static void __init do_security_initcalls(void)*/ int __init security_init (void ) { -printk (KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION -" initialized\n" ); +printk (KERN_INFO "Security Framework initialized\n" );if (verify (&dummy_security_ops)) { printk(KERN_ERR "%s could not verify "@@ -172,8 +170,5 @@ int mod_unreg_security(const char *name, struct security_operations *ops)return security_ops->unregister_security (name, ops); } -EXPORT_SYMBOL_GPL (register_security); -EXPORT_SYMBOL_GPL (unregister_security); -EXPORT_SYMBOL_GPL (mod_reg_security); -EXPORT_SYMBOL_GPL (mod_unreg_security); +/* Export required for modular use of security.h inlines */ EXPORT_SYMBOL (security_ops);security/selinux/hooks.c +0
-1@@ -20,7 +20,6 @@* as published by the Free Software Foundation. */ -#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/ptrace.h> security/selinux/xfrm.c +0
-1@@ -31,7 +31,6 @@* 2. Emulating a reasonable SO_PEERSEC across machines * 3. Testing addition of sk_policy's with security context via setsockopt */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/security.h> Signature · 6 lines
1.5.2.1 - To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 4 lines · * Serge E. Hallyn ([email protected]) wrote:
Sigh, as much as I would *like* to stay out of this (I don't use modules at all on any system where I can avoid it), won't it make development - and especially testing - of new lsms much more painful and therefore less likely?
Dev, hopefully not. Testing, well, perhaps.
Quoted 6 lines
I realize there has been a dearth of new LSMs to date, but if for instance a new solaris 10 based capability module were written, well, people would want to be able to
rmmod capability
modprobecap_prm
The problem is it's not necessarily even safe to do rmmod at all. And modprobe may require extra labelling, or extra checks for unlabelled objects (perhaps not so much for your example).
thanks,
-chris
Serge E. Hallyn
maintainerRe: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 12 lines · Chris Wright
Quoted 4 lines · * Serge E. Hallyn ([email protected]) wrote:
Sigh, as much as I would *like* to stay out of this (I don't use modules at all on any system where I can avoid it), won't it make development - and especially testing - of new lsms much more painful and therefore less likely?
Dev, hopefully not. Testing, well, perhaps.
Quoted 4 lines
I realize there has been a dearth of new LSMs to date, but if for instance a new solaris 10 based capability module were written, well, people would want to be able to
Quoted 6 lines
Quoted 2 lines
rmmod capability
modprobecap_prmThe problem is it's not necessarily even safe to do rmmod at all. And modprobe may require extra labelling, or extra checks for unlabelled objects (perhaps not so much for your example).
Right, and given that it's trivial for the author of an LSM which shouldn't be modular to make the LSM a boolean config rather than tristate, it doesn't seem like a good reason to take away the ability to have LSM modules.
-serge
Re: [PATCH][RFC] security: Convert LSM into a static interface
In reply to Serge E. HallynQuoted 11 lines · --- "Serge E. Hallyn
Quoted 10 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Module parameters for the capability and
root_plugmodules have been converted to kernel parameters.
Quoted 6 lines
Quoted 1 line
The
SECURITY_FRAMEWORK_VERSIONmacro has also been removed.Sigh, as much as I would *like* to stay out of this (I don't use modules at all on any system where I can avoid it), won't it make development - and especially testing - of new lsms much more painful and therefore less likely?
While there's lots of pain involved in developing an LSM modern development environments (e.g. virtual machines) have reduced the value of loadable modules for debug purposes.
Quoted 1 line
I realize there has been a dearth of new LSMs to date,
but so much excitment over those proposed!
Quoted 6 lines
but if
for instance a new solaris 10 based capability module were written, well, people would want to be able tormmod capability
modprobecap_prm
I think the value is overrated. You would never want to do that in a production environment, and in a debug environment you could just as easily reboot and get some start-up testing out of the way.
Casey Schaufler
[email protected]
James Morris
maintainerRe: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 3 lines · Casey Schaufler
While there's lots of pain involved in developing an LSM modern development environments (e.g. virtual machines) have reduced the value of loadable modules for debug purposes.
lguest is pretty good for this. You can boot a kernel in approximately the same time as loading a module.
Signature · 2 lines
James Morris <[email protected]>
Serge E. Hallyn
maintainerRe: [PATCH][RFC] security: Convert LSM into a static interface
In reply to Casey SchauflerQuoted 33 lines · Casey Schaufler
Quoted 11 lines · --- "Serge E. Hallyn
Quoted 10 lines · James Morris
Convert LSM into a static interface, as the ability to unload a security module is not required by in-tree users and potentially complicates the overall security architecture.
Needlessly exported LSM symbols have been unexported, to help reduce API abuse.
Module parameters for the capability and
root_plugmodules have been converted to kernel parameters.Quoted 6 lines
Quoted 1 line
The
SECURITY_FRAMEWORK_VERSIONmacro has also been removed.Sigh, as much as I would *like* to stay out of this (I don't use modules at all on any system where I can avoid it), won't it make development - and especially testing - of new lsms much more painful and therefore less likely?
While there's lots of pain involved in developing an LSM modern development environments (e.g. virtual machines) have reduced the value of loadable modules for debug purposes.
Quoted 1 line
I realize there has been a dearth of new LSMs to date,
but so much excitment over those proposed!
Quoted 4 lines
but if
for instance a new solaris 10 based capability module were written, well, people would want to be able to
Quoted 6 lines
Quoted 2 lines
rmmod capability
modprobecap_prmI think the value is overrated. You would never want to do that in a production environment, and in a debug environment you could just as easily reboot and get some start-up testing out of the way.
And in a development environment you can just as easily select CONFIG_XYZ=y, no?
So we have two options, one which provides greater choice and flexibility.
-serge
Re: [PATCH][RFC] security: Convert LSM into a static interface
Quoted 9 lines · --- "Serge E. Hallyn
Quoted 3 lines
I think the value is overrated. You would never want to do that in a production environment, and in a debug environment you could just as easily reboot and get some start-up testing out of the way.
And in a development environment you can just as easily select
CONFIG_XYZ=y, no?So we have two options, one which provides greater choice and flexibility.
I have no problem with leaving things the way they are today, and none with the proposed change. Either way works for me. It would be a little bit better for me if it stayed as is, but that's not a coding issue.
Casey Schaufler
[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · Serge E. Hallyn
Quoted 10 lines
I don't particularly mind, but can you point out any case where it is an advantage to have the one bit for f'E rather than just drop f'E altogether? Instead of having
f'I=something f'P=something f'E=offwe can always just remove the security.capability xattr. Right?
No. Bear in mind that capabilities are all about trusting specific applications with privilege as opposed to trusting the superuser to not run dangerous applications.
There are three situations, we'll take them in turn:
- no capabilities (fP=fI=fE=0): this is for applications that are not
intended to operate with privilege. Because of the way the capability convolution rules work, such a program can't execute with privilege. Period.
- with capabilities (fP and/or fI != 0), but fE=0 (off): this is for
applications that are intended to operate with privilege, but they were designed to know about capabilities and they manipulate (raise and lower) capabilities as needed to do the things they do.
- with capabilities, but fE=1 (on): this is a class of applications
loosely called 'legacy'. They can use privilege to operate, but don't strictly need to know about it. For example, /bin/chown . Such a program will have fP=0,fI=CAP_CHOWN. Since the administrator sets fP=0,fI=CAP_CHOWN,fE=1 on the /bin/chown file, any process with CAP_CHOWN in its inheritable set (pI) can "exec /bin/chown" and have it do the thing historically reserved for the superuser...
In some future world, the legacy fE bit may become unnecessary because every application will be rewritten to be careful about exercising privilege explicitly. In the meantime, the fE bit can be used to drop the setuid-0 bits from things like ping and traceroute.
Quoted 2 lines
Quoted 2 lines
If there's a case where that does not suffice, then I have no objection to doing it this way.
Does that explain it?
Quoted 7 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.Quoted 3 lines
The functionality is special, but someone with
CAP_SYS_ADMINcan always unload the capability module and create the security.capability xattr using the dummy module.
This argument leads down a rat hole. (As appears to have happened with the non-modularization LSM thread elsewhere...)
The simple fact is that CAP_SYS_ADMIN is equivalent to every other capability in the system if it can be used to load any flavor of kernel module. Arguing that you don't need a capability for something because you can do it with CAP_SYS_ADMIN is very close to admitting that you prefer the superuser (uid=0) model.
Quoted 2 lines
Quoted 2 lines
If we do add this cap, do we want to make it apply to all security.* xattrs?
I recommend limiting it to just capabilities.
For now, you can leave the other security attributes with the CAP_SYS_ADMIN ("misc") capability. In the original 'POSIX' drafts, there is a separate notion of advisory and mandatory access control; leveraging different capabilities to override.
Quoted 7 lines
3) The
cap_from_disk()interface checking needs some work.... Most notably, size must be greater than sizeof(u32) or the very first line will do something nasty... I'd recommend you use code like this:[...]
cap_from_disk(...){ if (size != sizeof(struct vfs_cap_data)) {
[...]
Quoted 6 lines
mistake at least once... The future is uncertain, so don't trust it will look the way you want it to. ;-)
Quoted 3 lines
Ok, so you're saying that when we do switch to 64-bit caps or some other evolution, we switch to completely separate logic based on the
VFS_CAP_REVISION?
Yes.
Quoted 1 line
Quoted 1 line
That seems sane to me.
You might also want to verify that unallocated bits hold the value 'zero'. Its funny what people do when they realize they can silently store bits in obscure places like this. That really messes up allocating bits in the future. Add a check that is something like:
if (version & ~(VFS_CAP_REVISION_MASK|VFS_CAP_FLAGS_EFFECTIVE)) {
return -EINVAL;
}Quoted 11 lines
7) This one is subtle, and to my mind not well appreciated. In
cap_bprm_apply_creds(), the wart of the global 'cap_bset' masking permitted bits can lead to problems like the one we saw a few years back with sendmail and capabilities. There is an assumption in setting permitted (they are called 'forced' in some documents) capabilities on a file that the file will execute with at least these. The inheritable ones are optional.Quoted 3 lines
Hmm, changing the behavior of the
cap_bsetis something that seems to belong in 8), though I see what you're saying, it does affect the behavior of vfs caps.
I'm not really changing the behavior of cap_bset. I'm specifying the behavior of fP. ;-)
[Your comments on cap_bset and CAP_SETPCAP are exactly where my ax^H^H^Hscalpel will fall after all this VFS support is stable. But *that* is a subject for a different thread... aka item 8.]
Quoted 3 lines
Quoted 3 lines
So yeah, I think you're right - but the question is whose word do we take here? The admin who set the vfs caps on the binary, or the admin who set
cap_bsetthrough sysctl?
The former.
Cheers
Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGge7WQheEq9QabfIRAo5oAJwLmR40gW/McHxGTFukm/PCRyLvegCgglpD tf7NgFcQvFNnMVDhNfslBGY=
=2tDD
-----END PGP SIGNATURE-----
Quoted 19 lines · Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 10 lines · Serge E. Hallyn
Quoted 10 lines
I don't particularly mind, but can you point out any case where it is an advantage to have the one bit for f'E rather than just drop f'E altogether? Instead of having
f'I=something f'P=something f'E=offwe can always just remove the security.capability xattr. Right?
No. Bear in mind that capabilities are all about trusting specific applications with privilege as opposed to trusting the superuser to not run dangerous applications.
Quoted 5 lines
There are three situations, we'll take them in turn:
- no capabilities (fP=fI=fE=0): this is for applications that are not
intended to operate with privilege. Because of the way the capability convolution rules work, such a program can't execute with privilege. Period.
(Except that in Linux, with SECURE_NOROOT=0, root will be able to. With SECURE_NOROOT=y it won't.)
Quoted 18 lines
- with capabilities (fP and/or fI != 0), but fE=0 (off): this is for
applications that are intended to operate with privilege, but they were designed to know about capabilities and they manipulate (raise and lower) capabilities as needed to do the things they do.- with capabilities, but fE=1 (on): this is a class of applications
loosely called 'legacy'. They can use privilege to operate, but don't strictly need to know about it. For example,/bin/chown. Such a program will have fP=0,fI=CAP_CHOWN. Since the administrator sets fP=0,fI=CAP_CHOWN,fE=1 on the/bin/chownfile, any process withCAP_CHOWNin its inheritable set (pI) can "exec/bin/chown" and have it do the thing historically reserved for the superuser...In some future world, the legacy fE bit may become unnecessary because every application will be rewritten to be careful about exercising privilege explicitly. In the meantime, the fE bit can be used to drop the setuid-0 bits from things like ping and traceroute.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
If there's a case where that does not suffice, then I have no objection to doing it this way.
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
Quoted 8 lines
Quoted 7 lines
2) Allocate capability bit-31 for
CAP_SETFCAP, and use it to gate whether the user can set this xattr on a file or not.CAP_SYS_ADMINis way too overloaded and this functionality is special.Quoted 3 lines
The functionality is special, but someone with
CAP_SYS_ADMINcan always unload the capability module and create the security.capability xattr using the dummy module.
Quoted 8 lines
This argument leads down a rat hole. (As appears to have happened with the non-modularization LSM thread elsewhere...)
The simple fact is that
CAP_SYS_ADMINis equivalent to every other capability in the system if it can be used to load any flavor of kernel module. Arguing that you don't need a capability for something because you can do it withCAP_SYS_ADMINis very close to admitting that you prefer the superuser (uid=0) model.
Well no, it could also just be acknowledging that at some point some better cap breakup should be attempted, though of course some amount of "these caps can subvert that cap" will always be there.
But I'm not actually objecting :) I expect this will be the first of the patches I whip up.
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
If we do add this cap, do we want to make it apply to all security.* xattrs?
I recommend limiting it to just capabilities.
For now, you can leave the other security attributes with the
CAP_SYS_ADMIN("misc") capability. In the original 'POSIX' drafts, there is a separate notion of advisory and mandatory access control; leveraging different capabilities to override.Quoted 7 lines
3) The
cap_from_disk()interface checking needs some work.... Most notably, size must be greater than sizeof(u32) or the very first line will do something nasty... I'd recommend you use code like this:[...]
cap_from_disk(...){ if (size != sizeof(struct vfs_cap_data)) {[...]
Quoted 6 lines
mistake at least once... The future is uncertain, so don't trust it will look the way you want it to. ;-)
Quoted 3 lines
Ok, so you're saying that when we do switch to 64-bit caps or some other evolution, we switch to completely separate logic based on the
VFS_CAP_REVISION?Yes.
Quoted 1 line
Quoted 1 line
That seems sane to me.
Quoted 8 lines
You might also want to verify that unallocated bits hold the value 'zero'. Its funny what people do when they realize they can silently store bits in obscure places like this. That really messes up allocating bits in the future. Add a check that is something like:
if (version & ~(VFS_CAP_REVISION_MASK|VFS_CAP_FLAGS_EFFECTIVE)) { return -EINVAL; }
I used to do that (except with a stupid loop), but let's say you update your distro, but the updated kernel has a problem. So you boot into an older kernel. But the distro update added a new capability. Now nothing runs with privilege.
Or are you saying that we would name the xattrs 'security.capability.vN', and with each capability we add bump N, so that after we've added 5 capabilities, each binary carries with it 5 xattrs, security.capability.v1 through security.capability.v5?
Quoted 19 lines
Quoted 11 lines
7) This one is subtle, and to my mind not well appreciated. In
cap_bprm_apply_creds(), the wart of the global 'cap_bset' masking permitted bits can lead to problems like the one we saw a few years back with sendmail and capabilities. There is an assumption in setting permitted (they are called 'forced' in some documents) capabilities on a file that the file will execute with at least these. The inheritable ones are optional.Quoted 3 lines
Hmm, changing the behavior of the
cap_bsetis something that seems to belong in 8), though I see what you're saying, it does affect the behavior of vfs caps.I'm not really changing the behavior of
cap_bset. I'm specifying the behavior of fP. ;-)[Your comments on
cap_bsetandCAP_SETPCAPare exactly where my ax^H^H^Hscalpel will fall after all this VFS support is stable. But *that* is a subject for a different thread... aka item 8.]
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
So yeah, I think you're right - but the question is whose word do we take here? The admin who set the vfs caps on the binary, or the admin who set
cap_bsetthrough sysctl?The former.
Well how about I whip up the patch (when time permits) and see if anyone complains :)
thanks,
-serge
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 5 lines · Serge E. Hallyn
Quoted 1 line
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
[We touched on this a number of emails back.]
If an application is capability aware, it can manipulate its own capabilities and should have fE=0.
If an application is not capability aware, it needs to have *all* of its capabilities enabled at exec() time. Otherwise, it won't work.
The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
Cheers
Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGg1LqQheEq9QabfIRAo3BAKCO8QrfcKBNqhfnn2BHp8O/qDkgXgCgleEl xP7LZPU9Qn6AjqI3ZM3FZ+4=
=urmz
-----END PGP SIGNATURE-----
Quoted 15 lines · Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 5 lines · Serge E. Hallyn
Quoted 1 line
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
[We touched on this a number of emails back.]
If an application is capability aware, it can manipulate its own capabilities and should have fE=0.
Quoted 7 lines
If an application is not capability aware, it needs to have *all* of its capabilities enabled at
exec()time. Otherwise, it won't work.The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
Sure - because it doesn't hurt anything, someone just *might* find it useful one day, and mostly the three bitmaps just look a lot cleaner to me than hiding a bit inside the version field. There are a *few* people using this, and so a complete switch in format for no actual net gain seems wrong. If we want to fake fE to the user as being one bit we can do that through the setfcaps/getfcaps programs.
There also are prior examples of doing it this way (i.e. Olaf Dietsche's implementation)
OTOH I don't deny implementing it fully as you describe seems to make the intent of the code clearer to readers and maintainers.
I guess maybe I'll give it a go and see what turns out.
thanks,
-serge
Quoted 10 lines · --- Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 5 lines · Serge E. Hallyn
Quoted 1 line
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
Quoted 7 lines
[We touched on this a number of emails back.]
If an application is capability aware, it can manipulate its own capabilities and should have fE=0.
If an application is not capability aware, it needs to have *all* of its capabilities enabled at
exec()time. Otherwise, it won't work.
The intent of the fE vector in the POSIX draft is that those capabilities are set on exec (lower vectors permitting). There are cases where it does make sense to raise just some (e.g. ping).
Quoted 4 lines
The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
No, it's to allow you to grant a subset of the available capabilities to a program that is not aware of capabilities. You can give "date" the capability to reset the clock without giving it the capability to remove other people's files without changing the code or running it setuid.
Casey Schaufler
[email protected]
Quoted 30 lines · Casey Schaufler
Quoted 10 lines · --- Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 5 lines · Serge E. Hallyn
Quoted 1 line
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
Quoted 7 lines
[We touched on this a number of emails back.]
If an application is capability aware, it can manipulate its own capabilities and should have fE=0.
If an application is not capability aware, it needs to have *all* of its capabilities enabled at
exec()time. Otherwise, it won't work.The intent of the fE vector in the POSIX draft is that those capabilities are set on exec (lower vectors permitting). There are cases where it does make sense to raise just some (e.g. ping).
Quoted 4 lines
The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
Quoted 5 lines
No, it's to allow you to grant a subset of the available capabilities to a program that is not aware of capabilities. You can give "date" the capability to reset the clock without giving it the capability to remove other people's files without changing the code or running it setuid.
Would there be a difference between that and setting either fI or fP (depending on your intent) to those caps, and setting fE=1 in Andrew's scheme?
thanks,
-serge
Quoted 37 lines · --- "Serge E. Hallyn
Quoted 30 lines · Casey Schaufler
Quoted 10 lines · --- Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 5 lines · Serge E. Hallyn
Quoted 1 line
Does that explain it?
Yes, thanks, but then it still could come in handy to have fE be a full bitset, so the application gets some eff caps automatically, while others it has to manually set...
Quoted 7 lines
[We touched on this a number of emails back.]
If an application is capability aware, it can manipulate its own capabilities and should have fE=0.
If an application is not capability aware, it needs to have *all* of its capabilities enabled at
exec()time. Otherwise, it won't work.The intent of the fE vector in the POSIX draft is that those capabilities are set on exec (lower vectors permitting). There are cases where it does make sense to raise just some (e.g. ping).
Quoted 4 lines
The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
Quoted 5 lines
No, it's to allow you to grant a subset of the available capabilities to a program that is not aware of capabilities. You can give "date" the capability to reset the clock without giving it the capability to remove other people's files without changing the code or running it setuid.
Quoted 3 lines
Would there be a difference between that and setting either fI or fP (depending on your intent) to those caps, and setting fE=1 in Andrew's scheme?
Arg, you're making me think. The POSIX group went through this, let me see if I can reconstruct the logic.
The main issue is one if there being a possible case where you have a capability ignorant program that you want to exec with a different fP and fE. On first glance it seems that since the program is capability ignorant it can't matter. But what if your capability ignorant program exec's a capability aware program to perform a helper function? You may well want the first program to have a capability that it does not use in fP (but not fE) to pass along to the helper program. True, you could probably come up with a way to set the capabilities on the helper program to account for this use, but there may be design and security constraints that make doing so complicated.
Casey Schaufler
[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Casey Schaufler
Quoted 3 lines
Would there be a difference between that and setting either fI or fP (depending on your intent) to those caps, and setting fE=1 in Andrew's scheme?
Arg, you're making me think. The POSIX group went through this, let me see if I can reconstruct the logic.
Quoted 8 lines
The main issue is one if there being a possible case where you have a capability ignorant program that you want to exec with a different fP and fE. On first glance it seems that since the program is capability ignorant it can't matter. But what if your capability ignorant program exec's a capability aware program to perform a helper function? You may well want the first program to have a capability that it does not use in fP (but not fE) to pass along to the helper program. True, you could probably
I'm not sure I've quite flogged this horse to death yet.. :-)
In my other reply, I quoted the rules. Here they are again:
pI' = pI
pP' = (X & fP) | (pI & fI)
pE' = pP' & fEIf program A exec()utes helper program B, then the only capabilities (p*') that B can get from A are a subset of A's pI set.
If A doesn't know about capabilities, then nothing about the fE value associated with the A program file can alter A's pI set and thus affect B. That is, nothing about the fE or fP value used to exec()ute A gets propagated through a subsequent exec() to B.
So far as I can see, to achieve the helper program support you are describing, the value of pI that program A (and thus program B) inherits will have to contain the relevant capabilities, and B will have to have a sufficient fI value to pick them up...
Incidentally, this is also where my request that we require (pP' >= fP) be true comes in. If a helper program (which may also be a legacy program) is used in a way that it is configured (via fP) to have powers that are denied to it (via X=cap_bset etc.,) then it should simply not be permitted to run (-EPERM). It should not have the opportunity to silently confuse itself (as was the case with sendmail when we tried to emulate setuid-0 behavior with capabilities a few years back).
Quoted 3 lines
come up with a way to set the capabilities on the helper program to account for this use, but there may be design and security constraints that make doing so complicated.
I've not seen anything yet to make be believe there is a case for a non-single bit fE value... Its a little ironic that I read all of the rationale I've been espousing in POSIX drafts - so far as I'm aware the only detail I'm mixing in there is the (pP' >= fP), -EPERM, thing.
If you or anyone can cite some counter examples, please do!
Cheers
Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFGhJjxQheEq9QabfIRAmyLAKCUxirmAuS4VM0U+9HloeOF6cKt2gCgi/fh ElhM1CISM4a+e0umBjK9GV0=
=Vrqj
-----END PGP SIGNATURE-----
Quoted 36 lines · Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 7 lines · Casey Schaufler
Quoted 3 lines
Would there be a difference between that and setting either fI or fP (depending on your intent) to those caps, and setting fE=1 in Andrew's scheme?
Arg, you're making me think. The POSIX group went through this, let me see if I can reconstruct the logic.
Quoted 8 lines
The main issue is one if there being a possible case where you have a capability ignorant program that you want to exec with a different fP and fE. On first glance it seems that since the program is capability ignorant it can't matter. But what if your capability ignorant program exec's a capability aware program to perform a helper function? You may well want the first program to have a capability that it does not use in fP (but not fE) to pass along to the helper program. True, you could probably
I'm not sure I've quite flogged this horse to death yet.. :-)
In my other reply, I quoted the rules. Here they are again:
pI' = pI pP' = (X & fP) | (pI & fI) pE' = pP' & fEIf program A exec()utes helper program B, then the only capabilities (p*') that B can get from A are a subset of A's pI set.
If A doesn't know about capabilities, then nothing about the fE value associated with the A program file can alter A's pI set and thus affect B. That is, nothing about the fE or fP value used to exec()ute A gets propagated through a subsequent
exec()to B.
Quoted 7 lines
So far as I can see, to achieve the helper program support you are describing, the value of pI that program A (and thus program B) inherits will have to contain the relevant capabilities, and B will have to have a sufficient fI value to pick them up...
Incidentally, this is also where my request that we require (pP' >= fP) be true comes in. If a helper program (which may also be a legacy
That was going to be my next thing to look at, btw.
Quoted 10 lines
program) is used in a way that it is configured (via fP) to have powers that are denied to it (via X=cap_bset etc.,) then it should simply not be permitted to run (
-EPERM). It should not have the opportunity to silently confuse itself (as was the case with sendmail when we tried to emulate setuid-0 behavior with capabilities a few years back).Quoted 3 lines
come up with a way to set the capabilities on the helper program to account for this use, but there may be design and security constraints that make doing so complicated.
Quoted 6 lines
I've not seen anything yet to make be believe there is a case for a non-single bit fE value... Its a little ironic that I read all of the rationale I've been espousing in POSIX drafts - so far as I'm aware the only detail I'm mixing in there is the (pP' >= fP),
-EPERM, thing.If you or anyone can cite some counter examples, please do!
Not really.
But, your argument is:
fE can only be used to create a different initial pE' than pP'.
If the binary doesn't know about capabilities, then you would never want to do that since it won't change it's pE', and therefore it's pP' is meaningless once pE' is set.
If the binary does know about capabilities, then it can change it's pE' within the bounds of it's pP' whenever it wants, so we may want to set pE' to 0 at start, but having pE' be just a subset of pP' has no advantage since the binary can set pE' to the subset when it wants.
Now, *my* argument :) is that:
While there is no particular advantage (that I can think of) to having the bitmap pE', there is also no disadvantage, and it produces kernel code closer to the actual equations usually seen.
In the course of this discussion, the two advantages I've seen which I'll concede to you are:
1. the resulting equations may be easier to read/understand, just bc it's one less bitmask operation whose purpose to try to understand. But I'm not certain.
2. Improper setting of fE *could* in theory cause another hard to diagnose sendmail-type vulnerability, by having fP set to the right value, but fE to the wrong value. Though that is stretching things a bit.
The change in xattr format offsets those, which is why I like the idea of just having the setfcaps program understand 'on=e' and 'off=e' (where on is of course just an alias for 'all'), but keeping the kernel code the same.
-serge
Quoted 53 lines · --- Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 7 lines · Casey Schaufler
Quoted 3 lines
Would there be a difference between that and setting either fI or fP (depending on your intent) to those caps, and setting fE=1 in Andrew's scheme?
Arg, you're making me think. The POSIX group went through this, let me see if I can reconstruct the logic.
Quoted 8 lines
The main issue is one if there being a possible case where you have a capability ignorant program that you want to exec with a different fP and fE. On first glance it seems that since the program is capability ignorant it can't matter. But what if your capability ignorant program exec's a capability aware program to perform a helper function? You may well want the first program to have a capability that it does not use in fP (but not fE) to pass along to the helper program. True, you could probably
I'm not sure I've quite flogged this horse to death yet.. :-)
In my other reply, I quoted the rules. Here they are again:
pI' = pI pP' = (X & fP) | (pI & fI) pE' = pP' & fEIf program A exec()utes helper program B, then the only capabilities (p*') that B can get from A are a subset of A's pI set.
If A doesn't know about capabilities, then nothing about the fE value associated with the A program file can alter A's pI set and thus affect B. That is, nothing about the fE or fP value used to exec()ute A gets propagated through a subsequent
exec()to B.So far as I can see, to achieve the helper program support you are describing, the value of pI that program A (and thus program B) inherits will have to contain the relevant capabilities, and B will have to have a sufficient fI value to pick them up...
Incidentally, this is also where my request that we require (pP' >= fP) be true comes in. If a helper program (which may also be a legacy program) is used in a way that it is configured (via fP) to have powers that are denied to it (via X=cap_bset etc.,) then it should simply not be permitted to run (
-EPERM). It should not have the opportunity to silently confuse itself (as was the case with sendmail when we tried to emulate setuid-0 behavior with capabilities a few years back).Quoted 3 lines
come up with a way to set the capabilities on the helper program to account for this use, but there may be design and security constraints that make doing so complicated.
Quoted 6 lines
I've not seen anything yet to make be believe there is a case for a non-single bit fE value... Its a little ironic that I read all of the rationale I've been espousing in POSIX drafts - so far as I'm aware the only detail I'm mixing in there is the (pP' >= fP),
-EPERM, thing.If you or anyone can cite some counter examples, please do!
Nope, I'm fresh out. If the reality is that you get no added value with a vector over a scalar I'm good with either scheme. Looks like you've done the dilegance. I see no flaws in your logic. I suppose I could argue for the vector in terms of compatability with Irix, but I'll leave that to those who might care.
Thank you for both the work and the clear explainations.
Casey Schaufler
[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · Casey Schaufler
Quoted 4 lines
The only reason for having an fE bitmap is to allow a capability-aware program (you really trust to do its privileged operations carefully) to be lazy and get some of its capabilities raised for free. Perhaps you can clarify why this is a desirable thing? :-)
No, it's to allow you to grant a subset of the available capabilities to a program that is not aware of capabilities. You can give "date" the capability to reset the clock without giving it the capability to remove other people's files without changing the code or running it setuid.
This is precisely what fE = 0 or ~0 provides.
Recall, an exec()'d program gets its p*' capabilities from a convolution of its exec()er's inheritable set (pI) *and* the file's capabilities (fI,fP,fE):
pI' = pI
pP' = (X & fP) | (pI & fI)
pE' = pP' & fE[Linux essentially has cap_bset for X.]
The fine-grain ability for ping to do its thing without becoming powerful enough to load a kernel module, for example, is facilitated by the "pP' &" part of the derivation of pE' (and not simply the unfiltered value of fE!).
As I said before, either the program knows how to raise and lower bits in its pE set, or it doesn't. In the former case, fE=0. In the latter case, fE=~0 will ensure that it gets all of the capabilities it is permitted to exercise at time of execution.
Could you cite some examples of where this position is unreasonable?
Thanks
Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGg9i1+bHCR3gb8jsRAvViAJ9T5x1fHrLGF4niRq7VhRqg4sej3wCgxkom oAFQEQwLkd/D6J5gi7Fb3Ww=
=+ZLb
-----END PGP SIGNATURE-----
Serge E. Hallyn
maintainerAll,
Regarding future/backward compatibility of file capabilities:
Quoted 1 line · Andrew Morgan
-----BEGIN PGP SIGNED MESSAGE-----
...
Quoted 13 lines
#define
VFS_CAP_REVISION_MASK0xFF000000
#defineVFS_CAP_REVISION0x01000000#define
VFS_CAP_FLAGS_MASK~VFS_CAP_REVISION_MASK
#defineVFS_CAP_FLAGS_EFFECTIVE0x000001struct vfs_cap_data { __u32 magic_etc; struct { __u32 permitted; /* Little endian */ __u32 inheritable; /* Little endian */ } data[1]; };
...
Quoted 26 lines
3) The
cap_from_disk()interface checking needs some work.... Most notably, size must be greater than sizeof(u32) or the very first line will do something nasty... I'd recommend you use code like this:[...]
cap_from_disk(...){ if (size != sizeof(struct vfs_cap_data)) { printk(KERN_WARNING "%s: invalid cap size %d for file %s\n", __FUNCTION__, size, bprm->filename); return -EINVAL; } switch ((version & VFS_CAP_REVISION_MASK)) { case VFS_CAP_REVISION: bprm->cap_effective = (version & VFS_CAP_FLAGS_EFFECTIVE) ? CAP_FULL_SET : CAP_EMPTY_SET; bprm->cap_permitted = to_cap_t( le32_to_cpu(dcap->data[0].permitted) ); bprm->cap_inheritable = to_cap_t( le32_to_cpu(dcap->data[0].inheritable) ); return 0; default: return -EINVAL; } }
Quoted 6 lines
Basically, I don't believe in designing a secure interface to be forward compatible - things never work out that way and the legacy you are implicitly committing to will haunt you in the future... FWIW I've known a few x86 MSR designers over the years and each one has made this mistake at least once... The future is uncertain, so don't trust it will look the way you want it to. ;-)
There are a few obvious approaches we can take:
1. Exactly Andrew describes. Once userspace switches to a new cap format, an older kernel simply won't support them
2. As Andrew describes, but also encode the version number into the capability name, i.e. security.capability.v3. Now userspace can optionally tack on more than one capability version to be backward compatible.
3. Somewhat different than Andrew describes. We mandate that any capability version N+1 consist of
struct vfs_cap_data {
__u32 magic;
capability_version_1;
capability_version_2;
...
capability_version_N;
capability_version_N+1;
};Or, for brevity,
struct vfs_cap_data {
__u32 first_magic;
__u32 last_magic;
capability_version_first;
...
capability_version_last;
};4. Stick to the current plan, where switching to 64-bit caps will be done as
struct vfs_cap_data_disk {
__le32 version;
__le32 data[]; /* eff[0], perm[0], inh[0], eff[1], ... */
};What would people prefer?
thanks,
-serge
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 2 lines · Serge E. Hallyn
1. Exactly Andrew describes. Once userspace switches to a new cap format, an older kernel simply won't support them
Mmm. Let me see. I think I prefer this one! :-)
Quoted 4 lines
2. As Andrew describes, but also encode the version number into the capability name, i.e. security.capability.v3. Now userspace can optionally tack on more than one capability version to be backward compatible.
If you have a significant legacy of use of earlier versions, I guess this makes sense. However, given the experimental nature of this support (it will be a while before the user space support for this is secure/robust), I'm not all that concerned about legacy support.
Quoted 11 lines
3. Somewhat different than Andrew describes. We mandate that any capability version N+1 consist of
struct vfs_cap_data { __u32 magic; capability_version_1; capability_version_2; ... capability_version_N; capability_version_N+1; };
Ugh. I don't like this. It presumes that the kernel will get more and more complicated over time. Please don't do this one.
Quoted 10 lines
Or, for brevity,
struct vfs_cap_data { __u32 first_magic; __u32 last_magic; capability_version_first; ... capability_version_last; };
Quoted 7 lines
4. Stick to the current plan, where switching to 64-bit caps will be done as
struct vfs_cap_data_disk { __le32 version; __le32 data[]; /* eff[0], perm[0], inh[0], eff[1], ... */ };
While asserting that it is more flexible etc., no one has yet actually given an example of where fE being richer than a simple binary helps anything. Until I see an example, I'm going to hold the position that this is needless "complexity".
Cheers
Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGjBFXmwytjiwfWMwRAofJAKCXX2GkN39o45fCQmxpNpZIEVH8EgCeLaDy AoWZNj/1MqT7oayabxUhIn8=
=OSBu
-----END PGP SIGNATURE-----
Quoted 4 lines · --- Andrew Morgan
no one has yet actually
given an example of where fE being richer than a simple binary helps anything. Until I see an example, I'm going to hold the position that this is needless "complexity".
The only counter to this argument is that you now have a different structure on files than on processes. Not a major issue, but one structure to describe capability sets is less complex than two. That way you can have one function to print a capset, regardless of its coming off a file or a process.
Just a thought.
Casey Schaufler
[email protected]