* [PATCH net] net/route: enforce hoplimit max value
@ 2016-05-13 16:33 Paolo Abeni
2016-05-14 19:34 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Abeni @ 2016-05-13 16:33 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Alexey Kuznetsov, Hannes Frederic Sowa
Currently, when creating or updating a route, no check is performed
in both ipv4 and ipv6 code to the hoplimit value.
The caller can i.e. set hoplimit to 256, and when such route will
be used, packets will be sent with hoplimit/ttl equal to 0.
This commit adds checks for the RTAX_HOPLIMIT value, in both ipv4
ipv6 route code, substituting any value greater than 255 with 255.
This is consistent with what is currently done for ADVMSS and MTU
in the ipv4 code.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv4/fib_semantics.c | 2 ++
net/ipv6/route.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index d97268e..2b68418 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -975,6 +975,8 @@ fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg)
val = 65535 - 40;
if (type == RTAX_MTU && val > 65535 - 15)
val = 65535 - 15;
+ if (type == RTAX_HOPLIMIT && val > 255)
+ val = 255;
if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
return -EINVAL;
fi->fib_metrics[type - 1] = val;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d916d6a..6f32944 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1750,6 +1750,8 @@ static int ip6_convert_metrics(struct mx6_config *mxc,
} else {
val = nla_get_u32(nla);
}
+ if (type == RTAX_HOPLIMIT && val > 255)
+ val = 255;
if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
goto err;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/route: enforce hoplimit max value
2016-05-13 16:33 [PATCH net] net/route: enforce hoplimit max value Paolo Abeni
@ 2016-05-14 19:34 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-05-14 19:34 UTC (permalink / raw)
To: pabeni; +Cc: netdev, kuznet, hannes
From: Paolo Abeni <pabeni@redhat.com>
Date: Fri, 13 May 2016 18:33:41 +0200
> Currently, when creating or updating a route, no check is performed
> in both ipv4 and ipv6 code to the hoplimit value.
>
> The caller can i.e. set hoplimit to 256, and when such route will
> be used, packets will be sent with hoplimit/ttl equal to 0.
>
> This commit adds checks for the RTAX_HOPLIMIT value, in both ipv4
> ipv6 route code, substituting any value greater than 255 with 255.
>
> This is consistent with what is currently done for ADVMSS and MTU
> in the ipv4 code.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Applied, thanks for fixing this.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-14 19:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-13 16:33 [PATCH net] net/route: enforce hoplimit max value Paolo Abeni
2016-05-14 19:34 ` David Miller
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).