diff options
author | hannes@stressinduktion.org <hannes@stressinduktion.org> | 2015-04-01 11:07:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-06 16:12:49 -0400 |
commit | f60e5990d9c1424af9dbca60a23ba2a1c7c1ce90 (patch) | |
tree | bba5ed057073e42c0113473e1cdbff0bc46ab875 /net/ipv6/ip6_output.c | |
parent | 576b7cd2f6ff1e90b3fc0a000d2fe74f8a50a4bb (diff) |
ipv6: protect skb->sk accesses from recursive dereference inside the stack
We should not consult skb->sk for output decisions in xmit recursion
levels > 0 in the stack. Otherwise local socket settings could influence
the result of e.g. tunnel encapsulation process.
ipv6 does not conform with this in three places:
1) ip6_fragment: we do consult ipv6_npinfo for frag_size
2) sk_mc_loop in ipv6 uses skb->sk and checks if we should
loop the packet back to the local socket
3) ip6_skb_dst_mtu could query the settings from the user socket and
force a wrong MTU
Furthermore:
In sk_mc_loop we could potentially land in WARN_ON(1) if we use a
PF_PACKET socket ontop of an IPv6-backed vxlan device.
Reuse xmit_recursion as we are currently only interested in protecting
tunnel devices.
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_output.c')
-rw-r--r-- | net/ipv6/ip6_output.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 7e80b61b51ff..36cf0ab685a0 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -542,7 +542,8 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
542 | { | 542 | { |
543 | struct sk_buff *frag; | 543 | struct sk_buff *frag; |
544 | struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); | 544 | struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); |
545 | struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; | 545 | struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? |
546 | inet6_sk(skb->sk) : NULL; | ||
546 | struct ipv6hdr *tmp_hdr; | 547 | struct ipv6hdr *tmp_hdr; |
547 | struct frag_hdr *fh; | 548 | struct frag_hdr *fh; |
548 | unsigned int mtu, hlen, left, len; | 549 | unsigned int mtu, hlen, left, len; |