Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2143265pxb; Mon, 12 Apr 2021 15:55:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynE6sdPPCBApZAWwfa3aLgM1RPn4WGGtP2Y0tyCosOYWTXdxUD4M1Kpj5U2BXDWqZinYfG X-Received: by 2002:a17:902:ed87:b029:eb:a96:7892 with SMTP id e7-20020a170902ed87b02900eb0a967892mr4684760plj.47.1618268149462; Mon, 12 Apr 2021 15:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618268149; cv=none; d=google.com; s=arc-20160816; b=HVpinVg8h723GVU492kw0kD/HbMpqQb7kIXccWDbnURVQUS7mnyxe/svF6QlHsEsJ+ sDTPfkSauSSUkkeJMfIh/lGO5gmRYFrd+Hixu6HURiiXLOqEYl2rue8WfXfVJ2KW9mWW 4gQSh68U8mty4rw+D7qhZfFQGeuqVfNjg+0K7PS169DIGsMFei617hj7FRe1dcipiweH JhaHEgzQreiUn4uAc99XEb/baKWAiQjw2OXagKgLVLM0hLdRfFLsSHbSTkE7OMwfaudP DyCbQMl771JythdD5+BF7U4B6NOvJgQ3OVs3vFSYxhpjIyZsu+Ai7wfu6S21D3dx1fFG RTEA== 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=SEJwILmO/ZFZT7i6DtBmgOm9ABcVQBsj1AO7lhAfqVs=; b=TVfI2xYUFb6YfPoUlVxdmmWaRaxOP3RQyMdpuIiuZ+iBKEcVlbdnmynwFF8gcKHOK4 ADQSenYNZF+cOzYdaPHLRP7tJFKatChziSmlrz1B6Cv95hc9DIxbbowB/5VyLBnbKpZs 4gzvegk9NoFIGrgQIRKgtuVTGEGCz/3apxGywx2rYTgfCg+qbaywtJdOPSKbRyj2mBZl N6zmysOgldXQn9tx2QdRo9rRQlIzLH0lDTCzBQ/kpm6VdlDmxLGgUVE3TujyZ0SN/LC+ KfYO1ivOvqEOJ+ZZwc0xaql5prvT8rHr9LeMpW3mg9P3YrYE5Yuxj54XA33l8E5B95kV oFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xhy6viJh; 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=pass (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 i21si16016738pgl.482.2021.04.12.15.55.36; Mon, 12 Apr 2021 15:55:49 -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=@linuxfoundation.org header.s=korg header.b=xhy6viJh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243520AbhDLJmX (ORCPT + 99 others); Mon, 12 Apr 2021 05:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240631AbhDLJKs (ORCPT ); Mon, 12 Apr 2021 05:10:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42F766134F; Mon, 12 Apr 2021 09:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218365; bh=GDv5pcHZJM8kn6QtWR2T+MtpIy5+uh9hWn5dt9Lxcp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xhy6viJhv+ifIPgvmU/ilo+QZxj0SeRP2G+TLUTSD+auswAXHNjbZeGE+qeQ4eWyC kRulQ/eU4R++UpRaxAq3iEuGd/jA5aomOAWKV25wHLyuvB916pEbXRIPU72OKJJL++ 0OmgAt8IFVKZNIzohxxsPNxDlNdzaBH2emXPJf58= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , "David S. Miller" , Sasha Levin Subject: [PATCH 5.11 135/210] net:tipc: Fix a double free in tipc_sk_mcast_rcv Date: Mon, 12 Apr 2021 10:40:40 +0200 Message-Id: <20210412084020.502236660@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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: Lv Yunlong [ Upstream commit 6bf24dc0cc0cc43b29ba344b66d78590e687e046 ] In the if(skb_peek(arrvq) == skb) branch, it calls __skb_dequeue(arrvq) to get the skb by skb = skb_peek(arrvq). Then __skb_dequeue() unlinks the skb from arrvq and returns the skb which equals to skb_peek(arrvq). After __skb_dequeue(arrvq) finished, the skb is freed by kfree_skb(__skb_dequeue(arrvq)) in the first time. Unfortunately, the same skb is freed in the second time by kfree_skb(skb) after the branch completed. My patch removes kfree_skb() in the if(skb_peek(arrvq) == skb) branch, because this skb will be freed by kfree_skb(skb) finally. Fixes: cb1b728096f54 ("tipc: eliminate race condition at multicast reception") Signed-off-by: Lv Yunlong Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/socket.c b/net/tipc/socket.c index cebcc104dc70..022999e0202d 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -1265,7 +1265,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, spin_lock_bh(&inputq->lock); if (skb_peek(arrvq) == skb) { skb_queue_splice_tail_init(&tmpq, inputq); - kfree_skb(__skb_dequeue(arrvq)); + __skb_dequeue(arrvq); } spin_unlock_bh(&inputq->lock); __skb_queue_purge(&tmpq); -- 2.30.2