Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp484171pxx; Wed, 28 Oct 2020 09:21:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOTvyXuXJ0a52ptaiRYACgWxMAu1MR5xtxsbj/Qy6UvfgTbEMtwRimXTP0VNU5A2IzcVrA X-Received: by 2002:a17:906:bfc8:: with SMTP id us8mr8667329ejb.282.1603902094919; Wed, 28 Oct 2020 09:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603902094; cv=none; d=google.com; s=arc-20160816; b=t+gnZQVbfuuk8vRAgdHXpJwPmWXsSw/Mmc08VKJAsAJWzt+71c1jnBTX519TkF2416 3QhdYaYwbVKrXenjj4AoQvsZxLqAUP5O/NyVGMJ7RV7j50CWFiY2tAefvwdoVFCxsf/s 31+OU/sOv+S0LSE1pMVcgarqfcd4O4O0Y2BoekfpGV6kVhcYDc4xYAy5TngQGfylotTF y5juMMGNlM6hHg/eBOmfU3XuKO4iendYAT9bGw8qQLDSkzexMf/5jpNr0TEl7ZydUqcA KqE8uWhBRgMt80ET8U94qSItQ5y0GkdviIrf9kqQviUdJepPV3FOevpVlycE0cDifbdF 52kw== 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=S7Zf1tuMfhAbE9FjkBZsTzPX7iXdkzlNYS741ka918md1YsC7JzH/C06LBBrHK6G7h h5JbFU5Y6Sn+FfdyepxFwcU+nv5jtbzEEKH5JzUlDYVtfuzrY+FbZsTu9RxnLKuHSxKR xvbxuUi5xR5gdhAD6e5W61oxNBVTe7lR4YI4BokjADYmpzhPBVzYANyC0vxkVD+uUrn9 rP11JAQCgm7cYo7+h3B66UDWA7OBY5nRoIDhPQLpSAFvahYSS9BKlmD/zOmtMFqKFmFB XKgdRcVj7X8CYS+YvZQp5byfNWHVubXX1c1ZSpVIwT2Gyn0qVY2q9XxUeVSNmOOSR26J SSFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qkwzFzyU; 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 j25si3921855ejb.68.2020.10.28.09.21.12; Wed, 28 Oct 2020 09:21:34 -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=qkwzFzyU; 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 S1816574AbgJ0RHl (ORCPT + 99 others); Tue, 27 Oct 2020 13:07:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:40628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754370AbgJ0PGe (ORCPT ); Tue, 27 Oct 2020 11:06:34 -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 8BAA321D24; Tue, 27 Oct 2020 15:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811194; bh=B/DywA4ArtioFHUmuchIufgDI7PqnX5KvfP7mYFUHo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkwzFzyUpqLCF3QPdTSKpKMstO2PdHw0oi/gOLnpmjNXoRWWxke1N2eNaunEAx6sV 2kN5P2O0tgXC7gfhIgnPU2DLsVaYyLOud5kN2N2r8W6txGgNxg4HtckF+gDJRrSoeY z0bAyNoG8GJMg2kfizMI1wdvg61WISj1ypNXpNIk= 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.8 406/633] RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt() Date: Tue, 27 Oct 2020 14:52:29 +0100 Message-Id: <20201027135541.770656935@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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