Subject: Re: [PATCH net-next] sctp: bring inet(6)_skb_parm back to sctp_input_cb

From: Marcelo Ricardo Leitner <[email-masked]>
Date: Thu, 5 Nov 2020 00:49:09 -0300

On Wed, Nov 04, 2020 at 02:55:32PM +0800, Xin Long wrote:
> inet(6)_skb_parm was removed from sctp_input_cb by Commit a1dd2cf2f1ae
> ("sctp: allow changing transport encap_port by peer packets"), as it
> thought sctp_input_cb->header is not used any more in SCTP.
> 
> syzbot reported a crash:
> 
>   [ ] BUG: KASAN: use-after-free in decode_session6+0xe7c/0x1580
>   [ ]
>   [ ] Call Trace:
>   [ ]  <IRQ>
>   [ ]  dump_stack+0x107/0x163
>   [ ]  kasan_report.cold+0x1f/0x37
>   [ ]  decode_session6+0xe7c/0x1580
>   [ ]  __xfrm_policy_check+0x2fa/0x2850
>   [ ]  sctp_rcv+0x12b0/0x2e30
>   [ ]  sctp6_rcv+0x22/0x40
>   [ ]  ip6_protocol_deliver_rcu+0x2e8/0x1680
>   [ ]  ip6_input_finish+0x7f/0x160
>   [ ]  ip6_input+0x9c/0xd0
>   [ ]  ipv6_rcv+0x28e/0x3c0
> 
> It was caused by sctp_input_cb->header/IP6CB(skb) still used in sctp rx
> path decode_session6() but some members overwritten by sctp6_rcv().
> 
> This patch is to fix it by bring inet(6)_skb_parm back to sctp_input_cb
> and not overwriting it in sctp4/6_rcv() and sctp_udp_rcv().
> 
> Reported-by: [email-masked]
> Fixes: a1dd2cf2f1ae ("sctp: allow changing transport encap_port by peer packets")
> Signed-off-by: Xin Long <[email-masked]>

Acked-by: Marcelo Ricardo Leitner <[email-masked]>

Thanks Xin.