public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: James <bold.zone2373@fastmail.com>
To: "Mahanta Jambigi" <mjambigi@linux.ibm.com>,
	alibuda@linux.alibaba.com, "Dust Li" <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, "Simon Horman" <horms@kernel.org>,
	"Shuah Khan" <skhan@linuxfoundation.org>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH v2] net/smc: Replace use of strncpy on NUL-terminated string with strscpy
Date: Tue, 02 Sep 2025 00:12:22 -0700	[thread overview]
Message-ID: <27d1804c-27c4-488f-9f35-1913a7f7015f@app.fastmail.com> (raw)
In-Reply-To: <7bd60e6d-4b33-4a04-998b-0be163a6fdb0@linux.ibm.com>



On Mon, Sep 1, 2025, at 11:40 PM, Mahanta Jambigi wrote:
> On 01/09/25 8:34 am, James Flowers wrote:
>> strncpy is deprecated for use on NUL-terminated strings, as indicated in
>> Documentation/process/deprecated.rst. strncpy NUL-pads the destination
>> buffer and doesn't guarantee the destination buffer will be NUL
>> terminated.
>> 
>> Signed-off-by: James Flowers <bold.zone2373@fastmail.com>
>> ---
>> V1 -> V2: Replaced with two argument version of strscpy
>> Note: this has only been compile tested.
>> 
>>  net/smc/smc_pnet.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
>> index 76ad29e31d60..b90337f86e83 100644
>> --- 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);
>
> I tested your changes by creating a Software PNET ID using *smc_pnet*
> tool & it works fine. Your changes are similar to ae2402b(net/smc:
> replace strncpy with strscpy) commit.
>
> Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
>
>>  	new_pe->ib_port = ib_port;
>>  
>>  	new_ibdev = true;

Thank you for doing that test, Mahanta. Thanks to all who have reviewed so far.

Best regards,
James Flowers

  reply	other threads:[~2025-09-02  7:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01  3:04 [PATCH v2] net/smc: Replace use of strncpy on NUL-terminated string with strscpy James Flowers
2025-09-01 16:03 ` Simon Horman
2025-09-02  4:09 ` Dust Li
2025-09-02  6:40 ` Mahanta Jambigi
2025-09-02  7:12   ` James [this message]
2025-09-02 23:00 ` patchwork-bot+netdevbpf

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=27d1804c-27c4-488f-9f35-1913a7f7015f@app.fastmail.com \
    --to=bold.zone2373@fastmail.com \
    --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=kuba@kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --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