path: root/fs/nfs/inode.c
diff options
authorJeff Layton <>2007-10-18 03:05:20 -0700
committerLinus Torvalds <>2007-10-18 14:37:22 -0700
commit6de0ec00ba8db84d7c452e65e502989455ecb6ea (patch)
tree804cf9f652e48aa30695124d6ab1915b0b8dd4d0 /fs/nfs/inode.c
parentcdd6fe6e2f7eb8e940854317613885c33b1fe584 (diff)
VFS: make notify_change pass ATTR_KILL_S*ID to setattr operations
When an unprivileged process attempts to modify a file that has the setuid or setgid bits set, the VFS will attempt to clear these bits. The VFS will set the ATTR_KILL_SUID or ATTR_KILL_SGID bits in the ia_valid mask, and then call notify_change to clear these bits and set the mode accordingly. With a networked filesystem (NFS and CIFS in particular but likely others), the client machine or process may not have credentials that allow for setting the mode. In some situations, this can lead to file corruption, an operation failing outright because the setattr fails, or to races that lead to a mode change being reverted. In this situation, we'd like to just leave the handling of this to the server and ignore these bits. The problem is that by the time the setattr op is called, the VFS has already reinterpreted the ATTR_KILL_* bits into a mode change. The setattr operation has no way to know its intent. The following patch fixes this by making notify_change no longer clear the ATTR_KILL_SUID and ATTR_KILL_SGID bits in the ia_valid before handing it off to the setattr inode op. setattr can then check for the presence of these bits, and if they're set it can assume that the mode change was only for the purposes of clearing these bits. This means that we now have an implicit assumption that notify_change is never called with ATTR_MODE and either ATTR_KILL_S*ID bit set. Nothing currently enforces that, so this patch also adds a BUG() if that occurs. Signed-off-by: Jeff Layton <> Cc: Michael Halcrow <> Cc: Christoph Hellwig <> Cc: Neil Brown <> Cc: "J. Bruce Fields" <> Cc: Chris Mason <> Cc: Jeff Mahoney <> Cc: "Vladimir V. Saveliev" <> Cc: Josef 'Jeff' Sipek <> Cc: Trond Myklebust <> Cc: Steven French <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'fs/nfs/inode.c')
0 files changed, 0 insertions, 0 deletions