From: Pavel Skripkin <paskripkin@gmail.com>
To: syzbot <syzbot+2c56b725ec547fa9cb29@syzkaller.appspotmail.com>,
christian.koenig@amd.com, dri-devel@lists.freedesktop.org,
gurchetansingh@chromium.org, kraxel@redhat.com,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, sumit.semwal@linaro.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] general protection fault in sg_alloc_append_table_from_pages
Date: Thu, 30 Dec 2021 16:53:21 +0300 [thread overview]
Message-ID: <83bf58b6-ace2-2db8-4f8b-322e78a3e198@gmail.com> (raw)
In-Reply-To: <000000000000b0a1a605ce3ec5ad@google.com>
[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]
On 10/13/21 19:51, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 717478d89fe2 Merge tag 'riscv-for-linus-5.15-rc5' of git:/..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=12489abf300000
> kernel config: https://syzkaller.appspot.com/x/.config?x=32e6048063923b7b
> dashboard link: https://syzkaller.appspot.com/bug?extid=2c56b725ec547fa9cb29
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=167b9e4f300000
>
> The issue was bisected to:
>
> commit 284562e1f34874e267d4f499362c3816f8f6bc3f
> Author: Gurchetan Singh <gurchetansingh@chromium.org>
> Date: Tue Dec 3 01:36:27 2019 +0000
>
> udmabuf: implement begin_cpu_access/end_cpu_access hooks
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12d68447300000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=11d68447300000
> console output: https://syzkaller.appspot.com/x/log.txt?x=16d68447300000
>
zero ubuf->pagecount will cause kmalloc_array() to return ZERO_PTR, that
is unsafe to deref
#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
With regards,
Pavel Skripkin
[-- Attachment #2: ph --]
[-- Type: text/plain, Size: 452 bytes --]
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index c57a609db75b..e7330684d3b8 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -190,6 +190,10 @@ static long udmabuf_create(struct miscdevice *device,
if (ubuf->pagecount > pglimit)
goto err;
}
+
+ if (!ubuf->pagecount)
+ goto err;
+
ubuf->pages = kmalloc_array(ubuf->pagecount, sizeof(*ubuf->pages),
GFP_KERNEL);
if (!ubuf->pages) {
next prev parent reply other threads:[~2021-12-30 13:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 16:51 [syzbot] general protection fault in sg_alloc_append_table_from_pages syzbot
2021-12-19 17:27 ` syzbot
2021-12-30 13:53 ` Pavel Skripkin [this message]
2021-12-30 14:04 ` syzbot
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=83bf58b6-ace2-2db8-4f8b-322e78a3e198@gmail.com \
--to=paskripkin@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kraxel@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=syzbot+2c56b725ec547fa9cb29@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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).