From: Ben Skeggs <bskeggs@redhat.com>
To: Luca Tettamanti <kronos.it@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>, dri-devel@lists.freedesktop.org
Subject: Re: question regarding nvc0_instmem_suspend()
Date: Mon, 16 Aug 2010 08:24:03 +1000 [thread overview]
Message-ID: <1281911043.2415.0.camel@nisroch> (raw)
In-Reply-To: <AANLkTi=2UMXQXe1E1VTLofx613bVN1KNoOebZcPzonXC@mail.gmail.com>
On Fri, 2010-08-13 at 23:59 +0200, Luca Tettamanti wrote:
> On Fri, Aug 13, 2010 at 11:39 PM, Dan Carpenter <error27@gmail.com> wrote:
> > Smatch thinks there is a buffer overflow in nvc0_instmem_suspend() and
> > I've looked at it, but I don't understand the code.
> >
> > drivers/gpu/drm/nouveau/nvc0_instmem.c +152 nvc0_instmem_suspend(10)
> > error: buffer overflow 'dev_priv->susres.ramin_copy' 16384 <= 1835008
> >
> > 141 int
> > 142 nvc0_instmem_suspend(struct drm_device *dev)
> > 143 {
> > 144 struct drm_nouveau_private *dev_priv = dev->dev_private;
> > 145 int i;
> > 146
> > 147 dev_priv->susres.ramin_copy = vmalloc(65536);
> >
> > dev_priv->susres.ramin_copy is an array of 16384 u32 elements
> > (65536 bytes).
> >
> > 148 if (!dev_priv->susres.ramin_copy)
> > 149 return -ENOMEM;
> > 150
> > 151 for (i = 0x700000; i < 0x710000; i += 4)
> > 152 dev_priv->susres.ramin_copy[i/4] = nv_rd32(dev, i);
> >
> > 0x700000 / 4 is 1835008 so we're way past the end of the array
> > and then we get larger.
>
> I guess that it should be something like:
>
> base = 0x700000;
> for (i = 0; i < 0x10000; i += 4)
> dev_priv->susres.ramin_copy[i/4] = nv_rd32(dev, base + i);
Oops, what a thinko. I've pushed a fix to nouveau git, I'll send it on
for inclusion in 2.6.36.
Ben.
>
>
> Luca
prev parent reply other threads:[~2010-08-15 22:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-13 21:39 question regarding nvc0_instmem_suspend() Dan Carpenter
2010-08-13 21:59 ` Luca Tettamanti
2010-08-15 22:24 ` Ben Skeggs [this message]
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=1281911043.2415.0.camel@nisroch \
--to=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=error27@gmail.com \
--cc=kronos.it@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.