* [PATCH 1/1] NET: ipv6, fix potential null dereference
@ 2010-01-10 9:06 Jiri Slaby
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10 9:06 UTC (permalink / raw)
To: davem
Cc: linux-kernel, jirislaby, Alexey Kuznetsov, Pekka Savola (ipv6),
James Morris, Hideaki YOSHIFUJI, Patrick McHardy, netdev
Stanse found a potential null dereference in snmp6_unregister_dev.
There is a check for idev being NULL, but it is dereferenced
earlier. Move the dereference after the check.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: "Pekka Savola (ipv6)" <pekkas@netcore.fi>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org
---
net/ipv6/proc.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index c9605c3..53f4ef5 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -256,11 +256,12 @@ int snmp6_register_dev(struct inet6_dev *idev)
int snmp6_unregister_dev(struct inet6_dev *idev)
{
- struct net *net = dev_net(idev->dev);
- if (!net->mib.proc_net_devsnmp6)
- return -ENOENT;
+ struct net *net;
if (!idev || !idev->stats.proc_dir_entry)
return -EINVAL;
+ net = dev_net(idev->dev);
+ if (!net->mib.proc_net_devsnmp6)
+ return -ENOENT;
remove_proc_entry(idev->stats.proc_dir_entry->name,
net->mib.proc_net_devsnmp6);
idev->stats.proc_dir_entry = NULL;
--
1.6.5.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
@ 2010-01-10 10:35 Alexey Dobriyan
2010-01-10 10:38 ` Jiri Slaby
2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
0 siblings, 2 replies; 8+ messages in thread
From: Alexey Dobriyan @ 2010-01-10 10:35 UTC (permalink / raw)
To: jslaby; +Cc: netdev
> Stanse found a potential null dereference
Nobody learns from Coverity, it seems. :^)
snmp6_unregister_dev() always called with valid idev.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
2010-01-10 10:35 [PATCH 1/1] NET: ipv6, fix potential null dereference Alexey Dobriyan
@ 2010-01-10 10:38 ` Jiri Slaby
2010-01-10 10:47 ` Alexey Dobriyan
2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
1 sibling, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10 10:38 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: netdev
On 01/10/2010 11:35 AM, Alexey Dobriyan wrote:
>> Stanse found a potential null dereference
>
> Nobody learns from Coverity, it seems. :^)
If it is known, why the test is still there?
I don't have access to the Coverity results anyway.
> snmp6_unregister_dev() always called with valid idev.
Ok, I'll post a patch to remove the check.
thanks,
--
js
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/1] NET: ipv6, remove unnecessary check
2010-01-10 10:35 [PATCH 1/1] NET: ipv6, fix potential null dereference Alexey Dobriyan
2010-01-10 10:38 ` Jiri Slaby
@ 2010-01-10 10:43 ` Jiri Slaby
2010-01-10 21:28 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10 10:43 UTC (permalink / raw)
To: davem
Cc: adobriyan, linux-kernel, jirislaby, Alexey Kuznetsov,
Pekka Savola (ipv6), James Morris, Hideaki YOSHIFUJI,
Patrick McHardy, netdev
Stanse found a potential null dereference in snmp6_unregister_dev.
There is a check for idev being NULL, but it is dereferenced
earlier. But idev cannot be NULL when passed to
snmp6_unregister_dev, so remove the test.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: "Pekka Savola (ipv6)" <pekkas@netcore.fi>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org
---
net/ipv6/proc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index c9605c3..7b197b7 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -259,7 +259,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
struct net *net = dev_net(idev->dev);
if (!net->mib.proc_net_devsnmp6)
return -ENOENT;
- if (!idev || !idev->stats.proc_dir_entry)
+ if (!idev->stats.proc_dir_entry)
return -EINVAL;
remove_proc_entry(idev->stats.proc_dir_entry->name,
net->mib.proc_net_devsnmp6);
--
1.6.5.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
2010-01-10 10:38 ` Jiri Slaby
@ 2010-01-10 10:47 ` Alexey Dobriyan
2010-01-10 11:05 ` Jiri Slaby
0 siblings, 1 reply; 8+ messages in thread
From: Alexey Dobriyan @ 2010-01-10 10:47 UTC (permalink / raw)
To: Jiri Slaby; +Cc: netdev
On Sun, Jan 10, 2010 at 11:38:57AM +0100, Jiri Slaby wrote:
> On 01/10/2010 11:35 AM, Alexey Dobriyan wrote:
> >> Stanse found a potential null dereference
> >
> > Nobody learns from Coverity, it seems. :^)
>
> If it is known, why the test is still there?
>
> I don't have access to the Coverity results anyway.
Well, when Coverity first exposed their database there were innumerable
"potential NULL dereference" defects and people fixed them by moving
stuff and most were bogus and there were flamewars and there were second
wave and so on...
Apparently "check all callers" is very hard to do programmatically.
> > snmp6_unregister_dev() always called with valid idev.
irda patch is not right too: calling tty->ops->hook with NULL tty is
impossible.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
2010-01-10 10:47 ` Alexey Dobriyan
@ 2010-01-10 11:05 ` Jiri Slaby
2010-01-10 11:37 ` Jiri Slaby
0 siblings, 1 reply; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10 11:05 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: netdev
On 01/10/2010 11:47 AM, Alexey Dobriyan wrote:
> On Sun, Jan 10, 2010 at 11:38:57AM +0100, Jiri Slaby wrote:
>> On 01/10/2010 11:35 AM, Alexey Dobriyan wrote:
>>>> Stanse found a potential null dereference
>>>
>>> Nobody learns from Coverity, it seems. :^)
>>
>> If it is known, why the test is still there?
>>
>> I don't have access to the Coverity results anyway.
>
> Well, when Coverity first exposed their database there were innumerable
> "potential NULL dereference" defects and people fixed them by moving
> stuff and most were bogus and there were flamewars and there were second
> wave and so on...
Well, it is a clear error. Either the check is superfluous, or there is
a potential NULL dereference.
And until people start to look at the reports for their stuff
themselves, they will get bogus fixes from others. And they have to nack
them, indeed.
While we are at it, could anybody look at (watch `task'):
int xprt_reserve_xprt(struct rpc_task *task)
{
struct rpc_rqst *req = task->tk_rqstp; <---- here
struct rpc_xprt *xprt = req->rq_xprt;
if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) {
if (task == xprt->snd_task)
return 1;
if (task == NULL) <------- here
return 0;
And this (I checked 2.6.28, where netdev_priv was dev->priv):
static void __devexit de_remove_one (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct de_private *de = netdev_priv(dev);
BUG_ON(!dev);
I know, currently netdev_priv returns dev+offset, but will this hold in
the future?
>>> snmp6_unregister_dev() always called with valid idev.
>
> irda patch is not right too: calling tty->ops->hook with NULL tty is
> impossible.
Yup, I somehow messed with tty->driver_data being NULL.
thanks,
--
js
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
2010-01-10 11:05 ` Jiri Slaby
@ 2010-01-10 11:37 ` Jiri Slaby
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10 11:37 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: netdev
On 01/10/2010 12:05 PM, Jiri Slaby wrote:
> And until people start to look at the reports for their stuff
> themselves, they will get bogus fixes from others. And they have to nack
> them, indeed.
Plus people sending such patches should plug in their brain. The tty
case is clearly bogus.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] NET: ipv6, remove unnecessary check
2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
@ 2010-01-10 21:28 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-01-10 21:28 UTC (permalink / raw)
To: jslaby
Cc: adobriyan, linux-kernel, jirislaby, kuznet, pekkas, jmorris,
yoshfuji, kaber, netdev
From: Jiri Slaby <jslaby@suse.cz>
Date: Sun, 10 Jan 2010 11:43:03 +0100
> Stanse found a potential null dereference in snmp6_unregister_dev.
> There is a check for idev being NULL, but it is dereferenced
> earlier. But idev cannot be NULL when passed to
> snmp6_unregister_dev, so remove the test.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-01-10 21:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 10:35 [PATCH 1/1] NET: ipv6, fix potential null dereference Alexey Dobriyan
2010-01-10 10:38 ` Jiri Slaby
2010-01-10 10:47 ` Alexey Dobriyan
2010-01-10 11:05 ` Jiri Slaby
2010-01-10 11:37 ` Jiri Slaby
2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
2010-01-10 21:28 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2010-01-10 9:06 [PATCH 1/1] NET: ipv6, fix potential null dereference Jiri Slaby
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).