Skip to contentSkip to conversation

net/ipv6: Do not allow route add with a device that is down

PATCH Applied David Ahern 4 participants 4 messages Jan 25, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net/ipv6: Do not allow route add with a device that is down

IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.

---
v3
- moved err=-ENETDOWN under the if check per Eric's request
- left the up check using dev->flags for consistency with IPv4 and that it is used more often in ipv4 and ivp6 code than netif_running

v2
- missed setting err to -ENETDOWN (thanks for catching that Roopa)

 net/ipv6/route.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ipv6/route.c +6 -0
index f85da2f1e729..aa4411c81e7e 100644
@@ -2734,6 +2734,12 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
 	if (!dev)
 		goto out;
 
+	if (!(dev->flags & IFF_UP)) {
+		NL_SET_ERR_MSG(extack, "Nexthop device is not up");
+		err = -ENETDOWN;
+		goto out;
+	}
+
 	if (!ipv6_addr_any(&cfg->fc_prefsrc)) {
 		if (!ipv6_chk_addr(net, &cfg->fc_prefsrc, dev, 0)) {
 			NL_SET_ERR_MSG(extack, "Invalid source address");
Signature · 1 line
2.11.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 6 lines · David Ahern

IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.

Thanks!

Reviewed-by on v3 1/1
#2 lore raw
In reply to David Ahern
Quoted 6 lines · David Ahern

IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.

Quoted 33 lines

---
v3
- moved err=-ENETDOWN under the if check per Eric's request
- left the up check using dev->flags for consistency with IPv4 and that it is used more often in ipv4 and ivp6 code than netif_running

v2
- missed setting err to -ENETDOWN (thanks for catching that Roopa)

 net/ipv6/route.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ipv6/route.c +6 -1
index f85da2f1e729..aa4411c81e7e 100644
@@ -2734,6 +2734,12 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
        if (!dev)
                goto out;
 
+       if (!(dev->flags & IFF_UP)) {
+               NL_SET_ERR_MSG(extack, "Nexthop device is not up");
+               err = -ENETDOWN;
+               goto out;
+       }
+
        if (!ipv6_addr_any(&cfg->fc_prefsrc)) {
                if (!ipv6_chk_addr(net, &cfg->fc_prefsrc, dev, 0)) {
                        NL_SET_ERR_MSG(extack, "Invalid source address");
--

2.11.0

maintainer Applied
#3 lore raw
In reply to David Ahern

From: David Ahern <[email protected]>
Date: Wed, 24 Jan 2018 19:45:29 -0800

Quoted 13 lines

IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.

---
v3
- moved err=-ENETDOWN under the if check per Eric's request
- left the up check using dev->flags for consistency with IPv4 and that it is used more often in ipv4 and ivp6 code than netif_running

Quoted 2 lines

v2
- missed setting err to -ENETDOWN (thanks for catching that Roopa)

Applied, thanks David.