kernels/linux-2.6.24/mm/filemap.c
/*
 * The logic we want is
 *
 *	if suid or (sgid and xgrp)
 *		remove privs
 */
The logic we want is
if suid or (sgid and xgrp)
remove privs
The logic we want is if suid or ( sgid and xgrp ) remove privs
int should_remove_suid(struct dentry *dentry)
{
	mode_t mode = dentry->d_inode->i_mode;
	int kill = 0;
	if (unlikely(mode & S_ISUID))
		kill = ATTR_KILL_SUID;
	if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
		kill |= ATTR_KILL_SGID;
	if (unlikely(kill && !capable(CAP_FSETID)))
		return kill;
	return 0;
}
int should_remove_suid ( struct dentry * dentry ) { mode_t mode = dentry -> d_inode -> i_mode ; int kill = 0 ; if ( unlikely ( mode & S_ISUID ) ) kill = ATTR_KILL_SUID ; if ( unlikely ( ( mode & S_ISGID ) && ( mode & S_IXGRP ) ) ) kill |= ATTR_KILL_SGID ; if ( unlikely ( kill && ! capable ( CAP_FSETID ) ) ) return kill ; return 0 ; }
The logic we want is
      if suid or (sgid and xgrp)
              remove privs
The logic we want is if suid or ( sgid and xgrp ) remove privs
/* suid always must be killed */ /*
	 * sgid without any exec bits is just a mandatory locking mark; leave
	 * it alone.  If some exec bits are set, it's a real sgid; kill it.
	 */