fuse: fix killing s[ug]id in setattr
authorMiklos Szeredi <mszeredi@redhat.com>
Sat, 1 Oct 2016 05:32:32 +0000 (07:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Oct 2016 10:26:55 +0000 (12:26 +0200)
commit879d001c6d3b6bdd880b6c86acbb0d1ea8e2f548
tree0068a190d8ecd4b7f9f61d46a8c2c787dd74e884
parent97a2eba1ed753daaa53531e37385a60a88daefb9
fuse: fix killing s[ug]id in setattr

commit a09f99eddef44035ec764075a37bace8181bec38 upstream.

Fuse allowed VFS to set mode in setattr in order to clear suid/sgid on
chown and truncate, and (since writeback_cache) write.  The problem with
this is that it'll potentially restore a stale mode.

The poper fix would be to let the filesystems do the suid/sgid clearing on
the relevant operations.  Possibly some are already doing it but there's no
way we can detect this.

So fix this by refreshing and recalculating the mode.  Do this only if
ATTR_KILL_S[UG]ID is set to not destroy performance for writes.  This is
still racy but the size of the window is reduced.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fuse/dir.c