netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: network dev <netdev@vger.kernel.org>,
	syzbot <syzbot+e96a7ba46281824cc46a@syzkaller.appspotmail.com>,
	Jon Maloy <jmaloy@redhat.com>, Ying Xue <ying.xue@windriver.com>
Subject: Re: [Patch net] tipc: fix the skb_unshare() in tipc_buf_append()
Date: Fri, 9 Oct 2020 11:07:51 +0800	[thread overview]
Message-ID: <CADvbK_e1A9BuNKbT_TkeWwxrZv-_jLKJduDn=8Bx24XXKA+w3A@mail.gmail.com> (raw)
In-Reply-To: <CAM_iQpW+3w28v6VVvAPrtmKh_Y7UXfFvna9ey77f9m3mDn7tZQ@mail.gmail.com>

On Fri, Oct 9, 2020 at 1:45 AM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> On Thu, Oct 8, 2020 at 1:45 AM Xin Long <lucien.xin@gmail.com> wrote:
> >
> > On Thu, Oct 8, 2020 at 12:12 PM Cong Wang <xiyou.wangcong@gmail.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@gmail.com>

  reply	other threads:[~2020-10-09  3:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  4:12 [Patch net] tipc: fix the skb_unshare() in tipc_buf_append() Cong Wang
2020-10-08  8:45 ` Xin Long
2020-10-08 17:44   ` Cong Wang
2020-10-09  3:07     ` Xin Long [this message]
2020-10-10  1:26 ` Jakub Kicinski

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='CADvbK_e1A9BuNKbT_TkeWwxrZv-_jLKJduDn=8Bx24XXKA+w3A@mail.gmail.com' \
    --to=lucien.xin@gmail.com \
    --cc=jmaloy@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+e96a7ba46281824cc46a@syzkaller.appspotmail.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).