From: Adrian Bunk <bunk@stusta.de>
To: Dave Jones <davej@redhat.com>,
bcollins@debian.org, dan@dennedy.org,
linux1394-devel@lists.sourceforge.net, scjody@steamballoon.com,
linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [2.6 patch] drivers/ieee1394/raw1394.c: fix a NULL pointer dereference
Date: Mon, 21 Nov 2005 00:52:42 +0100 [thread overview]
Message-ID: <20051120235242.GR16060@stusta.de> (raw)
In-Reply-To: <20051120234055.GF28918@redhat.com>
On Sun, Nov 20, 2005 at 06:40:55PM -0500, Dave Jones wrote:
> On Mon, Nov 21, 2005 at 12:20:09AM +0100, Adrian Bunk wrote:
> > The coverity checker spotted that this was a NULL pointer dereference in
> > the "if (copy_from_user(...))" case.
> >
> >
> > Signed-off-by: Adrian Bunk <bunk@stusta.de>
> >
> > --- linux-2.6.15-rc1-mm2-full/drivers/ieee1394/raw1394.c.old 2005-11-20 22:08:57.000000000 +0100
> > +++ linux-2.6.15-rc1-mm2-full/drivers/ieee1394/raw1394.c 2005-11-20 22:09:34.000000000 +0100
> > @@ -2166,7 +2166,8 @@
> > }
> > }
> > }
> > - kfree(cache->filled_head);
> > + if(cache->filled_head)
> > + kfree(cache->filled_head);
> > kfree(cache);
> >
> > if (ret >= 0) {
> >
>
> How do we get that far with a NULL filled_head ?
> If the kmalloc that fills cache->filled_head fails, we bail out early above.
The problem is not a NULL filled_head.
The problem is that in the "if (copy_from_user(...))" case, cache has
already been freed.
But thinking about this, my patch is also wrong and creates a memory
leak and the real bug is the freeing of cache above.
What about the patch below?
> Dave
cu
Adrian
<-- snip -->
The coverity checker spotted that this was a NULL pointer dereference in
the "if (copy_from_user(...))" case since the next step is to
kfree(cache->filled_head).
There's no need to free cache at this point, and it's getting free'd
later.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
--- linux-2.6.15-rc1-mm2-full/drivers/ieee1394/raw1394.c.old 2005-11-20 22:08:57.000000000 +0100
+++ linux-2.6.15-rc1-mm2-full/drivers/ieee1394/raw1394.c 2005-11-21 00:49:38.000000000 +0100
@@ -2131,7 +2131,6 @@
req->req.length)) {
csr1212_release_keyval(fi->csr1212_dirs[dr]);
fi->csr1212_dirs[dr] = NULL;
- CSR1212_FREE(cache);
ret = -EFAULT;
} else {
cache->len = req->req.length;
next prev parent reply other threads:[~2005-11-20 23:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-20 23:20 [2.6 patch] drivers/ieee1394/raw1394.c: fix a NULL pointer dereference Adrian Bunk
2005-11-20 23:33 ` Jody McIntyre
2005-11-20 23:46 ` Adrian Bunk
2005-11-20 23:54 ` Adrian Bunk
2005-11-20 23:40 ` Dave Jones
2005-11-20 23:52 ` Adrian Bunk [this message]
2005-11-21 19:13 ` Stefan Richter
2005-11-21 18:56 ` Ben Collins
2005-11-21 21:52 ` Jody McIntyre
2005-11-21 22:09 ` Stefan Richter
2005-11-21 22:32 ` Jody McIntyre
2005-11-21 21:55 ` Jody McIntyre
2005-11-20 23:45 ` Jesper Juhl
2005-11-20 23:54 ` Adrian Bunk
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=20051120235242.GR16060@stusta.de \
--to=bunk@stusta.de \
--cc=bcollins@debian.org \
--cc=dan@dennedy.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=scjody@steamballoon.com \
--cc=stable@kernel.org \
/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.