Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp345382rdh; Thu, 23 Nov 2023 05:41:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsc8s1eJdaqZodvhMJWup8IlnvW8SLCPp8oCN8f9i3ixMycr2j5JYcTL85BIUgQi//Z9sZ X-Received: by 2002:a05:6a20:160e:b0:189:c0e1:497e with SMTP id l14-20020a056a20160e00b00189c0e1497emr6196708pzj.59.1700746892012; Thu, 23 Nov 2023 05:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700746891; cv=none; d=google.com; s=arc-20160816; b=gsW5fsKCVycYqv/4BklSEbIfuMjrJ0Msve/EItZnqhgCKtwbmKFSMYfTI8CtCbncaK cG8bHBN1iJOfEXvq0Kpfv3my6VGbe5Xmgq93OLTfpb2zXXXa3Tqw9G4P33UZhOxd6cXg 4e0TDPlneMEQmpfbomS+fHZ9WEihO087nsAuRLSEp1dVt+ZT50aI0oXVQBrhGaNU/Lrw bQIaApzEepMgkQHJS0ItiJ4cntUE3/es0vtUjpJq21NL3i4+aL2fbZyW5YLiZgMJ/rEc q6K68RWkTvMPkQkU/dMttb1Z5FzqPCBnLoSnYxOfT7M/2f3AVDRNzGK0iTZfxb71UOKG NszQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=3dC8iNZd0ND1y8JUHCPnjrdmFx/rgku9wD1TzpCwI/M=; fh=/CyNfNgw1CM5qrSaEKcP+Lu4EaVfmidLtks5pKPsvKM=; b=lnp+ynHW5pdkoYwB/Un0hDZgGVdk165dSfsNSNoWQPATC6Qb9+Tp4lEk04BzTQtaTh nmH2G5d0fw96YORuFRwhaM4YuNJvppAkMTOD9IDhYEdzvtQ++f8VTLNd36y1qnOH+YGD ++assMSidrzvmU00Rw4p0q0FM3xol0nKFfVB9JiKd7fpe5QbL3T+GN7EnAbbUox5+xv9 RwfwQCYvySJ3NeIJsN77f2GbrMcsWyUg0/hug6LBNflgDvt3Of18mXu73jjl+CuBrE83 olpkzMgQ/a+Zs8ZqirG9TcoMm0oobEn0WyjFEwIeRHY6Ik3Enddav7hUwO56IPoFRFX2 frBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w10-20020a65694a000000b00565ecee8793si1316824pgq.875.2023.11.23.05.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 05:41:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2CC5680859B8; Thu, 23 Nov 2023 05:40:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345530AbjKWNkC (ORCPT + 99 others); Thu, 23 Nov 2023 08:40:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345504AbjKWNkB (ORCPT ); Thu, 23 Nov 2023 08:40:01 -0500 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413311A8; Thu, 23 Nov 2023 05:40:06 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0Vx-bD91_1700746802; Received: from 30.221.129.10(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0Vx-bD91_1700746802) by smtp.aliyun-inc.com; Thu, 23 Nov 2023 21:40:03 +0800 Message-ID: <80014d58-48b0-928f-cc0c-dcfaa75e5975@linux.alibaba.com> Date: Thu, 23 Nov 2023 21:39:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH net-next 5/7] net/smc: compatible with 128-bits extend GID of virtual ISM device To: Simon Horman Cc: wintera@linux.ibm.com, wenjia@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, kgraul@linux.ibm.com, jaka@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, raspl@linux.ibm.com, schnelle@linux.ibm.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1700402277-93750-1-git-send-email-guwen@linux.alibaba.com> <1700402277-93750-6-git-send-email-guwen@linux.alibaba.com> <20231122190725.GB6731@kernel.org> From: Wen Gu In-Reply-To: <20231122190725.GB6731@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 23 Nov 2023 05:40:30 -0800 (PST) On 2023/11/23 03:07, Simon Horman wrote: > On Sun, Nov 19, 2023 at 09:57:55PM +0800, Wen Gu wrote: >> According to virtual ISM support feature defined by SMCv2.1, GIDs of >> virtual ISM device are UUIDs defined by RFC4122, which are 128-bits >> long. So some adaptation work is required. And note that the GIDs of >> existing platform firmware ISM devices still remain 64-bits long. >> >> Signed-off-by: Wen Gu > > ... > >> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c > > ... > >> @@ -1522,7 +1527,10 @@ void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid, unsigned short vlan) >> /* run common cleanup function and build free list */ >> spin_lock_bh(&dev->lgr_lock); >> list_for_each_entry_safe(lgr, l, &dev->lgr_list, list) { >> - if ((!peer_gid || lgr->peer_gid == peer_gid) && >> + if ((!peer_gid->gid || > > Hi Wen Gu, > > Previously this condition assumed that peer could be NULL, > and that is still the case in the next condition, a few lines down. > But with this patch peer is unconditionally dereferenced here. > > As flagged by Smatch. > Hi Simon, Good catch! Previously the peer_gid is an u64 type variable and it will be checked if it is 0. With this patch, peer_gid is an struct smcd_gid type pointer and the function that calls smc_smcd_terminate will make sure it is not NULL. So it is safe here. But there is indeed a problem here, see below. >> + (lgr->peer_gid.gid == peer_gid->gid && >> + !smc_ism_is_virtual(dev) ? 1 : >> + lgr->peer_gid.gid_ext == peer_gid->gid_ext)) && >> (vlan == VLAN_VID_MASK || lgr->vlan_id == vlan)) { >> if (peer_gid) /* peer triggered termination */ This if condition should be 'if (peer_gid->gid)' I will fix this in the next version. Thank you very much. Regards, Wen Gu >> lgr->peer_shutdown = 1; > > ...