Skip to content

Commit

Permalink
Capabilities: BUG when an invalid capability is requested
Browse files Browse the repository at this point in the history
If an invalid (large) capability is requested the capabilities system
may panic as it is dereferencing an array of fixed (short) length.  Its
possible (and actually often happens) that the capability system
accidentally stumbled into a valid memory region but it also regularly
happens that it hits invalid memory and BUGs.  If such an operation does
get past cap_capable then the selinux system is sure to have problems as
it already does a (simple) validity check and BUG.  This is known to
happen by the broken and buggy firegl driver.

This patch cleanly checks all capable calls and BUG if a call is for an
invalid capability.  This will likely break the firegl driver for some
situations, but it is the right thing to do.  Garbage into a security
system gets you killed/bugged

Signed-off-by: Eric Paris <[email protected]>
Acked-by: Arjan van de Ven <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Acked-by: Andrew G. Morgan <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
eparis authored and James Morris committed Nov 11, 2008
1 parent e68b75a commit 637d32d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
*/
int capable(int cap)
{
if (unlikely(!cap_valid(cap))) {
printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
BUG();
}

if (has_capability(current, cap)) {
current->flags |= PF_SUPERPRIV;
return 1;
Expand Down

0 comments on commit 637d32d

Please sign in to comment.