Skip to content

Commit f198d93

Browse files
IurmanJPaolo Abeni
authored andcommitted
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: 9ee11f0 ("ipv6: ioam: Data plane support for Pre-allocated Trace") Reported-by: Paolo Abeni <[email protected]> Signed-off-by: Justin Iurman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 7d2a894 commit f198d93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/ipv6/exthdrs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ static bool ip6_parse_tlv(bool hopbyhop,
177177
case IPV6_TLV_IOAM:
178178
if (!ipv6_hop_ioam(skb, off))
179179
return false;
180+
181+
nh = skb_network_header(skb);
180182
break;
181183
case IPV6_TLV_JUMBO:
182184
if (!ipv6_hop_jumbo(skb, off))
@@ -943,6 +945,14 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)
943945
if (!skb_valid_dst(skb))
944946
ip6_route_input(skb);
945947

948+
/* About to mangle packet header */
949+
if (skb_ensure_writable(skb, optoff + 2 + hdr->opt_len))
950+
goto drop;
951+
952+
/* Trace pointer may have changed */
953+
trace = (struct ioam6_trace_hdr *)(skb_network_header(skb)
954+
+ optoff + sizeof(*hdr));
955+
946956
ioam6_fill_trace_data(skb, ns, trace, true);
947957
break;
948958
default:

0 commit comments

Comments
 (0)