Skip to content

Commit 1f29fae

Browse files
Serge E. Hallynxjamesmorris
authored andcommitted
file capabilities: add no_file_caps switch (v4)
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: Nov 05 2008: (v4) trivial port on top of always-start-\ with-clear-caps patch 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. Signed-off-by: Serge Hallyn <serue@us.ibm.com> Acked-by: Andrew G. Morgan <morgan@kernel.org> Signed-off-by: James Morris <jmorris@namei.org>
1 parent e21e696 commit 1f29fae

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,10 @@ and is between 256 and 4096 characters. It is defined in the file
14591459
instruction doesn't work correctly and not to
14601460
use it.
14611461

1462+
no_file_caps Tells the kernel not to honor file capabilities. The
1463+
only way then for a file to be executed with privilege
1464+
is to be setuid root or executed by root.
1465+
14621466
nohalt [IA-64] Tells the kernel not to use the power saving
14631467
function PAL_HALT_LIGHT when idle. This increases
14641468
power-consumption. On the positive side, it reduces

‎include/linux/capability.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ typedef struct __user_cap_data_struct {
6868
#define VFS_CAP_U32 VFS_CAP_U32_2
6969
#define VFS_CAP_REVISION VFS_CAP_REVISION_2
7070

71+
#ifdef CONFIG_SECURITY_FILE_CAPABILITIES
72+
extern int file_caps_enabled;
73+
#endif
7174

7275
struct vfs_cap_data {
7376
__le32 magic_etc; /* Little endian */

‎kernel/capability.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ EXPORT_SYMBOL(__cap_empty_set);
3333
EXPORT_SYMBOL(__cap_full_set);
3434
EXPORT_SYMBOL(__cap_init_eff_set);
3535

36+
#ifdef CONFIG_SECURITY_FILE_CAPABILITIES
37+
int file_caps_enabled = 1;
38+
39+
static int __init file_caps_disable(char *str)
40+
{
41+
file_caps_enabled = 0;
42+
return 1;
43+
}
44+
__setup("no_file_caps", file_caps_disable);
45+
#endif
46+
3647
/*
3748
* More recent versions of libcap are available from:
3849
*

‎security/commoncap.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ static int get_file_caps(struct linux_binprm *bprm)
281281

282282
bprm_clear_caps(bprm);
283283

284+
if (!file_caps_enabled)
285+
return 0;
286+
284287
if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)
285288
return 0;
286289

0 commit comments

Comments
 (0)