ila: reload IPv6 header after pskb_may_pull in checksum adjust
Subsystems (3)
PATCH 1/1 ila: reload IPv6 header after pskb_may_pull in checksum adjust
ila_csum_adjust_transport() caches ip6h = ipv6_hdr(skb) before calling pskb_may_pull(). On a non-linear skb whose transport header sits in a page fragment, pskb_may_pull() can call __pskb_pull_tail() / pskb_expand_head() and free the old skb head, leaving ip6h dangling; the following get_csum_diff(ip6h, p) then reads freed memory. ila_update_ipv6_locator() has the same pattern and additionally writes the new locator through the stale destination-address pointer.
Impact: a remote IPv6 packet routed through a configured ILA csum-adjust-transport route or receive-side mapping triggers a slab-use-after-free in ila_update_ipv6_locator() (KASAN). The route or mapping requires CAP_NET_ADMIN to configure, but trigger packets are unauthenticated once it exists.
Reload ip6h (and the derived iaddr) after each pskb_may_pull() before use, matching the transport-header reload the code already performs.
--- net/ipv6/ila/ila_common.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv6/ila/ila_common.c +6 -0
@@ -85,6 +85,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb,struct tcphdr *th = (struct tcphdr *) (skb_network_header (skb) + nhoff); + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&th->check, skb, diff, true, true);
@@ -96,6 +97,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb, (skb_network_header (skb) + nhoff);if (uh->check || skb->ip_summed ==CHECKSUM_PARTIAL ) { + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&uh->check, skb, diff, true, true);
@@ -110,6 +112,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb,struct icmp6hdr *ih = (struct icmp6hdr *) (skb_network_header (skb) + nhoff); + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&ih->icmp6_cksum, skb, diff, true, true);
@@ -151,6 +154,9 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,break ; } + ip6h =ipv6_hdr (skb); + iaddr =ila_a2i (&ip6h->daddr); +/* Now change destination address */ iaddr->loc = p->locator; }
Signature · 1 line
2.53.0
Hi Michael,
Quoted 54 lines · Michael Bommarito
ila_csum_adjust_transport()caches ip6h =ipv6_hdr(skb)before callingpskb_may_pull(). On a non-linear skb whose transport header sits in a page fragment,pskb_may_pull()can call__pskb_pull_tail()/pskb_expand_head()and free the old skb head, leaving ip6h dangling; the followingget_csum_diff(ip6h, p)then reads freed memory.ila_update_ipv6_locator()has the same pattern and additionally writes the new locator through the stale destination-address pointer.Impact: a remote IPv6 packet routed through a configured ILA csum-adjust-transport route or receive-side mapping triggers a slab-use-after-free in
ila_update_ipv6_locator()(KASAN). The route or mapping requiresCAP_NET_ADMINto configure, but trigger packets are unauthenticated once it exists.Reload ip6h (and the derived iaddr) after each
pskb_may_pull()before use, matching the transport-header reload the code already performs.Fixes 33f11d16142b ("ila: Create net/ipv6/ila directory")Assisted-by Claude:claude-opus-4-8Signed-off-by Michael Bommarito <[email protected]>--- net/ipv6/ila/ila_common.c | 6 ++++++ 1 file changed, 6 insertions(+)net/ipv6/ila/ila_common.c +3
-0@@ -85,6 +85,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb,struct tcphdr *th = (struct tcphdr *) (skb_network_header (skb) + nhoff); + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&th->check, skb, diff, true, true);@@ -96,6 +97,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb, (skb_network_header (skb) + nhoff);if (uh->check || skb->ip_summed ==CHECKSUM_PARTIAL ) { + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&uh->check, skb, diff, true, true);@@ -110,6 +112,7 @@ static void ila_csum_adjust_transport(struct sk_buff *skb,struct icmp6hdr *ih = (struct icmp6hdr *) (skb_network_header (skb) + nhoff); + ip6h =ipv6_hdr (skb); diff =get_csum_diff (ip6h, p);inet_proto_csum_replace_by_diff (&ih->icmp6_cksum, skb, diff, true, true);
net/ipv6/ila/ila_common.c void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p, · line 158
Quoted 5 lines
net/ipv6/ila/ila_common.c +2
-0@@ -151,6 +154,9 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,break ; } + ip6h =ipv6_hdr (skb); + iaddr =ila_a2i (&ip6h->daddr);
You should be able to reload the pointers only in the ILA_CSUM_ADJUST_TRANSPORT case.
Quoted 7 lines
net/ipv6/ila/ila_common.c +1
-0+/* Now change destination address */ iaddr->loc = p->locator; }Signature · 1 line
2.53.0