]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
file caps: always start with clear bprm->caps_*
authorSerge Hallyn <serue@us.ibm.com>
Thu, 30 Oct 2008 16:52:23 +0000 (11:52 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 10 Nov 2008 18:50:06 +0000 (10:50 -0800)
commit 3318a386e4ca68c76e0294363d29bdc46fcad670 upstream

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
security/commoncap.c

index 06d5c9469ba3bf260342c2cf80a3e256c6b16f18..37205a180d95490d2bb48f38ddd1161dbdc0a1e6 100644 (file)
@@ -244,10 +244,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;