From: Nikolay Borisov <nborisov@suse.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: Prevent possible ERR_PTR() dereference
Date: Tue, 11 Jul 2017 22:29:49 +0300 [thread overview]
Message-ID: <21f0034c-fd24-863f-a760-8f8732558468@suse.com> (raw)
In-Reply-To: <20170711172442.GY2866@twin.jikos.cz>
On 11.07.2017 20:24, David Sterba wrote:
> On Tue, Jul 11, 2017 at 04:55:51PM +0300, Nikolay Borisov wrote:
>> In btrfs_full_stripe_len/btrfs_is_parity_mirror we have similar code which
>> gets the chunk map for a particular range via get_chunk_map. However,
>> get_chunk_map can return an ERR_PTR value and while the 2 callers do catch
>> this with a WARN_ON they then proceed to indiscriminately dereference the
>> extent map. This of course leads to a crash. Fix the offenders by making the
>> dereference conditional on IS_ERR.
>
> While the code makes it better, the whole callchain should be fixed. The
> WARN_ON used to be a BUG_ON and the error handling was absent, and still
> is. Although it's unlikely to see the warnings from that, I'd rather see
> it fixed properly. The direct caller of btrfs_full_stripe_len will be
> able to handle it.
What should be returned in case we can't find the chunk_map -EINVAL ?
>
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>
> Reviewed-by: David Sterba <dsterba@suse.com>
>
next prev parent reply other threads:[~2017-07-11 19:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 13:55 [PATCH] btrfs: Prevent possible ERR_PTR() dereference Nikolay Borisov
2017-07-11 17:24 ` David Sterba
2017-07-11 19:29 ` Nikolay Borisov [this message]
2017-07-12 15:38 ` 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=21f0034c-fd24-863f-a760-8f8732558468@suse.com \
--to=nborisov@suse.com \
--cc=dsterba@suse.cz \
--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;
as well as URLs for NNTP newsgroup(s).