[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvbK_dwh4SFL1KbX=GhxW_O=cZLoPcXC9RjYpZd4=tWrm0LBA@mail.gmail.com>
Date: Thu, 8 Oct 2020 16:45:05 +0800
From: Xin Long <lucien.xin@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: network dev <netdev@...r.kernel.org>,
syzbot <syzbot+e96a7ba46281824cc46a@...kaller.appspotmail.com>,
Jon Maloy <jmaloy@...hat.com>,
Ying Xue <ying.xue@...driver.com>
Subject: Re: [Patch net] tipc: fix the skb_unshare() in tipc_buf_append()
On Thu, Oct 8, 2020 at 12:12 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> skb_unshare() drops a reference count on the old skb unconditionally,
> so in the failure case, we end up freeing the skb twice here.
> And because the skb is allocated in fclone and cloned by caller
> tipc_msg_reassemble(), the consequence is actually freeing the
> original skb too, thus triggered the UAF by syzbot.
Do you mean:
frag = skb_clone(skb, GFP_ATOMIC);
frag = skb_unshare(frag) will free the 'skb' too?
>
> Fix this by replacing this skb_unshare() with skb_cloned()+skb_copy().
>
> Fixes: ff48b6222e65 ("tipc: use skb_unshare() instead in tipc_buf_append()")
> Reported-and-tested-by: syzbot+e96a7ba46281824cc46a@...kaller.appspotmail.com
> Cc: Xin Long <lucien.xin@...il.com>
> Cc: Jon Maloy <jmaloy@...hat.com>
> Cc: Ying Xue <ying.xue@...driver.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>
> ---
> net/tipc/msg.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/tipc/msg.c b/net/tipc/msg.c
> index 52e93ba4d8e2..681224401871 100644
> --- a/net/tipc/msg.c
> +++ b/net/tipc/msg.c
> @@ -150,7 +150,8 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
> if (fragid == FIRST_FRAGMENT) {
> if (unlikely(head))
> goto err;
> - frag = skb_unshare(frag, GFP_ATOMIC);
> + if (skb_cloned(frag))
> + frag = skb_copy(frag, GFP_ATOMIC);
> if (unlikely(!frag))
> goto err;
> head = *headbuf = frag;
> --
> 2.28.0
>
Powered by blists - more mailing lists