Skip to contentSkip to conversation

fs/ntfs3: check return values in indx_delete_entry()

PATCH In review Dmitry Morgun 2 participants 2 messages Jul 12 – Oct 7 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

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.

Fixes 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
---
 fs/ntfs3/index.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/ntfs3/index.c +10 -0
index 5344b29b0..c730175d7 100644
@@ -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
#1 lore raw
Quoted 51 lines · Dmitry Morgun

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.

Fixes 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
---
  fs/ntfs3/index.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
fs/ntfs3/index.c +10 -1
index 5344b29b0..c730175d7 100644
@@ -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