fuse: fix killing s[ug]id in setattr
authorMiklos Szeredi <mszeredi@redhat.com>
Sat, 1 Oct 2016 05:32:32 +0000 (07:32 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:50:52 +0000 (03:50 +0000)
commit93d390202a5fd61e4677dd7b42b44c3b290d88c3
treeaa5d2dd592d004322ab8e10dc57a026b0132621b
parent643263c1e6c25a9b05a569498bbdd5155df851be
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>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/fuse/dir.c