]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
fuse: conditionally fill kstat in fuse_do_statx()
authorBernd Schubert <bschubert@ddn.com>
Wed, 23 Aug 2023 22:33:45 +0000 (00:33 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 29 Aug 2023 12:58:48 +0000 (14:58 +0200)
The code path

fuse_update_attributes
    fuse_update_get_attr
        fuse_do_statx

has the risk to use a NULL pointer for struct kstat *stat, although current
callers of fuse_update_attributes() only set request_mask to values that
will trigger the call of fuse_do_getattr(), which already handles the NULL
pointer.  Future updates might miss that fuse_do_statx() does not handle it
it is safer to add a condition already right now.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Fixes: d3045530bdd2 ("fuse: implement statx")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dir.c

index e190d09f220d9ce89ca2e4710685e86b45ea5986..04a1c62342dc468e5653426ca34e426fcc49e50c 100644 (file)
@@ -1219,11 +1219,14 @@ static int fuse_do_statx(struct inode *inode, struct file *file,
                fuse_change_attributes(inode, &attr, &outarg.stat,
                                       ATTR_TIMEOUT(&outarg), attr_version);
        }
-       stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME);
-       stat->btime.tv_sec = sx->btime.tv_sec;
-       stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1);
-       fuse_fillattr(inode, &attr, stat);
-       stat->result_mask |= STATX_TYPE;
+
+       if (stat) {
+               stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME);
+               stat->btime.tv_sec = sx->btime.tv_sec;
+               stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1);
+               fuse_fillattr(inode, &attr, stat);
+               stat->result_mask |= STATX_TYPE;
+       }
 
        return 0;
 }