|
|
25030b1 |
From: "D.S. Ljungmark" <ljungmark@modio.se>
|
|
|
25030b1 |
Date: Wed, 25 Mar 2015 09:28:15 +0100
|
|
|
25030b1 |
Subject: [PATCH] ipv6: Don't reduce hop limit for an interface
|
|
|
25030b1 |
|
|
|
25030b1 |
A local route may have a lower hop_limit set than global routes do.
|
|
|
25030b1 |
|
|
|
25030b1 |
RFC 3756, Section 4.2.7, "Parameter Spoofing"
|
|
|
25030b1 |
|
|
|
25030b1 |
> 1. The attacker includes a Current Hop Limit of one or another small
|
|
|
25030b1 |
> number which the attacker knows will cause legitimate packets to
|
|
|
25030b1 |
> be dropped before they reach their destination.
|
|
|
25030b1 |
|
|
|
25030b1 |
> As an example, one possible approach to mitigate this threat is to
|
|
|
25030b1 |
> ignore very small hop limits. The nodes could implement a
|
|
|
25030b1 |
> configurable minimum hop limit, and ignore attempts to set it below
|
|
|
25030b1 |
> said limit.
|
|
|
25030b1 |
|
|
|
25030b1 |
Signed-off-by: D.S. Ljungmark <ljungmark@modio.se>
|
|
|
25030b1 |
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
|
|
|
25030b1 |
---
|
|
|
25030b1 |
net/ipv6/ndisc.c | 9 ++++++++-
|
|
|
25030b1 |
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
25030b1 |
|
|
|
25030b1 |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
|
|
|
25030b1 |
index 682866777d53..d375ce60463e 100644
|
|
|
25030b1 |
--- a/net/ipv6/ndisc.c
|
|
|
25030b1 |
+++ b/net/ipv6/ndisc.c
|
|
|
25030b1 |
@@ -1216,7 +1216,14 @@ static void ndisc_router_discovery(struct sk_buff *skb)
|
|
|
25030b1 |
if (rt)
|
|
|
25030b1 |
rt6_set_expires(rt, jiffies + (HZ * lifetime));
|
|
|
25030b1 |
if (ra_msg->icmph.icmp6_hop_limit) {
|
|
|
25030b1 |
- in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
|
|
|
25030b1 |
+ /* Only set hop_limit on the interface if it is higher than
|
|
|
25030b1 |
+ * the current hop_limit.
|
|
|
25030b1 |
+ */
|
|
|
25030b1 |
+ if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
|
|
|
25030b1 |
+ in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
|
|
|
25030b1 |
+ } else {
|
|
|
25030b1 |
+ ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
|
|
|
25030b1 |
+ }
|
|
|
25030b1 |
if (rt)
|
|
|
25030b1 |
dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
|
|
|
25030b1 |
ra_msg->icmph.icmp6_hop_limit);
|
|
|
25030b1 |
--
|
|
|
25030b1 |
2.1.0
|
|
|
25030b1 |
|