From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 109B62F0686 for ; Mon, 15 Sep 2025 08:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757923363; cv=none; b=c8sCZvvkH8nDuRTaAzf0cxeAp7pTvF1rRZjVSHS7hes72U0BFtAmny42RhkHcVcNEKuDRRsIYuC4JTdSMwIO5SdmIsTEpy3oFbeUoNm5iyWFm3pYtwoQtzm5lYO6gGuxFpfy5ZiYxVCPwVHVY1DobEmzqi5r7OHwNLEYbJjDkog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757923363; c=relaxed/simple; bh=yEm2bzoiP+h/01QXVowc2unEj0br7/I+82JQsjglZt4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iX2dMg+a2aiZHBAeW29gEnMZ0Fh6CPaAQ8LNanUmH9DNgabDjS54wzx6MP3WnOFzWgOzjt1kYb7dzIyBEaECkn9kpnAMC/ho6l4iuYNCmWvcXAITaYYxDbFKDArEArsHEsPVf2XuBbiqYYGKCxH1UeeMeyp8BpCBVipcDNaMPj0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uorC5lsH; arc=none smtp.client-ip=140.211.166.136 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uorC5lsH" Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 920DE6F8A1 for ; Mon, 15 Sep 2025 08:02:41 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.101 X-Spam-Level: Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yoUkjCGTPYcU for ; Mon, 15 Sep 2025 08:02:41 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=leon@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org D039D6F845 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D039D6F845 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=uorC5lsH Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) by smtp3.osuosl.org (Postfix) with ESMTPS id D039D6F845 for ; Mon, 15 Sep 2025 08:02:40 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 16635601F5; Mon, 15 Sep 2025 08:02:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C793C4AF09; Mon, 15 Sep 2025 08:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757923358; bh=yEm2bzoiP+h/01QXVowc2unEj0br7/I+82JQsjglZt4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uorC5lsHLES+BCYb8oEHYS7RGXDtLY0MYCZlFj/JgkPCIg7eVxjft9QeVc/O4+JiD VWYAyx/HXk8vuDOvoaIgZawtwa7duDJUL5RhO+mPaWfVAsoDevA1cGNVR4oNVVaZaj zP7GONv5P2+Dh5H5tX8dqDa7NKGy2bVK9xZdHmyGX74mM/HxaEDBkUF4rMo+8fdvIi 0j7rMpquFaNuK0jESLtzfC8vpVbd1j8L4pSt9q/vo1RNoqqVHG53783DBRKtDO21cx pMIX6YzQ0hTN2NMj4FI2o1D8ZWJ4dcq5cULVdz8VN2jb+34BuQKN9RANHzY56C9zpQ sYnvOFrD8+IyA== Date: Mon, 15 Sep 2025 11:02:32 +0300 From: Leon Romanovsky To: Mahanta Jambigi Cc: Kriish Sharma , alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com, wenjia@linux.ibm.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [PATCH] net/smc: replace strncpy with strscpy for ib_name Message-ID: <20250915080232.GA9353@unreal> References: <20250908180913.356632-1-kriish.sharma2006@gmail.com> <20250910100100.GM341237@unreal> <24ced585-1b7f-4577-9cb5-8d6e60ecb363@linux.ibm.com> <20250912090713.GV341237@unreal> <947756ad-f9aa-479f-b463-4c97ff23a936@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel-mentees@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <947756ad-f9aa-479f-b463-4c97ff23a936@linux.ibm.com> On Mon, Sep 15, 2025 at 12:24:16PM +0530, Mahanta Jambigi wrote: > On 12/09/25 2:37 pm, Leon Romanovsky wrote: > > On Fri, Sep 12, 2025 at 01:18:52PM +0530, Mahanta Jambigi wrote: > >> On 10/09/25 3:31 pm, Leon Romanovsky wrote: > >>>> --- a/net/smc/smc_pnet.c > >>>> +++ b/net/smc/smc_pnet.c > >>>> @@ -450,7 +450,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name, > >>>> return -ENOMEM; > >>>> new_pe->type = SMC_PNET_IB; > >>>> memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN); > >>>> - strncpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX); > >>>> + strscpy(new_pe->ib_name, ib_name); > >>> > >>> It is worth to mention that caching ib_name is wrong as IB/core provides > >>> IB device rename functionality. > >> > >> In our case we hit this code path where we pass *PCI_ID* > >> as the *ib_name* using *smc_pnet* tool(smc_pnet -a -D > >> ). I believe PCI_ID will not change, so caching it here is fine. > > > > If I remember, you are reporting that cached ib_name through netlink much later. > > > > The caching itself is not an issue, but incorrect reported name can be seen as > > a wrong thing to do. > > In what case we can see this incorrect reported name, could you please > elaborate. Did you open net/smc/smc_pnet.c? Everything that uses ib_name in that file is incorrect. >From glance look: 1. smc_pnet_find_ib() returns completely random results if device is renamed in parallel. 2. SMC_PNETID_GET returns wrong names. It returns cached name which doesn't exist anymore. IB devices have stable indexes in similar way to netdevice. The code should rely on it and not on the name. Thanks