* [PATCH] hfs: fix potential use after free in hfs_correct_next_unused_CNID()
@ 2025-10-03 9:30 Dan Carpenter
2025-10-03 21:47 ` Viacheslav Dubeyko
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-10-03 9:30 UTC (permalink / raw)
To: Viacheslav Dubeyko
Cc: John Paul Adrian Glaubitz, Yangtao Li, linux-fsdevel,
linux-kernel, kernel-janitors
This code calls hfs_bnode_put(node) which drops the refcount and then
dreferences "node" on the next line. It's only safe to use "node"
when we're holding a reference so flip these two lines around.
Fixes: a06ec283e125 ("hfs: add logic of correcting a next unused CNID")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
fs/hfs/catalog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index caebabb6642f..b80ba40e3877 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -322,9 +322,9 @@ int hfs_correct_next_unused_CNID(struct super_block *sb, u32 cnid)
}
}
+ node_id = node->prev;
hfs_bnode_put(node);
- node_id = node->prev;
} while (node_id >= leaf_head);
return -ENOENT;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hfs: fix potential use after free in hfs_correct_next_unused_CNID()
2025-10-03 9:30 [PATCH] hfs: fix potential use after free in hfs_correct_next_unused_CNID() Dan Carpenter
@ 2025-10-03 21:47 ` Viacheslav Dubeyko
0 siblings, 0 replies; 2+ messages in thread
From: Viacheslav Dubeyko @ 2025-10-03 21:47 UTC (permalink / raw)
To: slava@dubeyko.com, dan.carpenter@linaro.org
Cc: glaubitz@physik.fu-berlin.de, frank.li@vivo.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
On Fri, 2025-10-03 at 12:30 +0300, Dan Carpenter wrote:
> This code calls hfs_bnode_put(node) which drops the refcount and then
> dreferences "node" on the next line. It's only safe to use "node"
> when we're holding a reference so flip these two lines around.
>
> Fixes: a06ec283e125 ("hfs: add logic of correcting a next unused CNID")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> fs/hfs/catalog.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index caebabb6642f..b80ba40e3877 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -322,9 +322,9 @@ int hfs_correct_next_unused_CNID(struct super_block *sb, u32 cnid)
> }
> }
>
> + node_id = node->prev;
> hfs_bnode_put(node);
>
> - node_id = node->prev;
> } while (node_id >= leaf_head);
>
> return -ENOENT;
Yeah, makes sense. Good catch. :) I missed this. Thanks a lot for the fix.
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Thanks,
Slava.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-03 21:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 9:30 [PATCH] hfs: fix potential use after free in hfs_correct_next_unused_CNID() Dan Carpenter
2025-10-03 21:47 ` Viacheslav Dubeyko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).