[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <66e8b376-b254-621c-ab3f-6af9d3182689@gmx.com>
Date: Thu, 14 Mar 2019 18:23:44 +0800
From: Su Yue <Damenly_Su@....com>
To: Qu Wenruo <quwenruo.btrfs@....com>,
Nikolay Borisov <nborisov@...e.com>, Kangjie Lu <kjlu@....edu>
Cc: pakki001@....edu, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: fix a NULL pointer dereference
On 2019/3/14 4:02 PM, Qu Wenruo wrote:
>
>
> On 2019/3/14 下午3:54, Nikolay Borisov wrote:
>>
>>
>> On 14.03.19 г. 9:50 ч., Kangjie Lu wrote:
>>> btrfs_lookup_block_group may fail and return NULL. The fix goes
>>> to out when it fails to avoid NULL pointer dereference.
>>
>> Actually no, in this case btrfs_lookup_block_group must never fail
>> because if we have an allocated eb then it must have been allocated from
>> a bg.
>
> Yep, that's the normal case.
>
> However I'm wondering if it's possible to get a bad eb which is cached.
>
> Then we could hit such situation.
>
> So I still believe being safe here still makes sense, especially who
> knows future fuzzed image will be.
Plus one.
Personally, I'd rather like the version 1.
Thanks,
Su
>
> Thanks,
> Qu
>
>>
>>>
>>> Signed-off-by: Kangjie Lu <kjlu@....edu>
>>> ---
>>> fs/btrfs/extent-tree.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>>> index 994f0cc41799..b1e7985bcb9d 100644
>>> --- a/fs/btrfs/extent-tree.c
>>> +++ b/fs/btrfs/extent-tree.c
>>> @@ -7303,6 +7303,8 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
>>>
>>> pin = 0;
>>> cache = btrfs_lookup_block_group(fs_info, buf->start);
>>> + if (!cache)
>>> + goto out;
>>>
>>> if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
>>> pin_down_extent(fs_info, cache, buf->start,
>>>
Powered by blists - more mailing lists