mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: check return values in indx_delete_entry()
@ 2026-07-12 15:15 Dmitry Morgun
  2026-10-07 21:33 ` Konstantin Komarov
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Morgun @ 2026-07-12 15:15 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Dmitry Morgun, ntfs3, linux-kernel, lvc-project

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")
Signed-off-by: Dmitry Morgun <d.morgun@ispras.ru>
---
 fs/ntfs3/index.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 5344b29b0..c730175d7 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -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) {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs/ntfs3: check return values in indx_delete_entry()
  2026-07-12 15:15 [PATCH] fs/ntfs3: check return values in indx_delete_entry() Dmitry Morgun
@ 2026-10-07 21:33 ` Konstantin Komarov
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2026-10-07 21:33 UTC (permalink / raw)
  To: Dmitry Morgun; +Cc: ntfs3, linux-kernel, lvc-project

On 7/12/26 17:15, Dmitry Morgun wrote:

> 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")
> Signed-off-by: Dmitry Morgun <d.morgun@ispras.ru>
> ---
>   fs/ntfs3/index.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
> index 5344b29b0..c730175d7 100644
> --- a/fs/ntfs3/index.c
> +++ b/fs/ntfs3/index.c
> @@ -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) {
> --
> 2.34.1

Hello,

Your patch is applied, thank you.

Regards,
Konstantin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-07 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-12 15:15 [PATCH] fs/ntfs3: check return values in indx_delete_entry() Dmitry Morgun
2026-10-07 21:33 ` Konstantin Komarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®