linux-stable/fs/nfsd
Sachin S. Prabhu 0953e620de Inconsistent setattr behaviour
There is an inconsistency seen in the behaviour of nfs compared to other local
filesystems on linux when changing owner or group of a directory. If the
directory has SUID/SGID flags set, on changing owner or group on the directory,
the flags are stripped off on nfs. These flags are maintained on other
filesystems such as ext3.

To reproduce on a nfs share or local filesystem, run the following commands
mkdir test; chmod +s+g test; chown user1 test; ls -ld test

On the nfs share, the flags are stripped and the output seen is
drwxr-xr-x 2 user1 root 4096 Feb 23  2009 test

On other local filesystems(ex: ext3), the flags are not stripped and the output
seen is
drwsr-sr-x 2 user1 root 4096 Feb 23 13:57 test

chown_common() called from sys_chown() will only strip the flags if the inode is
not a directory.
static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
{
..
        if (!S_ISDIR(inode->i_mode))
                newattrs.ia_valid |=
                        ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
..
}

See: http://www.opengroup.org/onlinepubs/7990989775/xsh/chown.html

"If the path argument refers to a regular file, the set-user-ID (S_ISUID) and
set-group-ID (S_ISGID) bits of the file mode are cleared upon successful return
from chown(), unless the call is made by a process with appropriate privileges,
in which case it is implementation-dependent whether these bits are altered. If
chown() is successfully invoked on a file that is not a regular file, these
bits may be cleared. These bits are defined in <sys/stat.h>."

The behaviour as it stands does not appear to violate POSIX.  However the
actions performed are inconsistent when comparing ext3 and nfs.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2009-03-18 17:59:37 -04:00
..
auth.c nfsd: fix cred leak on every rpc 2009-01-27 17:26:59 -05:00
auth.h nfsd: minor fs/nfsd/auth.h cleanup 2008-02-01 16:42:05 -05:00
export.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 2008-10-23 10:22:40 -07:00
Kconfig nfsd : Define NFSD only when FILE_LOCKING is enabled 2009-03-18 17:30:48 -04:00
lockd.c nfsd: common grace period control 2008-10-03 16:19:02 -04:00
Makefile knfsd: trivial makefile cleanup 2007-05-09 12:30:54 -07:00
nfs2acl.c nfsd: rename MAY_ flags 2008-06-23 13:02:50 -04:00
nfs3acl.c nfsd: rename MAY_ flags 2008-06-23 13:02:50 -04:00
nfs3proc.c Short write in nfsd becomes a full write to the client 2009-03-18 17:38:40 -04:00
nfs3xdr.c Use struct path in struct svc_export 2008-02-14 21:17:08 -08:00
nfs4acl.c nfsd: fix buffer overrun decoding NFSv4 acl 2008-09-01 14:24:24 -04:00
nfs4callback.c nfsd4: move rpc_client setup to a separate function 2009-03-18 17:38:39 -04:00
nfs4idmap.c nfsd: fix sparse warnings 2008-04-23 16:13:39 -04:00
nfs4proc.c nfsd4: remove redundant check from nfsd4_open 2009-03-18 17:38:41 -04:00
nfs4recover.c nfsd4: don't do lookup within readdir in recovery code 2009-03-18 17:38:40 -04:00
nfs4state.c nfsd4: don't check ip address in setclientid 2009-03-18 17:38:42 -04:00
nfs4xdr.c nfsd4: support putpubfh operation 2009-03-18 17:38:40 -04:00
nfscache.c nfsd: fail module init on reply cache init failure 2008-02-01 16:42:04 -05:00
nfsctl.c knfsd: add file to export stats about nfsd pools 2009-03-18 17:38:42 -04:00
nfsfh.c NFSD: FIDs need to take precedence over UUIDs 2009-01-07 17:23:07 -05:00
nfsproc.c Short write in nfsd becomes a full write to the client 2009-03-18 17:38:40 -04:00
nfssvc.c knfsd: add file to export stats about nfsd pools 2009-03-18 17:38:42 -04:00
nfsxdr.c Use struct path in struct svc_export 2008-02-14 21:17:08 -08:00
stats.c [PATCH] knfsd: nfsd4: add per-operation server stats 2006-07-10 13:24:27 -07:00
vfs.c Inconsistent setattr behaviour 2009-03-18 17:59:37 -04:00