Skip to content

Commit

Permalink
capabilities: add a securebit to disable PR_CAP_AMBIENT_RAISE
Browse files Browse the repository at this point in the history
Per Andrew Morgan's request, add a securebit to allow admins to disable
PR_CAP_AMBIENT_RAISE.  This securebit will prevent processes from adding
capabilities to their ambient set.

For simplicity, this disables PR_CAP_AMBIENT_RAISE entirely rather than
just disabling setting previously cleared bits.

Signed-off-by: Andy Lutomirski <[email protected]>
Acked-by: Andrew G. Morgan <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Serge Hallyn <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Aaron Jones <[email protected]>
Cc: Ted Ts'o <[email protected]>
Cc: Andrew G. Morgan <[email protected]>
Cc: Mimi Zohar <[email protected]>
Cc: Austin S Hemmelgarn <[email protected]>
Cc: Markku Savela <[email protected]>
Cc: Jarkko Sakkinen <[email protected]>
Cc: Michael Kerrisk <[email protected]>
Cc: James Morris <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
amluto authored and torvalds committed Sep 4, 2015
1 parent 32ae976 commit 746bf6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion include/uapi/linux/securebits.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@
#define SECBIT_KEEP_CAPS (issecure_mask(SECURE_KEEP_CAPS))
#define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED))

/* When set, a process cannot add new capabilities to its ambient set. */
#define SECURE_NO_CAP_AMBIENT_RAISE 6
#define SECURE_NO_CAP_AMBIENT_RAISE_LOCKED 7 /* make bit-6 immutable */

#define SECBIT_NO_CAP_AMBIENT_RAISE (issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
#define SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED \
(issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED))

#define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \
issecure_mask(SECURE_NO_SETUID_FIXUP) | \
issecure_mask(SECURE_KEEP_CAPS))
issecure_mask(SECURE_KEEP_CAPS) | \
issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
#define SECURE_ALL_LOCKS (SECURE_ALL_BITS << 1)

#endif /* _UAPI_LINUX_SECUREBITS_H */
3 changes: 2 additions & 1 deletion security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,8 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
if (arg2 == PR_CAP_AMBIENT_RAISE &&
(!cap_raised(current_cred()->cap_permitted, arg3) ||
!cap_raised(current_cred()->cap_inheritable,
arg3)))
arg3) ||
issecure(SECURE_NO_CAP_AMBIENT_RAISE)))
return -EPERM;

new = prepare_creds();
Expand Down

0 comments on commit 746bf6d

Please sign in to comment.