From: Dave Jones <davej@redhat.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: maarten.lankhorst@canonical.com, bskeggs@redhat.com
Subject: Re: drm/nouveau: do not allow negative sizes for now
Date: Mon, 29 Jul 2013 20:21:49 -0400 [thread overview]
Message-ID: <20130730002149.GA3853@redhat.com> (raw)
In-Reply-To: <20130723230814.C82D766092E@gitolite.kernel.org>
On Tue, Jul 23, 2013 at 11:08:14PM +0000, Linux Kernel wrote:
> Gitweb: http://git.kernel.org/linus/;a=commit;h=0108bc808107b97e101b15af9705729626be6447
> Commit: 0108bc808107b97e101b15af9705729626be6447
> Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
> AuthorDate: Sun Jul 7 10:40:19 2013 +0200
> Committer: Ben Skeggs <bskeggs@redhat.com>
> CommitDate: Wed Jul 10 10:48:07 2013 +1000
>
> drm/nouveau: do not allow negative sizes for now
>
> The API allows up to 64-bits allocations, but size is handled as int
> inside nouveau almost everywhere. Until this is fixed it's better to
> prevent negative sizes.
>
> The 256 kB before INT_MAX is paranoia, because of the large page
> aligning below that could flip it above INT_MAX.
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 459a445..4e7ee5f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -198,6 +198,12 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
> size_t acc_size;
> int ret;
> int type = ttm_bo_type_device;
> + int max_size = INT_MAX & ~((1 << drm->client.base.vm->vmm->lpg_shift) - 1);
> +
> + if (size <= 0 || size > max_size) {
> + nv_warn(drm, "skipped size %x\n", (u32)size);
> + return -EINVAL;
> + }
>
> if (sg)
> type = ttm_bo_type_sg;
A few more lines down..
222 if (drm->client.base.vm) {
223 if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
Which implies we may now be dereferencing NULL in some situations.
Either the check needs moving higher, or removing.
Can we get here with a NULL client.base.vm ?
Dave
parent reply other threads:[~2013-07-30 0:22 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20130723230814.C82D766092E@gitolite.kernel.org>]
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=20130730002149.GA3853@redhat.com \
--to=davej@redhat.com \
--cc=bskeggs@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@canonical.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