Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp157855pxx; Wed, 28 Oct 2020 01:02:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFJRpwpJbwnCFojgXhdDwhldVQ1Lfkwc2HrJ05Snj5mL5sehdjHxVITRg3YtUcrrI3Jmlj X-Received: by 2002:a17:906:3e4e:: with SMTP id t14mr6358158eji.242.1603872176317; Wed, 28 Oct 2020 01:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872176; cv=none; d=google.com; s=arc-20160816; b=v48qEcB6H39Jx64Zg1Rs1rk3KKZQEReXYvs26XfIWiVzhgDlM8/GNnwgCd1auT9Ay7 shGx+wBoWcSLavSNaOLSauqb2S+31VmB/U5Wca5CQDG77l6RzARKPTMEUCpgvakL1OuP AVy1BZ8Mm60ZkKxYvC2QXoZ3btanfZOpelzpMH3uoS0Q+Mrt5iMHdxNeIntPnyUiULbL l7/Fz0aK6XCJkru7dQtgaGxVyPgqqthkSB1GQ11OEpWPtnR5T9OUhyckEZjdaC5x6zTE CoNcyjB/W8ZwWkDS7rOFKXX7mNjOYRq8WNKY+1bUZoDQC12MK6hk+TOsRJVJRM2VPI14 8kDw== 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=fDg3uUssbB1H/WUVdG/S3wkHj1EFvw0uNdOdmJTrVb8=; b=lBvVpAgjq0xsXvCxkcLlRSfi58IPf7VILlYRrNUXkMlf9e9rY4B66/+EuMeytyv02l aYnLkgPMwkUGKUmPjWQUeoqL1kvWtL7Okk70CEoF/24WrwaGKvkLN97jBlnUbQWMb3JM gqYEZXNsby/8++fylSVDM69ilsNHN0sFG4lk9WuAPEaiFkxc4H0WKStUeqQrrMoHFgSy qApbG4P8JrwLFWWYIQL+W8uD/pwl83Xc+427x1Wq8m3ksEEh3q/F7iV3IAReO2SNHxpS GC/hXRMHtz0gvtO8teFhxk24gf/EOSBB5dR5N3HRMCh2+qJwi40BPazcrJjVga12xfnD EL2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BkiFCeGJ; 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 dk22si2709939edb.258.2020.10.28.01.02.33; Wed, 28 Oct 2020 01:02:56 -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=BkiFCeGJ; 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 S368180AbgJ0N5T (ORCPT + 99 others); Tue, 27 Oct 2020 09:57:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368170AbgJ0N5R (ORCPT ); Tue, 27 Oct 2020 09:57:17 -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 D95AF21D41; Tue, 27 Oct 2020 13:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807037; bh=uN2CxSEDCzGGU6nQ+FvZW9OEUbApARxwXfnsiQR00ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkiFCeGJvjdTpudrfNpmQBw275wgjz1hss8WfIci/c0R5sBW89BlpgO37FzCMEvcQ 3ZjvaF2y9sAvXrwn64G+LJMXHYrK52/G6dnxCoO6UiWV1Ce+oJaXMzLbbQAJYjYRUG CfZp8H9L6U8HZxyZNFtXJOUR11K7DztkECW7Rkm0= 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 4.4 002/112] tipc: fix the skb_unshare() in tipc_buf_append() Date: Tue, 27 Oct 2020 14:48:32 +0100 Message-Id: <20201027134900.654163019@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 @@ -138,7 +138,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;