fs/ntfs3: check return values in indx_delete_entry()
PATCH 1/1 fs/ntfs3: check return values in indx_delete_entry()
When the index tree collapses down to an empty root, indx_delete_entry() calls attr_set_size() and ni_remove_attr() for both ATTR_ALLOC and ATTR_BITMAP, but their return values are overwritten by the following call without being checked.
In most other call sites of these functions the return value is checked, so add the same checks here in case an error at this point is meaningful.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/ntfs3/index.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ntfs3/index.c +10 -0
@@ -2619,18 +2619,28 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni, err =attr_set_size (ni,ATTR_ALLOC , in->name, in->name_len, &indx->alloc_run,0 ,NULL , false); +if (err) + goto out; +if (in->name ==I30_NAME )i_size_write (&ni->vfs_inode,0 ); err =ni_remove_attr (ni,ATTR_ALLOC , in->name, in->name_len, false,NULL );run_close (&indx->alloc_run); +if (err) + goto out; err =attr_set_size (ni,ATTR_BITMAP , in->name, in->name_len, &indx->bitmap_run,0 ,NULL , false); +if (err) + goto out; + err =ni_remove_attr (ni,ATTR_BITMAP , in->name, in->name_len, false,NULL );run_close (&indx->bitmap_run); +if (err) + goto out; root =indx_get_root (indx, ni, &attr, &mi);if (!root) {
Signature · 1 line
2.34.1
Konstantin Komarov
maintainerQuoted 51 lines · Dmitry Morgun
When the index tree collapses down to an empty root,
indx_delete_entry()callsattr_set_size()andni_remove_attr()for bothATTR_ALLOCandATTR_BITMAP, but their return values are overwritten by the following call without being checked.In most other call sites of these functions the return value is checked, so add the same checks here in case an error at this point is meaningful.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")Signed-off-by Dmitry Morgun <[email protected]>--- fs/ntfs3/index.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/ntfs3/index.c +10
-1@@ -2619,18 +2619,28 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni, err =attr_set_size (ni,ATTR_ALLOC , in->name, in->name_len, &indx->alloc_run,0 ,NULL , false); +if (err) + goto out; +if (in->name ==I30_NAME )i_size_write (&ni->vfs_inode,0 ); err =ni_remove_attr (ni,ATTR_ALLOC , in->name, in->name_len, false,NULL );run_close (&indx->alloc_run); +if (err) + goto out; err =attr_set_size (ni,ATTR_BITMAP , in->name, in->name_len, &indx->bitmap_run,0 ,NULL , false); +if (err) + goto out; + err =ni_remove_attr (ni,ATTR_BITMAP , in->name, in->name_len, false,NULL );run_close (&indx->bitmap_run); +if (err) + goto out; root =indx_get_root (indx, ni, &attr, &mi);if (!root) { --
Quoted 1 line
2.34.1
Hello,
Your patch is applied, thank you.
Regards,
Konstantin