Skip to content

Commit

Permalink
file caps: always start with clear bprm->caps_*
Browse files Browse the repository at this point in the history
While Linux doesn't honor setuid on scripts.  However, it mistakenly
behaves differently for file capabilities.

This patch fixes that behavior by making sure that get_file_caps()
begins with empty bprm->caps_*.  That way when a script is loaded,
its bprm->caps_* may be filled when binfmt_misc calls prepare_binprm(),
but they will be cleared again when binfmt_elf calls prepare_binprm()
next to read the interpreter's file capabilities.

Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Andrew G. Morgan <morgan@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Serge Hallyn authored and torvalds committed Nov 1, 2008
1 parent e06f42d commit 3318a38
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ static int get_file_caps(struct linux_binprm *bprm)
struct vfs_cap_data vcaps;
struct inode *inode;

if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) {
bprm_clear_caps(bprm);
bprm_clear_caps(bprm);

if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)
return 0;
}

dentry = dget(bprm->file->f_dentry);
inode = dentry->d_inode;
Expand Down

0 comments on commit 3318a38

Please sign in to comment.