Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp516179pxx; Wed, 28 Oct 2020 10:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAh0UB8MLXTSAvL8/3ta4T/u6IX7T0q5iQgV9IMiHWoLmRT4Box+xXAnKKEV57xYbSKB9G X-Received: by 2002:a17:906:3cc:: with SMTP id c12mr58601eja.210.1603904755315; Wed, 28 Oct 2020 10:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904755; cv=none; d=google.com; s=arc-20160816; b=dfg0dxtE2vlm5qPmMaGECKyXQ1P8hGlUM4essqogs3tg/cKnpuENZuseD0PKl+QVwF 0mNI0ps9dVzA7UDMNIVnMpYtsfcMjoIoTENuqml1z6034rKxGIBVxbYG08PFomfuEE+U hFLG37GyXrYgVYwvHyctAnw5FKT7uqOuXDax7UqvNIXZ2pYxQ0oTay4fFEAkx1g2kfOi HPV1qyVEorZJBquEkTwadV6cWlS3lgftNykt7ldM3r1/JLiFOcUJnZC8aVIP0P4XR9rd fFfsftheLnUHrn3TIDffijEbQorg8TkqPYyTH9IRh/uxJII44XSYD8EbMMwXVjDjULkT DNiQ== 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=CwRWXivymGxWEMJZZk16+pQP8YAJvR/Is3qaDtEoAt0=; b=jtHdA2hdU8fs1JvDKNzjCkvZ0/tpAEvPl6cm/rKthvQTsklyZ8PnitoRKXO0UBwD0Y 9ucFZkyhyILQR+pmnwEIs/s4Lbxc1R7supGGuMj/9ypjHQ1CRQxUHLjpB8ujKTpkV+ek 0ixl58m2l2Uw+GjcbLTCPeR2euwig8/yhmGvyf3EtMor7mJ4mAkOO2lULfetgfI+Ikhw YcT/eQUnhgOwMa1YBtsN5vDCI1RG3eH+PtnxWgVQDoy11jzG8UXHxTHQSagk//mVUql0 qo+MlhAOBMCIyPgypUw3Memk8eKtjHV2tSdqzdsBCMAjzu6JEkM3Z9i/YZ7/78Hulkcy W0Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZzzYwol/"; 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 y1si30775edp.57.2020.10.28.10.05.25; Wed, 28 Oct 2020 10:05:55 -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="ZzzYwol/"; 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 S1820071AbgJ0Rch (ORCPT + 99 others); Tue, 27 Oct 2020 13:32:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:40620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762163AbgJ0OlS (ORCPT ); Tue, 27 Oct 2020 10:41:18 -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 2FCBB22275; Tue, 27 Oct 2020 14:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809676; bh=B/DywA4ArtioFHUmuchIufgDI7PqnX5KvfP7mYFUHo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzzYwol/ffe4S5Sb9jhKhzP5En45GXNn8kv4bHElyZdirw5gObwLuIJmO+x3Bmaru ffJR7L28l1+BPJx/qyZKDuLFon73RfGqWskr7bILFTFCpLFeV0nOcxscnMA5pvRyXd zRz5cgSvXVW5G4pNt3mA11pb3pRCm3AlK4LRIIyM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Pearson , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.4 249/408] RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt() Date: Tue, 27 Oct 2020 14:53:07 +0100 Message-Id: <20201027135506.614472189@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: Bob Pearson [ Upstream commit e7ec96fc7932f48a6d6cdd05bf82004a1a04285b ] The changes referenced below replaced sbk_clone)_ by taking additional references, passing the skb along and then freeing the skb. This deleted the packets before they could be processed and additionally passed bad data in each packet. Since pkt is stored in skb->cb changing pkt->qp changed it for all the packets. Replace skb_get() by sbk_clone() in rxe_rcv_mcast_pkt() for cases where multiple QPs are receiving multicast packets on the same address. Delete kfree_skb() because the packets need to live until they have been processed by each QP. They are freed later. Fixes: 86af61764151 ("IB/rxe: remove unnecessary skb_clone") Fixes: fe896ceb5772 ("IB/rxe: replace refcount_inc with skb_get") Link: https://lore.kernel.org/r/20201008203651.256958-1-rpearson@hpe.com Signed-off-by: Bob Pearson Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_recv.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index 46e111c218fd4..be6416a982c70 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -281,6 +281,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) struct rxe_mc_elem *mce; struct rxe_qp *qp; union ib_gid dgid; + struct sk_buff *per_qp_skb; + struct rxe_pkt_info *per_qp_pkt; int err; if (skb->protocol == htons(ETH_P_IP)) @@ -309,21 +311,26 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) if (err) continue; - /* if *not* the last qp in the list - * increase the users of the skb then post to the next qp + /* for all but the last qp create a new clone of the + * skb and pass to the qp. */ if (mce->qp_list.next != &mcg->qp_list) - skb_get(skb); + per_qp_skb = skb_clone(skb, GFP_ATOMIC); + else + per_qp_skb = skb; - pkt->qp = qp; + per_qp_pkt = SKB_TO_PKT(per_qp_skb); + per_qp_pkt->qp = qp; rxe_add_ref(qp); - rxe_rcv_pkt(pkt, skb); + rxe_rcv_pkt(per_qp_pkt, per_qp_skb); } spin_unlock_bh(&mcg->mcg_lock); rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */ + return; + err1: kfree_skb(skb); } -- 2.25.1