Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3318a386 authored by Serge Hallyn's avatar Serge Hallyn Committed by Linus Torvalds
Browse files

file caps: always start with clear bprm->caps_*



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: default avatarSerge Hallyn <serue@us.ibm.com>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarAndrew G. Morgan <morgan@kernel.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e06f42d6
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -279,10 +279,10 @@ static int get_file_caps(struct linux_binprm *bprm)
	struct vfs_cap_data vcaps;
	struct vfs_cap_data vcaps;
	struct inode *inode;
	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;
		return 0;
	}


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