Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1572032pxb; Tue, 8 Feb 2022 22:41:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2eup/YgNynKBmVra7CI90Nye5usDkmRF6U850+JsHzaQbnUEd52wZrGRqK7+rGA3/J7cC X-Received: by 2002:a17:903:1105:: with SMTP id n5mr788202plh.99.1644388912394; Tue, 08 Feb 2022 22:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644388912; cv=none; d=google.com; s=arc-20160816; b=aIEWHPkCalyOo62FChKmR2pnJX/vDa3vVMbeAnWwvr0YHs9T2rTPPzEhBf+7Myfbh1 8HXTGeYQV78/jNUkA7/EhOa3dRam6Ac/KkCy9tOEUKl12H1P5HA2vpXLKgYb76pWIZ3L QppUEtmXLXlXglC3Jkc9Ebt0wzAPr5OXbgjJx42L04DbdA0bxhfhRK+hzDLiXYF+4oYA AWuZ0TYjf+ZSUNLFXzm1hxGKJWDS/CuO1cxbQpJY/5EFhEX2puqJgeufem49qyUOTKZE gWt8CvnZscRCm3MDwXk4HmX4nFzT0TgBqT0BV5Y77ow6leVl1SYzHw0cEh681v0eDutC 53yg== 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=+JYWCbA7CU4AZ2soKhL9Fbow85+BYwKeSmaexqlVudk=; b=NzXULqbXLiouQ3UuGPyAHC8zKOusmNintsYKezc8bVP/EllZUP32Dy9JiLfjfLcjw6 9Wm2UfXxUhj9PcexDtte136E06/HDlGVA6/jp9PkBX4aNBPIgA3SZp90TIF+TdTYUkri UjgD/GduOA/AGlGnAHCMY2csdT07O2vaaW55r5WJ5OS8X5KO6snBn2fr6Gpf8BjEA+8D s5QL5sOhU04EORzl3Hz6x2BarEFPPXRTbavEf7SkPPJ5N4kv35FvE/QJjgPz7ulR8LTl 09/l2fZWH5DD40TrPAswdVnfwVZ/HvrOedsMT1tjE1UYVsRmSB99nctRzux865mM8GS0 vJLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Wuy6jr3/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ot7si4554522pjb.1.2022.02.08.22.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:41:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Wuy6jr3/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E46BC0F86BD; Tue, 8 Feb 2022 22:25:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388531AbiBGLnx (ORCPT + 99 others); Mon, 7 Feb 2022 06:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385786AbiBGLcf (ORCPT ); Mon, 7 Feb 2022 06:32:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C24C043188; Mon, 7 Feb 2022 03:32:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D870960B20; Mon, 7 Feb 2022 11:32:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF29C004E1; Mon, 7 Feb 2022 11:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233554; bh=c1+xPpj9w6ih7bgu3DWcQoQVtxFuv7Z/aEH2fqPUAlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wuy6jr3/sYTq5hdluXS7r3O7xi2F1+qaAabUoG5eqh+A1bu7938fHhh0WZ6kHNHU4 /gcLCB9FH9hK4Vum7sCl62jjhpmrOCDEoOrthUWR0+qaLMh+i0fDGEP6vDMKNXwbdo sGjAyIpT9YxPr3kq4Ext9+KiqEUs67fNjOe2gIpU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.16 048/126] RDMA/cma: Use correct address when leaving multicast group Date: Mon, 7 Feb 2022 12:06:19 +0100 Message-Id: <20220207103805.779925636@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Gottlieb commit d9e410ebbed9d091b97bdf45b8a3792e2878dc48 upstream. In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate the mgid, otherwise we will generate an IGMP for an incorrect address. Fixes: b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join") Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.com Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/cma.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -67,8 +67,8 @@ static const char * const cma_events[] = [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit", }; -static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr *addr, - union ib_gid *mgid); +static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid, + enum ib_gid_type gid_type); const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event) { @@ -1846,17 +1846,19 @@ static void destroy_mc(struct rdma_id_pr if (dev_addr->bound_dev_if) ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if); - if (ndev) { + if (ndev && !send_only) { + enum ib_gid_type gid_type; union ib_gid mgid; - cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr, - &mgid); - - if (!send_only) - cma_igmp_send(ndev, &mgid, false); - - dev_put(ndev); + gid_type = id_priv->cma_dev->default_gid_type + [id_priv->id.port_num - + rdma_start_port( + id_priv->cma_dev->device)]; + cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid, + gid_type); + cma_igmp_send(ndev, &mgid, false); } + dev_put(ndev); cancel_work_sync(&mc->iboe_join.work); }