patch-1.3.85 linux/fs/exec.c

Next file: linux/fs/fcntl.c
Previous file: linux/fs/buffer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.84/linux/fs/exec.c linux/fs/exec.c
@@ -465,7 +465,13 @@
 		bprm->e_gid = current->egid;
 	} else {
 		bprm->e_uid = (i & S_ISUID) ? bprm->inode->i_uid : current->euid;
-		bprm->e_gid = (i & S_ISGID) ? bprm->inode->i_gid : current->egid;
+		/*
+		 * If setgid is set but no group execute bit then this
+		 * is a candidate for mandatory locking, not a setgid
+		 * executable.
+		 */
+		bprm->e_gid = ((i & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) ?
+			bprm->inode->i_gid : current->egid;
 	}
 	if ((retval = permission(bprm->inode, MAY_EXEC)) != 0)
 		return retval;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this