diff options
| author | Shunbo Shi <shishunbo@cmss.chinamobile.com> | 2026-11-03 03:22:10 +0000 |
|---|---|---|
| committer | Miklos Szeredi <mszeredi@redhat.com> | 2026-11-20 13:46:01 +0100 |
| commit | 71b2cafb76c62c0f800daa94fc4c8f32936a4fbb (patch) | |
| tree | b0b01b8e1692a7d650a0e520eaff22d5b39f89a0 /include/uapi | |
| parent | ae932b1f5727004f585d603e0cbab7e0725c04cf (diff) | |
fuse: fix UBSAN warning in fuse_iomap_writeback_range()
In fuse_iomap_writeback_range() 'ap' is initialized to '&wpa->ia.ap'
unconditionally, but 'wpa' (== data->wpa) is NULL when the writeback
of the first folio of a batch starts: 'data' is zero-initialized in
fuse_writepages() and fuse_launder_folio(), and fuse_writepages_send()
resets data->wpa to NULL after every batch.
Taking the address of a member of a NULL pointer is undefined
behavior. The bogus initial value of 'ap' is never actually
dereferenced: all uses are either guarded by 'if (wpa)' or run after
'ap' has been reassigned in the 'data->wpa == NULL' branch, where a
new 'wpa' is allocated first. Still, the expression lets the
compiler assume that 'wpa' is non-NULL for the whole function, which
could break the 'if (wpa)' check below and turn the latent UB into a
real NULL pointer dereference.
This can be observed with a kernel built with -fsanitize=null (not
part of the default CONFIG_UBSAN flag set) when writeback of an mmap
dirty region is triggered, e.g. via msync()/fsync():
UBSAN: member access within null pointer of type
'struct fuse_writepage_args'
Call Trace:
__ubsan_handle_type_mismatch_v1+0x3f/0x50
fuse_iomap_writeback_range+0x79c/0xbd0
iomap_writepages+0x64/0x140
fuse_writepages+0xe0/0x260
do_writepages+0xaa/0x360
Initialize 'ap' to NULL when 'wpa' is NULL. With this change the
warning above is gone while the writeback path is exercised
identically.
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'include/uapi')
0 files changed, 0 insertions, 0 deletions
