Skip to contentSkip to conversation

NET: ipv6, fix potential null dereference

PATCH Applied Alexey Dobriyan 4 participants 7 messages Jan 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 1 line

Stanse found a potential null dereference

Nobody learns from Coverity, it seems. :^)

snmp6_unregister_dev() always called with valid idev.

#1 lore raw
Quoted 3 lines · Alexey Dobriyan
Quoted 1 line

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.

Quoted 1 line

snmp6_unregister_dev() always called with valid idev.

Ok, I'll post a patch to remove the check.

thanks,

Signature · 1 line
js
#2 lore raw
Quoted 8 lines · Jiri Slaby
Quoted 3 lines · Alexey Dobriyan
Quoted 1 line

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.

Quoted 1 line
Quoted 1 line

snmp6_unregister_dev() always called with valid idev.

irda patch is not right too: calling tty->ops->hook with NULL tty is impossible.

#3 lore raw
Quoted 6 lines · Alexey Dobriyan
Quoted 5 lines · Jiri Slaby
Quoted 3 lines · Alexey Dobriyan
Quoted 1 line

Stanse found a potential null dereference

Nobody learns from Coverity, it seems. :^)

Quoted 8 lines
Quoted 3 lines

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?

Quoted 4 lines
Quoted 1 line
Quoted 1 line

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,

Signature · 1 line
js
#4 lore raw
Quoted 3 lines · Jiri Slaby

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.

#5 lore raw

PATCH 1/1 NET: ipv6, remove unnecessary check

In reply to Alexey Dobriyan

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.

Cc "David S. Miller" <[email protected]>
Cc Alexey Kuznetsov <[email protected]>
Cc "Pekka Savola (ipv6)" <[email protected]>
Cc James Morris <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/ipv6/proc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/proc.c +1 -1
index c9605c3..7b197b7 100644
@@ -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);
Signature · 1 line
1.6.5.7
maintainer Applied
#6 lore raw

Re: [PATCH 1/1] NET: ipv6, remove unnecessary check

From: Jiri Slaby <[email protected]>
Date: Sun, 10 Jan 2010 11:43:03 +0100

Quoted 6 lines

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.

Applied.