[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1396821554.12330.51.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Sun, 06 Apr 2014 14:59:14 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Sasha Levin <sasha.levin@...cle.com>
Cc: "David S. Miller" <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
linux-decnet-user@...ts.sourceforge.net,
LKML <linux-kernel@...r.kernel.org>,
Dave Jones <davej@...hat.com>
Subject: [PATCH] decnet: fix possible NULL deref in dnet_select_source()
From: Eric Dumazet <edumazet@...gle.com>
dnet_select_source() should make sure dn_ptr is not NULL.
While looking at this decnet code, I believe I found a device
reference leak, lets fix it as well.
Reported-by: Sasha Levin <sasha.levin@...cle.com>
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
It seems this bug is very old, no recent change is involved.
net/decnet/dn_route.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index ce0cbbfe0f43..4d1608dfb0bd 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -923,6 +923,8 @@ static __le16 dnet_select_source(const struct net_device *dev, __le16 daddr, int
rcu_read_lock();
dn_db = rcu_dereference(dev->dn_ptr);
+ if (!dn_db)
+ goto out;
for (ifa = rcu_dereference(dn_db->ifa_list);
ifa != NULL;
ifa = rcu_dereference(ifa->ifa_next)) {
@@ -938,6 +940,7 @@ static __le16 dnet_select_source(const struct net_device *dev, __le16 daddr, int
if (best_match == 0)
saddr = ifa->ifa_local;
}
+out:
rcu_read_unlock();
return saddr;
@@ -1034,7 +1037,6 @@ source_ok:
if (dev_out)
dev_put(dev_out);
dev_out = init_net.loopback_dev;
- dev_hold(dev_out);
if (!fld.daddr) {
fld.daddr =
fld.saddr = dnet_select_source(dev_out, 0,
@@ -1042,6 +1044,7 @@ source_ok:
if (!fld.daddr)
goto out;
}
+ dev_hold(dev_out);
fld.flowidn_oif = LOOPBACK_IFINDEX;
res.type = RTN_LOCAL;
goto make_route;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists