From: WenRuo Qu <wqu@suse.com>
To: Nikolay Borisov <nborisov@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 1/5] btrfs: extent_io: Do extra check for extent buffer read write functions
Date: Wed, 10 Jul 2019 10:58:40 +0000 [thread overview]
Message-ID: <47b88874-6cef-4eb2-74d8-5a1f51efa99d@suse.com> (raw)
In-Reply-To: <0c6525ff-63f5-6342-4c6c-2e229d0e98b2@suse.com>
On 2019/7/10 下午6:42, Nikolay Borisov wrote:
>
>
[...]
>>
>> +/*
>> + * Check if the [start, start + len) range is valid before reading/writing
>> + * the eb.
>> + *
>> + * Caller should not touch the dst/src memory if this function returns error.
>> + */
>> +static int check_eb_range(const struct extent_buffer *eb, unsigned long start,
>> + unsigned long len)
>> +{
>> + unsigned long end;
>> +
>> + /* start, start + len should not go beyond eb->len nor overflow */
>> + if (unlikely(start > eb->len || start + len > eb->len ||
>
> I think your check here is wrong, it should be start + len > start +
> eb->len. start is the logical address hence it can be a lot bigger than
> the size of the eb which is 16k by default.
Definitely NO.
[start, start + len) must be in the range of [0, nodesize).
So think again.
>
>> + check_add_overflow(start, len, &end))) {
>> + WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG), KERN_ERR
>> +"btrfs: bad eb rw request, eb bytenr=%llu len=%lu rw start=%lu len=%lu\n",
>> + eb->start, eb->len, start, len);
>> + btrfs_warn(eb->fs_info,
>> +"btrfs: bad eb rw request, eb bytenr=%llu len=%lu rw start=%lu len=%lu\n",
>> + eb->start, eb->len, start, len);
>
> If CONFIG_BTRFS_DEBUG is enabled then we will print the warning text
> twice. Simply make it:
>
> WARN_ON(IS_ENABLED()) and leave the btrfs_Warn to always print the text.
WARN_ON() doesn't contain any text to indicate the reason of the stack dump.
Thus I still prefer to show exact the reason other than takes developer
several seconds to combine the stack with the following btrfs_warn()
message.
Anyway, it's not something you'll see even in months, thus I don't
really think it would cause any difference.
Thanks,
Qu
next prev parent reply other threads:[~2019-07-10 11:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 8:02 [PATCH 0/5] btrfs: Enhanced runtime defence against fuzzed images Qu Wenruo
2019-07-10 8:02 ` [PATCH 1/5] btrfs: extent_io: Do extra check for extent buffer read write functions Qu Wenruo
2019-07-10 10:42 ` Nikolay Borisov
2019-07-10 10:58 ` WenRuo Qu [this message]
2019-07-24 16:00 ` David Sterba
2019-07-24 22:54 ` Qu Wenruo
2019-07-25 6:39 ` Nikolay Borisov
2019-07-10 8:02 ` [PATCH 2/5] btrfs: extent-tree: Kill BUG_ON() in __btrfs_free_extent() and do better comment Qu Wenruo
2019-07-10 10:48 ` Nikolay Borisov
2019-07-10 11:00 ` WenRuo Qu
2019-07-10 8:02 ` [PATCH 3/5] btrfs: Detect unbalanced tree with empty leaf before crashing btree operations Qu Wenruo
2019-07-10 10:54 ` Nikolay Borisov
2019-07-10 8:02 ` [PATCH 4/5] btrfs: extent-tree: Kill the BUG_ON() in insert_inline_extent_backref() Qu Wenruo
2019-07-10 11:12 ` Nikolay Borisov
2019-07-10 8:02 ` [PATCH 5/5] btrfs: ctree: Checking key orders before merged tree blocks Qu Wenruo
2019-07-10 11:19 ` Nikolay Borisov
2019-07-10 12:02 ` Qu Wenruo
2019-07-10 12:12 ` Nikolay Borisov
2019-07-24 16:24 ` David Sterba
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=47b88874-6cef-4eb2-74d8-5a1f51efa99d@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@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