mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: linux-nilfs <linux-nilfs@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] nilfs2: strengthen consistency checks in nilfs_direct_propagate()
Date: Thu, 03 Sep 2026 13:30:12 -0700	[thread overview]
Message-ID: <cdfe97ab759d5b667b5fee9061f3e77f6c0b36ac.camel@dubeyko.com> (raw)
In-Reply-To: <20260903172557.9446-1-konishi.ryusuke@gmail.com>

On Fri, 2026-09-04 at 02:23 +0900, Ryusuke Konishi wrote:
> nilfs_direct_propagate() is responsible for updating the virtual
> block
> number associated with a dirty data block in the direct mapping.
> 
> It is not designed to handle intermediate node blocks.  Furthermore,
> it
> assumes that the block offset of the passed buffer head is within the
> range of NILFS_DIRECT_KEY_MAX; otherwise, an out-of-bounds memory
> access
> could occur within the inode containing the bmap root.
> 
> While such inconsistencies stem from bugs, they can cause silent,
> harmful side effects unless a debug kernel is used - as was the case
> with a recent slab out-of-bounds access issue found in this function.
> 
> Therefore, issue a kernel warning via WARN_ON_ONCE() and return -
> EINVAL
> for these anomalies, allowing the bmap layer to handle the situation
> as
> a filesystem error.
> 
> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> ---
> Hi Viacheslav,
> 
> Please queue this for the next cycle.
> 
> While the recent out-of-bounds memory access issue in
> nilfs_direct_propagate() has already been fixed, this adds extra
> checks
> to catch and gracefully handle similar potential bugs.
> 
> Thanks,
> Ryusuke Konishi
> 
>  fs/nilfs2/direct.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
> index b8643d3aa2f8..64da677dc8d4 100644
> --- a/fs/nilfs2/direct.c
> +++ b/fs/nilfs2/direct.c
> @@ -270,8 +270,14 @@ static int nilfs_direct_propagate(struct
> nilfs_bmap *bmap,
>  	if (!NILFS_BMAP_USE_VBN(bmap))
>  		return 0;
>  
> +	if (WARN_ON_ONCE(buffer_nilfs_node(bh)))
> +		return -EINVAL;
> +
>  	dat = nilfs_bmap_get_dat(bmap);
>  	key = nilfs_bmap_data_get_key(bmap, bh);
> +	if (WARN_ON_ONCE(key > NILFS_DIRECT_KEY_MAX))
> +		return -EINVAL;
> +
>  	ptr = nilfs_direct_get_ptr(bmap, key);
>  	if (ptr == NILFS_BMAP_INVALID_PTR)
>  		return -EINVAL;

Applied.

Thanks,
Slava.

      reply	other threads:[~2026-09-03 20:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 17:23 Ryusuke Konishi
2026-09-03 20:30 ` Viacheslav Dubeyko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cdfe97ab759d5b667b5fee9061f3e77f6c0b36ac.camel@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®