netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Mahanta Jambigi <mjambigi@linux.ibm.com>
Cc: Kriish Sharma <kriish.sharma2006@gmail.com>,
	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
Date: Mon, 15 Sep 2025 11:02:32 +0300	[thread overview]
Message-ID: <20250915080232.GA9353@unreal> (raw)
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 <pnet_name> -D
> >> <PCI_ID>). 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

  reply	other threads:[~2025-09-15  8:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08 18:09 [PATCH] net/smc: replace strncpy with strscpy for ib_name Kriish Sharma
2025-09-09  3:23 ` Dust Li
2025-09-10 10:01 ` Leon Romanovsky
2025-09-12  7:48   ` Mahanta Jambigi
2025-09-12  9:07     ` Leon Romanovsky
2025-09-15  6:54       ` Mahanta Jambigi
2025-09-15  8:02         ` Leon Romanovsky [this message]
2025-09-15  9:44           ` Mahanta Jambigi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250915080232.GA9353@unreal \
    --to=leon@kernel.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=kriish.sharma2006@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjambigi@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tonylu@linux.alibaba.com \
    --cc=wenjia@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).