From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1578EC43457 for ; Thu, 8 Oct 2020 17:45:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F567221FE for ; Thu, 8 Oct 2020 17:45:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XGf1phL3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730680AbgJHRpK (ORCPT ); Thu, 8 Oct 2020 13:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbgJHRpK (ORCPT ); Thu, 8 Oct 2020 13:45:10 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA6E4C061755 for ; Thu, 8 Oct 2020 10:45:08 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id k25so7178901ioh.7 for ; Thu, 08 Oct 2020 10:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7c6P9y8oZCFRMDjIeQQPduGoLHcjK1nCsIFHGMh/gMM=; b=XGf1phL3L92ks5nPZoiatj0bOhxvaKSRhFWZ6Bnt4a3j2YM74VXQ+3sflnEPvWAX7Z li9Tj7em8GONUbAozHl5a9kh54CF0wexOAO1SIycenSmYmPHCifNQFoF6BxH34uOF3VO 8TJezo4zvnGthphAGjVrWQhwYdQATX170Qk/GoL0ELNPjg3AYaRr2+Uu9oJe4j6H9yqV rIs9PtzPhJpFy40vSmjc+2RX7XOXWWsWcRizXNf890lCMMOzam34sqbtqXWYLdfkA2Pe Cu8rjrRUUq7VIMB9gB3nEak6IiNsF5s61hUagLkz6KXItbbL7FLdu1vqtIJ4mcubuybt zI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7c6P9y8oZCFRMDjIeQQPduGoLHcjK1nCsIFHGMh/gMM=; b=uBwulgv26Nn7J/2sIlLcvzArBrmpMCbX6FFcStsmgjfBQDEFMi1EXgv033eXtY5KJX Z2y0f9cUgA3B38zXQhQKW7yXHKE34gX6hlE/suDC13fbmKqi2rK93eqR3qYzcPyMwc6E Ad4uI196GRaDsqbKEpUf0mJ9E+Zf1UcmGifkIRs8BUNAzOjx46lHrWtKLa5XH/bKVZSY U10Tew5VTm/2Kf+r2+fKF53H4j5hsoXzmKdNRqdm97TxVj6Q3L3PhHOgETZuk0Ig5XMK UHiTaR3zVWouiRvp8Tg1CltXfhlW3nFuQevGaGoxC3ZVUrezko+7RzDt1XBK3m1SEjFF jjzg== X-Gm-Message-State: AOAM532fGpPwKhMpRcL6aE12MfYZAircVc/VhnRdFJM63X/qrAbJoFK7 4JO4VSQ9zweiYyfWf+nrywNLt8R4jM325s32DYQExC6kr1yvCg== X-Google-Smtp-Source: ABdhPJxdFfn+S77W/rpoow6//gEGrsKxV7L1Q7ExxMqfDp99/TtK93XNKpRMx8+nzg3tyBlKvCOlwOY7cubg9XtJQn4= X-Received: by 2002:a6b:1542:: with SMTP id 63mr6722773iov.64.1602179107861; Thu, 08 Oct 2020 10:45:07 -0700 (PDT) MIME-Version: 1.0 References: <20201008041250.22642-1-xiyou.wangcong@gmail.com> In-Reply-To: From: Cong Wang Date: Thu, 8 Oct 2020 10:44:56 -0700 Message-ID: Subject: Re: [Patch net] tipc: fix the skb_unshare() in tipc_buf_append() To: Xin Long Cc: network dev , syzbot , Jon Maloy , Ying Xue Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Oct 8, 2020 at 1:45 AM Xin Long wrote: > > On Thu, Oct 8, 2020 at 12:12 PM Cong Wang 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.