Commit f198d933 authored by Justin Iurman's avatar Justin Iurman Committed by Paolo Abeni

Fix write to cloned skb in ipv6_hop_ioam()

ioam6_fill_trace_data() writes inside the skb payload without ensuring
it's writeable (e.g., not cloned). This function is called both from the
input and output path. The output path (ioam6_iptunnel) already does the
check. This commit provides a fix for the input path, inside
ipv6_hop_ioam(). It also updates ip6_parse_tlv() to refresh the network
header pointer ("nh") when returning from ipv6_hop_ioam().

Fixes: 9ee11f0f ("ipv6: ioam: Data plane support for Pre-allocated Trace")
Reported-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 7d2a894d
...@@ -177,6 +177,8 @@ static bool ip6_parse_tlv(bool hopbyhop, ...@@ -177,6 +177,8 @@ static bool ip6_parse_tlv(bool hopbyhop,
case IPV6_TLV_IOAM: case IPV6_TLV_IOAM:
if (!ipv6_hop_ioam(skb, off)) if (!ipv6_hop_ioam(skb, off))
return false; return false;
nh = skb_network_header(skb);
break; break;
case IPV6_TLV_JUMBO: case IPV6_TLV_JUMBO:
if (!ipv6_hop_jumbo(skb, off)) if (!ipv6_hop_jumbo(skb, off))
...@@ -943,6 +945,14 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff) ...@@ -943,6 +945,14 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)
if (!skb_valid_dst(skb)) if (!skb_valid_dst(skb))
ip6_route_input(skb); ip6_route_input(skb);
/* About to mangle packet header */
if (skb_ensure_writable(skb, optoff + 2 + hdr->opt_len))
goto drop;
/* Trace pointer may have changed */
trace = (struct ioam6_trace_hdr *)(skb_network_header(skb)
+ optoff + sizeof(*hdr));
ioam6_fill_trace_data(skb, ns, trace, true); ioam6_fill_trace_data(skb, ns, trace, true);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment