From: Qu Wenruo <wqu@suse.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: check if there is space for chunk item when validating sys chunk array
Date: Thu, 17 Sep 2026 06:58:29 +0930 [thread overview]
Message-ID: <99e44bec-be94-465c-ae93-bff828111702@suse.com> (raw)
In-Reply-To: <1b84f9c06df52773d921c1b2e58e4d27414b5ac8.1789574998.git.fdmanana@suse.com>
在 2026/9/17 01:41, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> We checked if have enough remaining space for a key before dereferencing a
> key, but we then dereference a chunk item, to get the number of stripes,
> without checking if there is space for the item. So add a check to see if
> there is enough space for a chunk item before dereferencing the item to
> extract the stripe count.
>
> Fixes: 2a9bb78cfd36 ("btrfs: validate system chunk array at btrfs_validate_super()")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/disk-io.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index a1d83ad9a4c0..94a7e9059a7b 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -2370,6 +2370,10 @@ static int validate_sys_chunk_array(const struct btrfs_fs_info *fs_info,
> key.type, cur);
> return -EUCLEAN;
> }
> +
> + if (unlikely(cur + sizeof(*chunk) > sys_array_size))
> + goto short_read;
> +
> chunk = (struct btrfs_chunk *)(sb->sys_chunk_array + cur);
> num_stripes = btrfs_stack_chunk_num_stripes(chunk);
> if (unlikely(cur + btrfs_chunk_item_size(num_stripes) > sys_array_size))
prev parent reply other threads:[~2026-09-16 21:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:11 [PATCH] btrfs: check if there is space for chunk item when validating sys chunk array fdmanana
2026-09-16 21:28 ` Qu Wenruo [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=99e44bec-be94-465c-ae93-bff828111702@suse.com \
--to=wqu@suse.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@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