Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp211311pxx; Wed, 28 Oct 2020 02:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk3KKP9kIuN166IBSTsQiaOMvW/YyniFAa4G+bXexqKs0wwY0tWhnu+7JgV2CE1rFbh6hj X-Received: by 2002:a05:6402:744:: with SMTP id p4mr6711655edy.190.1603879067317; Wed, 28 Oct 2020 02:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603879067; cv=none; d=google.com; s=arc-20160816; b=tBIj7e2dTSjsI4I93vpPNAh2PylbAXzLm8mUNY8jOARxLILzim55CCeDnbhO9JP3LN GCai5+m5Um8IBuMb6MvZxMF86mVCGpcBzO9PAZ7t1aATNr8dX3SvGN6B/5HDqO3QCS6d Sbi+83TXF0IFteE94HLAtWkWwY6lkmpdiJ8NolKl503UiQb0G05Ayh+BKOicrOLfZfCu +0c43oDo9i6uTwtb4jhBG7+gJT/Doo9/AfslUdkoVlWx8ms0WD+fuKcnOmuwkSg7P8ZI 8H0c8yLvwdX6JAFop9p+rcL2fWV/PD3Zd/f2u9Mzv8Omay3tmxQyZBeV1t8vNikOaStt yhcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gPEY5IzIBbgZCwX/WBgYJDB5cZVslJkMzRnj3jKECj0=; b=FSWn8Mp9h5YE1bSi2fzAzsJP2hDJRKJ62r+Yk7WPQEUr7myTQdb+2xVqIgXpm2pOy2 l23ajCvUim67f5KQBww3A9g97iUZomDGXGZa96lAEJs27cFzaA3hYz+mcsaxBB504dOE xTJaG4trXdrUBF250SB1Vy6MJ2/I2m4r63nyvx6mltqOJu8HX5UlG89eGENBluur22m0 No0aW0lH358yE3Cl/t6JtVQhcNKJhB2QCr9vSmUbtwX1iQ3omPO7mBhENdIDHw+SQrlo Oli71cJnomzMHpiUihmk4oo8ifE4IDmH350l5ctrMnOzZVkBQ5bfyY+d6tBHGrspc8X2 BL3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LD8xjM+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b29si2827715edn.354.2020.10.28.02.57.25; Wed, 28 Oct 2020 02:57:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LD8xjM+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896819AbgJ0O3A (ORCPT + 99 others); Tue, 27 Oct 2020 10:29:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:55194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759271AbgJ0O2n (ORCPT ); Tue, 27 Oct 2020 10:28:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B1701206DC; Tue, 27 Oct 2020 14:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808923; bh=Noym+lf8cZ47Ly+mv+s8DXWgLUwSiQZUDXTZQt2zu7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LD8xjM+A8gbe1dPr7MkEvVK3E3rJG/AY6kwbJxhB/kaL4y5FGsBL9jp5lj/Uk+lDd y/P+7uys2JnI6+/3teUYabxvZG7BtNglUatIGYb/JnUkJHMWvzBldoNuRR3evCOuts kvLdztFP/l9a/Mxq4+/iXgjq60WkNsbyCSKuG+jk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Ying Xue , Cong Wang , Xin Long , Jakub Kicinski , syzbot+e96a7ba46281824cc46a@syzkaller.appspotmail.com Subject: [PATCH 5.4 011/408] tipc: fix the skb_unshare() in tipc_buf_append() Date: Tue, 27 Oct 2020 14:49:09 +0100 Message-Id: <20201027135455.577087822@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cong Wang [ Upstream commit ed42989eab57d619667d7e87dfbd8fe207db54fe ] 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. 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@syzkaller.appspotmail.com Cc: Jon Maloy Cc: Ying Xue Signed-off-by: Cong Wang Reviewed-by: Xin Long Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/tipc/msg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -140,7 +140,8 @@ int tipc_buf_append(struct sk_buff **hea 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;