From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A471FC11D3D for ; Thu, 27 Feb 2020 19:01:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BAA324692 for ; Thu, 27 Feb 2020 19:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582830094; bh=jB6PxrsYAh6O2oHTdDruFl7xaP2WE5fpKkdA7wnBSxQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=L7TppCKtreC6K3p5Qzdo0f5V8tj9BwGMRixN/qJTlfMhMKGeKE4B7sm4XV5qYL2Cs jgVbDM+FbA18LdOlnjBhGgnSw5GSXTG9sA5tPaEj3Tw2X4iKQTTkHT7qSKtqMt2HyZ zYI1WOoRKylpdjPYAiu7Miz6Itr4Cey5VPL2YCmU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729317AbgB0TBd (ORCPT ); Thu, 27 Feb 2020 14:01:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:40912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729170AbgB0TBd (ORCPT ); Thu, 27 Feb 2020 14:01:33 -0500 Received: from localhost (unknown [213.57.247.131]) (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 7D5A72467B; Thu, 27 Feb 2020 19:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582830092; bh=jB6PxrsYAh6O2oHTdDruFl7xaP2WE5fpKkdA7wnBSxQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dweqwxe9B/LIH1xt5nH3oTH8yslhc+7dAqb+BO0xfhWy9mBFLuEIv2kuH+SVm78Sp 26DW2PhiVtYrt5bMd7PmDZh4VNjfpUqPUuNhoybtJ5LOxC5psrqYjZM3f606TgEiQs JYEGB77HDmRgI71hwZFqam35Iaym+PE9B8bizkwY= Date: Thu, 27 Feb 2020 21:01:26 +0200 From: Leon Romanovsky To: "Marciniszyn, Mike" Cc: Doug Ledford , Jason Gunthorpe , Maor Gottlieb , "linux-rdma@vger.kernel.org" Subject: Re: [PATCH rdma-rc] RDMA/core: Fix pkey and port assignment in get_new_pps Message-ID: <20200227190126.GO12414@unreal> References: <20200227125728.100551-1-leon@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Thu, Feb 27, 2020 at 02:07:10PM +0000, Marciniszyn, Mike wrote: > > > > From: Maor Gottlieb > > > > When port is part of the modify mask, then we should take > > it from the qp_attr and not from the old pps. Same for PKEY. > > > > Cc: > > Fixes: 1dd017882e01 ("RDMA/core: Fix protection fault in > > get_pkey_idx_qp_list") > > Signed-off-by: Maor Gottlieb > > Signed-off-by: Leon Romanovsky > > --- > > drivers/infiniband/core/security.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/infiniband/core/security.c > > b/drivers/infiniband/core/security.c > > index b9a36ea244d4..2d5608315dc8 100644 > > --- a/drivers/infiniband/core/security.c > > +++ b/drivers/infiniband/core/security.c > > @@ -340,11 +340,15 @@ static struct ib_ports_pkeys *get_new_pps(const > > struct ib_qp *qp, > > return NULL; > > > > if (qp_attr_mask & IB_QP_PORT) > > - new_pps->main.port_num = > > - (qp_pps) ? qp_pps->main.port_num : qp_attr- > > >port_num; > > + new_pps->main.port_num = qp_attr->port_num; > > + else if (qp_pps) > > + new_pps->main.port_num = qp_pps->main.port_num; > > + > > if (qp_attr_mask & IB_QP_PKEY_INDEX) > > - new_pps->main.pkey_index = (qp_pps) ? qp_pps- > > >main.pkey_index : > > - qp_attr->pkey_index; > > + new_pps->main.pkey_index = qp_attr->pkey_index; > > + else if (qp_pps) > > + new_pps->main.pkey_index = qp_pps->main.pkey_index; > > + > > if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & > > IB_QP_PORT)) > > new_pps->main.state = IB_PORT_PKEY_VALID; > > > > I agree with this aspect of the patch and it does fix the panic, because the correct unit > is gotten from qp_pps. > > My issue is that the new_pps->main.state will come back as 0, and the insert routine will drop any new pkey index update. > > The sequence I'm concerned about is: > > 0x71 attr mask with both pkey index and port. > > A ulp decides to change the pkey index and does an 0x51 modify without setting the unit. > > I see new_pps->main.state being returned as 0 and port_pkey_list_insert() will early out. I see, maybe we can store the main.state in qps and restore it from there? > > I asked this exact question in https://marc.info/?l=linux-rdma&m=158278763015030&w=2. > > I also asked about the logical or, and you answered that pointing to an additional patch. > > You but didn't address the main.state being 0 and losing the pkey_index update in the 0x51 modify. > > Mike > > > > > >