fuse: invalidate dir dentry after chmod
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)
commit 5e2b8828ff3d79aca8c3a1730652758753205b61 upstream.

Without "default_permissions" the userspace filesystem's lookup operation
needs to perform the check for search permission on the directory.

If directory does not allow search for everyone (this is quite rare) then
userspace filesystem has to set entry timeout to zero to make sure
permissions are always performed.

Changing the mode bits of the directory should also invalidate the
(previously cached) dentry to make sure the next lookup will have a chance
of updating the timeout, if needed.

Reported-by: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
[bwh: Backported to 3.2:
 - Adjust context
 - Open-code d_is_dir()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/fuse/dir.c

index 15c1d29..75b3966 100644 (file)
@@ -1393,10 +1393,20 @@ error:
 
 static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 {
+       int ret;
+
        if (attr->ia_valid & ATTR_FILE)
-               return fuse_do_setattr(entry, attr, attr->ia_file);
+               ret = fuse_do_setattr(entry, attr, attr->ia_file);
        else
-               return fuse_do_setattr(entry, attr, NULL);
+               ret = fuse_do_setattr(entry, attr, NULL);
+
+       if (!ret) {
+               /* Directory mode changed, may need to revalidate access */
+               if (S_ISDIR(entry->d_inode->i_mode) &&
+                   (attr->ia_valid & ATTR_MODE))
+                       fuse_invalidate_entry_cache(entry);
+       }
+       return ret;
 }
 
 static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,