From: Steffen Klassert <steffen.klassert@secunet•com>
To: Xin Long <lucien.xin@gmail•com>
Cc: <netdev@vger•kernel.org>,
Herbert Xu <herbert@gondor•apana.org.au>,
"David S. Miller" <davem@davemloft•net>,
Sabrina Dubroca <sd@queasysnail•net>
Subject: Re: [PATCH ipsec] xfrm: fix a NULL-ptr deref in xfrm_local_error
Date: Fri, 29 May 2020 12:40:53 +0200 [thread overview]
Message-ID: <20200529104053.GH13121@gauss3.secunet.de> (raw)
In-Reply-To: <690acd84dbe4f2e3955f54a1d6bfe71548a481cf.1590486106.git.lucien.xin@gmail.com>
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@redhat•com>
> Signed-off-by: Xin Long <lucien.xin@gmail•com>
Patch applied, thanks Xin!
prev parent reply other threads:[~2020-05-29 10:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 9:41 [PATCH ipsec] xfrm: fix a NULL-ptr deref in xfrm_local_error Xin Long
2020-05-29 10:40 ` Steffen Klassert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200529104053.GH13121@gauss3.secunet.de \
--to=steffen.klassert@secunet$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=lucien.xin@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=sd@queasysnail$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox