fs: ext4: initialize fsdata in pagecache_write()
Subsystems (6)
PATCH 1/1 fs: ext4: initialize fsdata in pagecache_write()
When aops->write_begin() does not initialize fsdata, KMSAN reports an error passing the latter to aops->write_end().
Fix this by unconditionally initializing fsdata.
Also speculatively fix similar issues in affs, f2fs, hfs, hfsplus, as suggested by Eric Biggers.
--- fs/affs/file.c | 2 +- fs/ext4/verity.c | 2 +- fs/f2fs/verity.c | 2 +- fs/hfs/extent.c | 2 +- fs/hfsplus/extents.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
fs/affs/file.c +1 -1
@@ -880,7 +880,7 @@ affs_truncate(struct inode *inode)if (inode->i_size >AFFS_I (inode)->mmu_private) {struct address_space *mapping = inode->i_mapping;struct page *page; -void *fsdata; +void *fsdata =NULL ;loff_t isize = inode->i_size;int res;
fs/ext4/verity.c +1 -1
@@ -79,7 +79,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,size_t n =min_t (size_t, count,PAGE_SIZE -offset_in_page (pos));struct page *page; -void *fsdata; +void *fsdata =NULL ;int res; res = aops->write_begin (NULL , mapping, pos, n, &page, &fsdata);
fs/f2fs/verity.c +1 -1
@@ -81,7 +81,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,size_t n =min_t (size_t, count,PAGE_SIZE -offset_in_page (pos));struct page *page; -void *fsdata; +void *fsdata =NULL ;int res; res = aops->write_begin (NULL , mapping, pos, n, &page, &fsdata);
fs/hfs/extent.c +1 -1
@@ -486,7 +486,7 @@ void hfs_file_truncate(struct inode *inode) inode->i_size);if (inode->i_size >HFS_I (inode)->phys_size) {struct address_space *mapping = inode->i_mapping; -void *fsdata; +void *fsdata =NULL ;struct page *page;/* XXX: Can use generic_cont_expand? */
fs/hfsplus/extents.c +1 -1
@@ -554,7 +554,7 @@ void hfsplus_file_truncate(struct inode *inode)if (inode->i_size > hip->phys_size) {struct address_space *mapping = inode->i_mapping;struct page *page; -void *fsdata; +void *fsdata =NULL ;loff_t size = inode->i_size; res = hfsplus_write_begin(NULL, mapping, size, 0,
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Quoted 9 lines · Alexander Potapenko
[PATCH] fs: ext4: initialize fsdata in
pagecache_write()When
aops->write_begin()does not initialize fsdata, KMSAN reports an error passing the latter toaops->write_end().Fix this by unconditionally initializing fsdata.
Also speculatively fix similar issues in affs, f2fs, hfs, hfsplus, as suggested by Eric Biggers.
You might have better luck with separate patches for each filesystem, as it might be hard to get someone to apply this patch otherwise.
If you do go with a single patch, then the subject prefix should be "fs:", not "fs: ext4:".
- Eric
Quoted 7 lines · Eric Biggers
Quoted 5 lines · Alexander Potapenko
[PATCH] fs: ext4: initialize fsdata in
pagecache_write()When
aops->write_begin()does not initialize fsdata, KMSAN reports an error passing the latter toaops->write_end().
Quoted 7 lines
Quoted 4 lines
Fix this by unconditionally initializing fsdata.
Also speculatively fix similar issues in affs, f2fs, hfs, hfsplus, as suggested by Eric Biggers.
You might have better luck with separate patches for each filesystem, as it might be hard to get someone to apply this patch otherwise.
Done.
Please disregard this patch.
Quoted 4 lines
If you do go with a single patch, then the subject prefix should be "fs:", not "fs: ext4:".
- Eric
Signature · 10 lines
Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg