[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200529104053.GH13121@gauss3.secunet.de>
Date: Fri, 29 May 2020 12:40:53 +0200
From: Steffen Klassert <steffen.klassert@...unet.com>
To: Xin Long <lucien.xin@...il.com>
CC: <netdev@...r.kernel.org>, Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Sabrina Dubroca <sd@...asysnail.net>
Subject: Re: [PATCH ipsec] xfrm: fix a NULL-ptr deref in xfrm_local_error
On Tue, May 26, 2020 at 05:41:46PM +0800, Xin Long wrote:
> This patch is to fix a crash:
>
> [ ] kasan: GPF could be caused by NULL-ptr deref or user memory access
> [ ] general protection fault: 0000 [#1] SMP KASAN PTI
> [ ] RIP: 0010:ipv6_local_error+0xac/0x7a0
> [ ] Call Trace:
> [ ] xfrm6_local_error+0x1eb/0x300
> [ ] xfrm_local_error+0x95/0x130
> [ ] __xfrm6_output+0x65f/0xb50
> [ ] xfrm6_output+0x106/0x46f
> [ ] udp_tunnel6_xmit_skb+0x618/0xbf0 [ip6_udp_tunnel]
> [ ] vxlan_xmit_one+0xbc6/0x2c60 [vxlan]
> [ ] vxlan_xmit+0x6a0/0x4276 [vxlan]
> [ ] dev_hard_start_xmit+0x165/0x820
> [ ] __dev_queue_xmit+0x1ff0/0x2b90
> [ ] ip_finish_output2+0xd3e/0x1480
> [ ] ip_do_fragment+0x182d/0x2210
> [ ] ip_output+0x1d0/0x510
> [ ] ip_send_skb+0x37/0xa0
> [ ] raw_sendmsg+0x1b4c/0x2b80
> [ ] sock_sendmsg+0xc0/0x110
>
> This occurred when sending a v4 skb over vxlan6 over ipsec, in which case
> skb->protocol == htons(ETH_P_IPV6) while skb->sk->sk_family == AF_INET in
> xfrm_local_error(). Then it will go to xfrm6_local_error() where it tries
> to get ipv6 info from a ipv4 sk.
>
> This issue was actually fixed by Commit 628e341f319f ("xfrm: make local
> error reporting more robust"), but brought back by Commit 844d48746e4b
> ("xfrm: choose protocol family by skb protocol").
>
> So to fix it, we should call xfrm6_local_error() only when skb->protocol
> is htons(ETH_P_IPV6) and skb->sk->sk_family is AF_INET6.
>
> Fixes: 844d48746e4b ("xfrm: choose protocol family by skb protocol")
> Reported-by: Xiumei Mu <xmu@...hat.com>
> Signed-off-by: Xin Long <lucien.xin@...il.com>
Patch applied, thanks Xin!
Powered by blists - more mailing lists