Skip to content

Commit f73016b

Browse files
bsberndMiklos Szeredi
authored andcommitted
fuse: conditionally fill kstat in fuse_do_statx()
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: d304553 ("fuse: implement statx") Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 7d875e6 commit f73016b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/fuse/dir.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,11 +1219,14 @@ static int fuse_do_statx(struct inode *inode, struct file *file,
12191219
fuse_change_attributes(inode, &attr, &outarg.stat,
12201220
ATTR_TIMEOUT(&outarg), attr_version);
12211221
}
1222-
stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME);
1223-
stat->btime.tv_sec = sx->btime.tv_sec;
1224-
stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1);
1225-
fuse_fillattr(inode, &attr, stat);
1226-
stat->result_mask |= STATX_TYPE;
1222+
1223+
if (stat) {
1224+
stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME);
1225+
stat->btime.tv_sec = sx->btime.tv_sec;
1226+
stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1);
1227+
fuse_fillattr(inode, &attr, stat);
1228+
stat->result_mask |= STATX_TYPE;
1229+
}
12271230

12281231
return 0;
12291232
}

0 commit comments

Comments
 (0)