fuse: Conditionally fill kstat in fuse_do_statx
Subsystems (2)
PATCH 1/1 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.
--- fs/fuse/dir.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
fs/fuse/dir.c +9 -5
@@ -1219,11 +1219,15 @@ 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 ; }
Signature · 1 line
2.34.1
Quoted 15 lines · Bernd Schubert
The code path
fuse_update_attributes
fuse_update_get_attr
fuse_do_statxhas the risk to use a NULL pointer for struct kstat *stat, although current callers of
fuse_update_attributesonly setrequest_maskto values that will trigger the call offuse_do_getattr, which already handles the NULL pointer. Future updates might miss thatfuse_do_statxdoes not handle it - it is safer to add a condition already right now.
Quoted 1 line
Signed-off-by Bernd Schubert <[email protected]>
Applied, thanks.
Miklos