file capabilities: add no_file_caps switch (v3)
Subsystems (4)
PATCH 1/2 file capabilities: add no_file_caps switch (v3)
Add a no_file_caps boot option when file capabilities are compiled into the kernel (CONFIG_SECURITY_FILE_CAPABILITIES=y).
This allows distributions to ship a kernel with file capabilities compiled in, without forcing users to use (and understand and trust) them.
When no_file_caps is specified at boot, then when a process executes a file, any file capabilities stored with that file will not be used in the calculation of the process' new capability sets.
This means that booting with the no_file_caps boot option will not be the same as booting a kernel with file capabilities compiled out - in particular a task with CAP_SETPCAP will not have any chance of passing capabilities to another task (which isn't "really" possible anyway, and which may soon by killed altogether by David Howells in any case), and it will instead be able to put new capabilities in its pI. However since fI will always be empty and pI is masked with fI, it gains the task nothing.
We also support the extra prctl options, setting securebits and dropping capabilities from the per-process bounding set.
The other remaining difference is that killpriv, task_setscheduler, setioprio, and setnice will continue to be hooked. That will be noticable in the case where a root task changed its uid while keeping some caps, and another task owned by the new uid tries to change settings for the more privileged task.
Changelog:
Sep 23 2008: nixed file_caps_enabled when file caps are
not compiled in as it isn't used. Document no_file_caps in kernel-parameters.txt.
--- Documentation/kernel-parameters.txt | 4 ++++ include/linux/capability.h | 3 +++ kernel/capability.c | 11 +++++++++++ security/commoncap.c | 5 +++++ 4 files changed, 23 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +4 -0
@@ -1393,6 +1393,10 @@ and is between 256 and 4096 characters. It is defined in the file instruction doesn't work correctly and not to use it. + no_file_caps Tells the kernel not to honor file capabilities. The + only way then for a file to be executed with privilege + is to be setuid root or executed by root. + nohalt [IA-64] Tells the kernel not to use the power saving function PAL_HALT_LIGHT when idle. This increases power-consumption. On the positive side, it reduces
include/linux/capability.h +3 -0
@@ -68,6 +68,9 @@ typedef struct __user_cap_data_struct {#define VFS_CAP_U32 VFS_CAP_U32_2#define VFS_CAP_REVISION VFS_CAP_REVISION_2 +#ifdef CONFIG_SECURITY_FILE_CAPABILITIES +extern int file_caps_enabled; +#endif struct vfs_cap_data {__le32 magic_etc;/* Little endian */
kernel/capability.c +11 -0
@@ -33,6 +33,17 @@ EXPORT_SYMBOL(__cap_empty_set);EXPORT_SYMBOL (__cap_full_set);EXPORT_SYMBOL (__cap_init_eff_set); +#ifdef CONFIG_SECURITY_FILE_CAPABILITIES +int file_caps_enabled =1 ; + +static int __init file_caps_disable (char *str) +{ + file_caps_enabled =0 ; +return 1 ; +} +__setup ("no_file_caps" , file_caps_disable); +#endif +/* * More recent versions of libcap are available from: *
security/commoncap.c +5 -0
@@ -279,6 +279,11 @@ static int get_file_caps(struct linux_binprm *bprm)struct vfs_cap_data vcaps;struct inode *inode; +if (!file_caps_enabled) { +bprm_clear_caps (bprm); +return 0 ; + } +if (bprm->file->f_vfsmnt->mnt_flags &MNT_NOSUID ) {bprm_clear_caps (bprm);return 0 ;
Signature · 1 line
1.5.4.3
PATCH 2/2 file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
Remove the option to compile the kernel without file capabilities. Not compiling file capabilities actually makes the kernel less safe, as it includes the possibility for a task changing another task's capabilities.
Some are concerned that userspace tools (and user education) are not up to the task of properly configuring file capabilities on a system. For those cases, there is now the ability to boot with the no_file_caps boot option. This will prevent file capabilities from being used in the capabilities recalculation at exec, but will not change the rest of the kernel behavior which used to be switchable using the CONFIG_SECURITY_FILE_CAPABILITIES option.
--- fs/open.c | 8 -- include/linux/capability.h | 2 - include/linux/init_task.h | 4 - kernel/capability.c | 158 -------------------------------------------- security/Kconfig | 9 --- security/commoncap.c | 53 --------------- 6 files changed, 0 insertions(+), 234 deletions(-)
fs/open.c +0 -8
@@ -444,14 +444,6 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)/* * Clear the capabilities if we switch to a non-root user */ -#ifndef CONFIG_SECURITY_FILE_CAPABILITIES -/* -* FIXME: There is a race here against sys_capset. The -* capabilities can change yet we will restore the old -* value below. We should hold task_capabilities_lock, -* but we cannot because user_path_at can sleep. -*/ -#endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */ if (current->uid) old_cap =cap_set_effective (__cap_empty_set);else
include/linux/capability.h +0 -2
@@ -68,9 +68,7 @@ typedef struct __user_cap_data_struct {#define VFS_CAP_U32 VFS_CAP_U32_2#define VFS_CAP_REVISION VFS_CAP_REVISION_2 -#ifdef CONFIG_SECURITY_FILE_CAPABILITIES extern int file_caps_enabled; -#endif struct vfs_cap_data {__le32 magic_etc;/* Little endian */
include/linux/init_task.h +0 -4
@@ -102,16 +102,12 @@ extern struct group_info init_groups;#define INIT_IDS #endif -#ifdef CONFIG_SECURITY_FILE_CAPABILITIES /* * Because of the reduced scope of CAP_SETPCAP when filesystem * capabilities are in effect, it is safe to allow CAP_SETPCAP to * be available in the default configuration. */ # define CAP_INIT_BSET CAP_FULL_SET -#else -# define CAP_INIT_BSET CAP_INIT_EFF_SET -#endif /* * INIT_TASK is used to set up the first task table, touch at
kernel/capability.c +0 -158
182 lines not on this page · raw message
security/Kconfig +0 -9
@@ -73,15 +73,6 @@ config SECURITY_NETWORK_XFRM IPSec. If you are unsure how to answer this question, answer N. -config SECURITY_FILE_CAPABILITIES - bool "File POSIX Capabilities" - default n - help - This enables filesystem capabilities, allowing you to give - binaries a subset of root's powers without using setuid 0. - - If in doubt, answer N. - config SECURITY_ROOTPLUG bool "Root Plug Support" depends on USB=y && SECURITY
security/commoncap.c +0 -53
101 lines not on this page · raw message
Signature · 1 line
1.5.4.3
Re: [PATCH 2/2] file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Cheers
Andrew
Quoted 13 lines · Serge E. Hallyn
Remove the option to compile the kernel without file capabilities. Not compiling file capabilities actually makes the kernel less safe, as it includes the possibility for a task changing another task's capabilities.
Some are concerned that userspace tools (and user education) are not up to the task of properly configuring file capabilities on a system. For those cases, there is now the ability to boot with the
no_file_capsboot option. This will prevent file capabilities from being used in the capabilities recalculation at exec, but will not change the rest of the kernel behavior which used to be switchable using theCONFIG_SECURITY_FILE_CAPABILITIESoption.Signed-off-by Serge Hallyn <[email protected]>
Quoted 8 lines
--- fs/open.c | 8 -- include/linux/capability.h | 2 - include/linux/init_task.h | 4 - kernel/capability.c | 158 -------------------------------------------- security/Kconfig | 9 --- security/commoncap.c | 53 --------------- 6 files changed, 0 insertions(+), 234 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFI2ckn+bHCR3gb8jsRAh1QAJ9yEYEdnUgOn5w18u6DgXNKCnAbWACgnq8j 70Oa+pgYJpRVsIPMSJcUGhY=
=26lW
-----END PGP SIGNATURE-----
Re: [PATCH 2/2] file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
In reply to Serge E. HallynQuoted 11 lines · * Serge E. Hallyn ([email protected]) wrote:
Remove the option to compile the kernel without file capabilities. Not compiling file capabilities actually makes the kernel less safe, as it includes the possibility for a task changing another task's capabilities.
Some are concerned that userspace tools (and user education) are not up to the task of properly configuring file capabilities on a system. For those cases, there is now the ability to boot with the
no_file_capsboot option. This will prevent file capabilities from being used in the capabilities recalculation at exec, but will not change the rest of the kernel behavior which used to be switchable using theCONFIG_SECURITY_FILE_CAPABILITIESoption.
(note: defconfig has CONFIG_SECURITY_FILE_CAPABILITIES=y)
text data bss dec hex filename
6805157 1018344 671900 8495401 81a129 obj64-defconfig/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch1/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch2/vmlinux 6804605 1018344 671900 8494849 819f01 obj64-nofcap/vmlinux 6804604 1018344 671900 8494848 819f00 obj64-nofcap-patch1/vmlinux 6805150 1018368 671900 8495418 81a13a obj64-nofcap-patch2/vmlinux
The last 2 show the real diff now, add 570 bytes by effectively forcing CONFIG_SECURITY_FILE_CAPABILITIES on.
What is being done to enable userspace in distros to make those 570 bytes generally useful?
thanks,
-chris
Re: [PATCH 2/2] file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
Quoted 13 lines · Chris Wright
Quoted 11 lines · * Serge E. Hallyn ([email protected]) wrote:
Remove the option to compile the kernel without file capabilities. Not compiling file capabilities actually makes the kernel less safe, as it includes the possibility for a task changing another task's capabilities.
Some are concerned that userspace tools (and user education) are not up to the task of properly configuring file capabilities on a system. For those cases, there is now the ability to boot with the
no_file_capsboot option. This will prevent file capabilities from being used in the capabilities recalculation at exec, but will not change the rest of the kernel behavior which used to be switchable using theCONFIG_SECURITY_FILE_CAPABILITIESoption.
Quoted 8 lines
(note: defconfig has
CONFIG_SECURITY_FILE_CAPABILITIES=y)
text data bss dec hex filename6805157 1018344 671900 8495401 81a129 obj64-defconfig/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch1/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch2/vmlinux 6804605 1018344 671900 8494849 819f01 obj64-nofcap/vmlinux 6804604 1018344 671900 8494848 819f00 obj64-nofcap-patch1/vmlinux 6805150 1018368 671900 8495418 81a13a obj64-nofcap-patch2/vmlinux
(what are you using to get these numbers?)
Quoted 2 lines
The last 2 show the real diff now, add 570 bytes by effectively forcing
CONFIG_SECURITY_FILE_CAPABILITIESon.
That surprises me - I thought a reasonable amount of code was cut as well. Sounds like it may be worth it to refactor some of the code.
Quoted 2 lines
What is being done to enable userspace in distros to make those 570 bytes generally useful?
Fedora 9 and ubuntu intrepid already have full capabilities support and modern libcap. Sles is set to ship with a modern libcap, and according to what Andreas is saying, if we can provide them with the no_file_caps boot option then suse is willing to have a kernel with capabilities turned on. I think gentoo still comes with libcap-1. Need to look into changing that.
I suppose the next baby-step will be to do get rid of setuid on little things like ping. Actually using inheritable caps for pseudo-admin 'roles' may be a bit farther off, and a particularly interesting problem will be to take huge pieces of cross-os software like ssh which make assumptions about setuid behavior, and find ways to make them work correctly with capabilities, with capabilities in SECURE_NOROOT|SECURE_NOSETUIDFIXUP, and with non-linux oses.
-serge
Re: [PATCH 2/2] file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
Quoted 23 lines · * Serge E. Hallyn ([email protected]) wrote:
Quoted 13 lines · Chris Wright
Quoted 11 lines · * Serge E. Hallyn ([email protected]) wrote:
Remove the option to compile the kernel without file capabilities. Not compiling file capabilities actually makes the kernel less safe, as it includes the possibility for a task changing another task's capabilities.
Some are concerned that userspace tools (and user education) are not up to the task of properly configuring file capabilities on a system. For those cases, there is now the ability to boot with the
no_file_capsboot option. This will prevent file capabilities from being used in the capabilities recalculation at exec, but will not change the rest of the kernel behavior which used to be switchable using theCONFIG_SECURITY_FILE_CAPABILITIESoption.Quoted 8 lines
(note: defconfig has
CONFIG_SECURITY_FILE_CAPABILITIES=y)
text data bss dec hex filename6805157 1018344 671900 8495401 81a129 obj64-defconfig/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch1/vmlinux 6805151 1018368 671900 8495419 81a13b obj64-defconfig-patch2/vmlinux 6804605 1018344 671900 8494849 819f01 obj64-nofcap/vmlinux 6804604 1018344 671900 8494848 819f00 obj64-nofcap-patch1/vmlinux 6805150 1018368 671900 8495418 81a13a obj64-nofcap-patch2/vmlinux
Quoted 1 line
(what are you using to get these numbers?)
Just building w/ O=obj64... and then using "size obj64-*/vmlinux"
Quoted 5 lines
Quoted 2 lines
The last 2 show the real diff now, add 570 bytes by effectively forcing
CONFIG_SECURITY_FILE_CAPABILITIESon.That surprises me - I thought a reasonable amount of code was cut as well. Sounds like it may be worth it to refactor some of the code.
Be nice to cut it down if you can.
Quoted 10 lines
Quoted 2 lines
What is being done to enable userspace in distros to make those 570 bytes generally useful?
Fedora 9 and ubuntu intrepid already have full capabilities support and modern libcap. Sles is set to ship with a modern libcap, and according to what Andreas is saying, if we can provide them with the
no_file_capsboot option then suse is willing to have a kernel with capabilities turned on. I think gentoo still comes with libcap-1. Need to look into changing that.
Quoted 7 lines
I suppose the next baby-step will be to do get rid of setuid on little things like ping. Actually using inheritable caps for pseudo-admin 'roles' may be a bit farther off, and a particularly interesting problem will be to take huge pieces of cross-os software like ssh which make assumptions about setuid behavior, and find ways to make them work correctly with capabilities, with capabilities in SECURE_NOROOT|SECURE_NOSETUIDFIXUP, and with non-linux oses.
The baby step including simple things like setuid ping was the step I was thinking of. That w/ embedded and bloatwatch in mind is why I asked.
thanks,
-chris
Re: [PATCH 2/2] file capabilities: remove CONFIG_SECURITY_FILE_CAPABILITIES
In reply to Serge E. HallynQuoted 9 lines · On Thursday, 25 September 2008 3:02:33 Serge E. Hallyn wrote:
Quoted 2 lines · Chris Wright
What is being done to enable userspace in distros to make those 570 bytes generally useful?
Fedora 9 and ubuntu intrepid already have full capabilities support and modern libcap. Sles is set to ship with a modern libcap, and according to what Andreas is saying, if we can provide them with the
no_file_capsboot option then suse is willing to have a kernel with capabilities turned on.
Yes.
Quoted 5 lines
I think gentoo still comes with libcap-1. Need to look into changing that.
I suppose the next baby-step will be to do get rid of setuid on little things like ping.
Real file capability support in RPM seems important to me; hacking this into %post scripts is not a reasonable approach.
Thanks,
Andreas