From: Pavel Skripkin <paskripkin@gmail.com>
To: kraxel@redhat.com, sumit.semwal@linaro.org,
christian.koenig@amd.com, daniel.vetter@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
syzbot+2c56b725ec547fa9cb29@syzkaller.appspotmail.com
Subject: Re: [PATCH] udmabuf: validate ubuf->pagecount
Date: Wed, 12 Jan 2022 21:08:46 +0300 [thread overview]
Message-ID: <c5ae2a68-070f-884c-c82a-2d3f4b8e06b1@gmail.com> (raw)
In-Reply-To: <20211230142649.23022-1-paskripkin@gmail.com>
On 12/30/21 17:26, Pavel Skripkin wrote:
> Syzbot has reported GPF in sg_alloc_append_table_from_pages(). The
> problem was in ubuf->pages == ZERO_PTR.
>
> ubuf->pagecount is calculated from arguments passed from user-space. If
> user creates udmabuf with list.size == 0 then ubuf->pagecount will be
> also equal to zero; it causes kmalloc_array() to return ZERO_PTR.
>
> Fix it by validating ubuf->pagecount before passing it to
> kmalloc_array().
>
> Fixes: fbb0de795078 ("Add udmabuf misc device")
> Reported-and-tested-by: syzbot+2c56b725ec547fa9cb29@syzkaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> ---
>
Gentle ping :)
>
> ---
> drivers/dma-buf/udmabuf.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> 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) {
With regards,
Pavel Skripkin
next prev parent reply other threads:[~2022-01-12 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-30 14:26 [PATCH] udmabuf: validate ubuf->pagecount Pavel Skripkin
2022-01-12 18:08 ` Pavel Skripkin [this message]
2022-01-14 16:57 ` Daniel Vetter
2022-01-18 6:56 ` Gerd Hoffmann
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=c5ae2a68-070f-884c-c82a-2d3f4b8e06b1@gmail.com \
--to=paskripkin@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.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 \
/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