From: Anant Thazhemadam <anant.thazhemadam@gmail.com>
To: Andrew Price <anprice@redhat.com>
Cc: agruenba@redhat.com, Fox Chen <foxhlchen@gmail.com>,
linux-kernel@vger.kernel.org,
syzbot+a5e2482a693e6b1e444b@syzkaller.appspotmail.com,
cluster-devel@redhat.com, rpeterso@redhat.com,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] [Cluster-devel] [PATCH] fs: gfs2: prevent OOB access in gfs2_read_sb()
Date: Wed, 14 Oct 2020 18:44:06 +0530 [thread overview]
Message-ID: <48a1f8ca-54ce-09f4-45c2-b1091d4e358a@gmail.com> (raw)
In-Reply-To: <d75dc535-00be-3aa7-addb-c2615b202b56@redhat.com>
On 14/10/20 6:34 pm, Andrew Price wrote:
> On 13/10/2020 16:26, Anant Thazhemadam wrote:
>> In gfs2_read_sb(), if the condition
>> (d != sdp->sd_heightsize[x - 1] || m)
>> isn't satisfied (in the first 11 iterations), the loop continues,
>> and begins to perform out-of-bounds access.
>> Fix this out-of-bounds access by introducing a condition in the for loop
>> that ensures that no more than GFS2_MAX_META_HEIGHT + 1 elements are
>> accessed.
>>
>> In addition to this, if the above condition is satisfied when
>> x = GFS2_MAX_META_HEIGHT (which = 10), and the flow of control breaks
>> out of the loop, then an out-of-bounds access is performed again while
>> assigning sdp->sd_heightsize[x] = ~0 (since x would be 11 now.), and
>> also the assertion that spd->sd_max_height <= GFS2_MAX_META_HEIGHT would
>> fail.
>> Fix this out-of-bounds access and ensure that the assertion doesn't fail
>> by introducing another variable "index", which keeps track of the last
>> valid value of x (pre-increment) that can be used.
>
> That's not quite the right approach. Your analysis below is correct: the problem stems from the block size in the superblock being zeroed by the fuzzer. So the correct fix would be to add a validation check for sb_bsize (gfs2_check_sb() is lacking somewhat). Valid values are powers of 2 between 512 and the page size.
>
I see. Thanks for the review! I'll send in a v2 that implements this check soon enough.
Thanks,
Anant
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2020-10-14 13:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 15:26 [Linux-kernel-mentees] [PATCH] fs: gfs2: prevent OOB access in gfs2_read_sb() Anant Thazhemadam
2020-10-14 13:04 ` [Linux-kernel-mentees] [Cluster-devel] " Andrew Price
2020-10-14 13:14 ` Anant Thazhemadam [this message]
2020-10-14 13:25 ` Fox Chen
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=48a1f8ca-54ce-09f4-45c2-b1091d4e358a@gmail.com \
--to=anant.thazhemadam@gmail.com \
--cc=agruenba@redhat.com \
--cc=anprice@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=foxhlchen@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpeterso@redhat.com \
--cc=syzbot+a5e2482a693e6b1e444b@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).