From: Cheng Yongkang <teel4res@gmail.com>
To: Qu Wenruo <wqu@suse.com>
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: reject zero num_stripes in the system chunk array
Date: Fri, 30 Oct 2026 01:01:30 -0700 [thread overview]
Message-ID: <179334729054.2353588.12398743988940745859@gmail.com> (raw)
In-Reply-To: <6ad220fa-d6a0-4b4c-a313-a0cc052b8637@suse.com>
Hi Qu,
Removing the ASSERT alone is not sufficient. btrfs_chunk_item_size()
computes
sizeof(struct btrfs_chunk) +
sizeof(struct btrfs_stripe) * (num_stripes - 1)
With num_stripes == 0, the (num_stripes - 1) term underflows in the
unsigned multiplication and the function returns 16 bytes (48 - 32)
instead of a valid item size. The system chunk array loop would then
advance by the wrong size before btrfs_check_chunk_valid() runs.
So either btrfs_chunk_item_size() has to handle num_stripes == 0 first
(for example, return sizeof(struct btrfs_chunk) and let
btrfs_check_chunk_valid() reject it), or the early check has to stay so
the size calculation is never reached with zero stripes. I kept the
early check as the minimal fix; if you prefer centralizing the rejection
in the tree-checker, I can change btrfs_chunk_item_size() and drop the
check.
Thanks,
Cheng Yongkang
next prev parent reply other threads:[~2026-10-30 8:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 14:12 Cheng Yongkang
2026-10-29 17:55 ` Filipe Manana
2026-10-30 8:01 ` Cheng Yongkang
2026-10-29 21:00 ` Qu Wenruo
2026-10-30 8:01 ` Cheng Yongkang [this message]
2026-10-30 8:13 ` Qu Wenruo
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=179334729054.2353588.12398743988940745859@gmail.com \
--to=teel4res@gmail.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=wqu@suse.com \
/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®