From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 1/5] btrfs: extent_io: Do extra check for extent buffer read write functions
Date: Tue, 11 Aug 2020 14:42:48 -0400 [thread overview]
Message-ID: <26d258e9-4489-df31-d919-a672002863cc@toxicpanda.com> (raw)
In-Reply-To: <20200809120919.85271-2-wqu@suse.com>
On 8/9/20 8:09 AM, Qu Wenruo wrote:
> Although we have start, len check for extent buffer reader/write (e.g.
> read_extent_buffer()), those checks has its limitations:
> - No overflow check
> Values like start = 1024 len = -1024 can still pass the basic
> (start + len) > eb->len check.
>
> - Checks are not consistent
> For read_extent_buffer() we only check (start + len) against eb->len.
> While for memcmp_extent_buffer() we also check start against eb->len.
>
> - Different error reporting mechanism
> We use WARN() in read_extent_buffer() but BUG() in
> memcpy_extent_buffer().
>
> - Still modify memory if the request is obviously wrong
> In read_extent_buffer() even we find (start + len) > eb->len, we still
> call memset(dst, 0, len), which can eaisly cause memory access error
> if start + len overflows.
>
> To address above problems, this patch creates a new common function to
> check such access, check_eb_range().
> - Add overflow check
> This function checks start, start + len against eb->len and overflow
> check.
>
> - Unified checks
>
> - Unified error reports
> Will call WARN() if CONFIG_BTRFS_DEBUG is configured.
> And also do btrfs_warn() message for non-debug build.
>
> - Exit ASAP if check fails
> No more possible memory corruption.
>
> - Add extra comment for @start @len used in those functions
> Even experienced developers sometimes get confused with the @start
> @len with logical address in those functions.
> I'm not sure what's the cause, maybe it's the extent_buffer::start
> naming.
> For now, just add some comment.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=202817
> [ Inspired by above report, the report itself is already addressed ]
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
next prev parent reply other threads:[~2020-08-11 18:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-09 12:09 [PATCH v3 0/5] btrfs: Enhanced runtime defence against fuzzed images Qu Wenruo
2020-08-09 12:09 ` [PATCH v3 1/5] btrfs: extent_io: Do extra check for extent buffer read write functions Qu Wenruo
2020-08-11 18:42 ` Josef Bacik [this message]
2020-08-09 12:09 ` [PATCH v3 2/5] btrfs: extent-tree: Kill BUG_ON() in __btrfs_free_extent() and do better comment Qu Wenruo
2020-08-11 18:45 ` Josef Bacik
2020-08-09 12:09 ` [PATCH v3 3/5] btrfs: Detect unbalanced tree with empty leaf before crashing btree operations Qu Wenruo
2020-08-11 18:48 ` Josef Bacik
2020-08-11 23:04 ` Qu Wenruo
2020-08-12 0:23 ` Josef Bacik
2020-08-12 0:29 ` Qu Wenruo
2020-08-12 1:50 ` Josef Bacik
2020-08-12 1:53 ` Qu Wenruo
2020-08-09 12:09 ` [PATCH v3 4/5] btrfs: extent-tree: Kill the BUG_ON() in insert_inline_extent_backref() Qu Wenruo
2020-08-11 18:50 ` Josef Bacik
2020-08-09 12:09 ` [PATCH v3 5/5] btrfs: ctree: Checking key orders before merged tree blocks Qu Wenruo
2020-08-11 18:53 ` Josef Bacik
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=26d258e9-4489-df31-d919-a672002863cc@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=linux-btrfs@vger.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