Re: [PATCH] nilfs2: Add pointer check for nilfs_direct_propagate()
From: Ryusuke Konishi
Date: Wed Apr 02 2025 - 07:32:27 EST
On Wed, Apr 2, 2025 at 5:59 PM Wentao Liang wrote:
>
> In nilfs_direct_propagate(), the printer get from nilfs_direct_get_ptr()
> need to be checked to ensure it is not an invalid pointer. A proper
> implementation can be found in nilfs_direct_delete(). Add a value check
> and return -ENOENT when it is an invalid pointer.
>
> Fixes: 10ff885ba6f5 ("nilfs2: get rid of nilfs_direct uses")
> Cc: stable@xxxxxxxxxxxxxxx # v2.6+
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> fs/nilfs2/direct.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
> index 893ab36824cc..ff1c9fe72bec 100644
> --- a/fs/nilfs2/direct.c
> +++ b/fs/nilfs2/direct.c
> @@ -273,6 +273,9 @@ static int nilfs_direct_propagate(struct nilfs_bmap *bmap,
> dat = nilfs_bmap_get_dat(bmap);
> key = nilfs_bmap_data_get_key(bmap, bh);
> ptr = nilfs_direct_get_ptr(bmap, key);
> + if (ptr == NILFS_BMAP_INVALID_PTR)
> + return -ENOENT;
> +
> if (!buffer_nilfs_volatile(bh)) {
> oldreq.pr_entry_nr = ptr;
> newreq.pr_entry_nr = ptr;
> --
> 2.42.0.windows.2
>
This patch requires review and correction.
To avoid noise, I will comment on it separately in a reply email that
excludes the stable ML.
As a comment in advance, the commit pointed to by the Fixes tag is not
the commit that caused the issue, and the version specification "#
v2.6+" includes versions prior to nilfs2 mainline integration, so it
is unnecessary.
Regards,
Ryusuke Konishi