Skip to content

Commit 23e9fcf

Browse files
akodanevklassert
authored andcommitted
vti: fix NULL dereference in xfrm_input()
Can be reproduced with LTP tests: # icmp-uni-vti.sh -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10 IPv4: RIP: 0010:xfrm_input+0x7f9/0x870 ... Call Trace: <IRQ> vti_input+0xaa/0x110 [ip_vti] ? skb_free_head+0x21/0x40 vti_rcv+0x33/0x40 [ip_vti] xfrm4_ah_rcv+0x33/0x60 ip_local_deliver_finish+0x94/0x1e0 ip_local_deliver+0x6f/0xe0 ? ip_route_input_noref+0x28/0x50 ... # icmp-uni-vti.sh -6 -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10 IPv6: RIP: 0010:xfrm_input+0x7f9/0x870 ... Call Trace: <IRQ> xfrm6_rcv_tnl+0x3c/0x40 vti6_rcv+0xd5/0xe0 [ip6_vti] xfrm6_ah_rcv+0x33/0x60 ip6_input_finish+0xee/0x460 ip6_input+0x3f/0xb0 ip6_rcv_finish+0x45/0xa0 ipv6_rcv+0x34b/0x540 xfrm_input() invokes xfrm_rcv_cb() -> vti_rcv_cb(), the last callback might call skb_scrub_packet(), which in turn can reset secpath. Fix it by adding a check that skb->sp is not NULL. Fixes: 7e9e920 ("xfrm: Clear RX SKB secpath xfrm_offload") Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 67a6338 commit 23e9fcf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/xfrm/xfrm_input.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
429429
nf_reset(skb);
430430

431431
if (decaps) {
432-
skb->sp->olen = 0;
432+
if (skb->sp)
433+
skb->sp->olen = 0;
433434
skb_dst_drop(skb);
434435
gro_cells_receive(&gro_cells, skb);
435436
return 0;
@@ -440,7 +441,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
440441

441442
err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async);
442443
if (xfrm_gro) {
443-
skb->sp->olen = 0;
444+
if (skb->sp)
445+
skb->sp->olen = 0;
444446
skb_dst_drop(skb);
445447
gro_cells_receive(&gro_cells, skb);
446448
return err;

0 commit comments

Comments
 (0)