All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vti: fix NULL dereference in xfrm_input()
@ 2017-09-12 11:53 Alexey Kodanev
  2017-09-13 10:44 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kodanev @ 2017-09-12 11:53 UTC (permalink / raw)
  To: netdev; +Cc: Steffen Klassert, Herbert Xu, David Miller, Alexey Kodanev

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: 7e9e9202bccc ("xfrm: Clear RX SKB secpath xfrm_offload")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 net/xfrm/xfrm_input.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 2515cd2..8ac9d32 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -429,7 +429,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
 	nf_reset(skb);
 
 	if (decaps) {
-		skb->sp->olen = 0;
+		if (skb->sp)
+			skb->sp->olen = 0;
 		skb_dst_drop(skb);
 		gro_cells_receive(&gro_cells, skb);
 		return 0;
@@ -440,7 +441,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
 
 		err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async);
 		if (xfrm_gro) {
-			skb->sp->olen = 0;
+			if (skb->sp)
+				skb->sp->olen = 0;
 			skb_dst_drop(skb);
 			gro_cells_receive(&gro_cells, skb);
 			return err;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vti: fix NULL dereference in xfrm_input()
  2017-09-12 11:53 [PATCH] vti: fix NULL dereference in xfrm_input() Alexey Kodanev
@ 2017-09-13 10:44 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2017-09-13 10:44 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: netdev, Herbert Xu, David Miller

On Tue, Sep 12, 2017 at 02:53:46PM +0300, Alexey Kodanev wrote:
> 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: 7e9e9202bccc ("xfrm: Clear RX SKB secpath xfrm_offload")
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>

Patch applied, thanks Alexey!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-13 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 11:53 [PATCH] vti: fix NULL dereference in xfrm_input() Alexey Kodanev
2017-09-13 10:44 ` Steffen Klassert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.