diff mbox series

ipv6: frags: Fix bogus skb->sk in reassembled packets

Message ID 20181220132010.ltpc4yga5st7zwyu@gondor.apana.org.au
State Accepted, archived
Delegated to: David Miller
Headers show
Series ipv6: frags: Fix bogus skb->sk in reassembled packets | expand

Commit Message

Herbert Xu Dec. 20, 2018, 1:20 p.m. UTC
It was reported that IPsec would crash when it encounters an IPv6
reassembled packet because skb->sk is non-zero and not a valid
pointer.

This is because skb->sk is now a union with ip_defrag_offset.

This patch fixes this by resetting skb->sk when exiting from
the reassembly code.

Reported-by: Xiumei Mu <xmu@redhat.com>
Fixes: 219badfaade9 ("ipv6: frags: get rid of ip6frag_skb_cb/...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Eric Dumazet Dec. 20, 2018, 1:26 p.m. UTC | #1
On Thu, Dec 20, 2018 at 5:20 AM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> It was reported that IPsec would crash when it encounters an IPv6
> reassembled packet because skb->sk is non-zero and not a valid
> pointer.
>
> This is because skb->sk is now a union with ip_defrag_offset.
>
> This patch fixes this by resetting skb->sk when exiting from
> the reassembly code.
>
> Reported-by: Xiumei Mu <xmu@redhat.com>
> Fixes: 219badfaade9 ("ipv6: frags: get rid of ip6frag_skb_cb/...")
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
> index 5c3c92713096..a98f95fb6eac 100644
> --- a/net/ipv6/reassembly.c
> +++ b/net/ipv6/reassembly.c
> @@ -378,6 +378,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
>                 if (skb_try_coalesce(head, fp, &headstolen, &delta)) {
>                         kfree_skb_partial(fp, headstolen);
>                 } else {
> +                       fp->sk = NULL;
>                         if (!skb_shinfo(head)->frag_list)
>                                 skb_shinfo(head)->frag_list = fp;
>                         head->data_len += fp->len;


I wonder why this have not been done earlier in commit

commit 5d407b071dc369c26a38398326ee2be53651cfe4
Author: Taehee Yoo <ap420073@gmail.com>
Date:   Mon Sep 10 02:47:05 2018 +0900

    ip: frags: fix crash in ip_do_fragment()

Maybe because the Fixes tag mentioned fa0f527358bd ("ip: use rb trees
for IP frag queue.")
and IPv6 reasm was not using rbtree ...

Oh well.
David Miller Dec. 21, 2018, 12:32 a.m. UTC | #2
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 20 Dec 2018 21:20:10 +0800

> It was reported that IPsec would crash when it encounters an IPv6
> reassembled packet because skb->sk is non-zero and not a valid
> pointer.
> 
> This is because skb->sk is now a union with ip_defrag_offset.
> 
> This patch fixes this by resetting skb->sk when exiting from
> the reassembly code.
> 
> Reported-by: Xiumei Mu <xmu@redhat.com>
> Fixes: 219badfaade9 ("ipv6: frags: get rid of ip6frag_skb_cb/...")
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Applied and queued up for -stable, thanks Herbert.
diff mbox series

Patch

diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 5c3c92713096..a98f95fb6eac 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -378,6 +378,7 @@  static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
 		if (skb_try_coalesce(head, fp, &headstolen, &delta)) {
 			kfree_skb_partial(fp, headstolen);
 		} else {
+			fp->sk = NULL;
 			if (!skb_shinfo(head)->frag_list)
 				skb_shinfo(head)->frag_list = fp;
 			head->data_len += fp->len;