[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvbK_e1A9BuNKbT_TkeWwxrZv-_jLKJduDn=8Bx24XXKA+w3A@mail.gmail.com>
Date: Fri, 9 Oct 2020 11:07:51 +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 Fri, Oct 9, 2020 at 1:45 AM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> On Thu, Oct 8, 2020 at 1:45 AM Xin Long <lucien.xin@...il.com> wrote:
> >
> > 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?
>
> Yes, more precisely, I mean:
>
> new = skb_clone(old)
> kfree_skb(new)
> kfree_skb(new)
>
> would free 'old' eventually when 'old' is a fast clone. The skb_clone()
> sets ->fclone_ref to 2 and returns the clone, whose skb->fclone is
> SKB_FCLONE_CLONE. So, the first call of kfree_skbmem() will
> just decrease ->fclone_ref by 1, but the second call will trigger
> kmem_cache_free() which frees _both_ skb's.
Thanks. Didn't notice kfree_skb 'buf' on the err path.
Reviewed-by: Xin Long <lucien.xin@...il.com>
Powered by blists - more mailing lists