public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: I Hsin Cheng <richard120310@gmail.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev
Subject: Re: [RFC PATCH] wifi: mac80211: Replace strncpy() with strscpy()
Date: Thu, 27 Mar 2025 22:24:52 +0800	[thread overview]
Message-ID: <Z-VftFBpDBT6l1f6@vaxr-BM6660-BM6360> (raw)
In-Reply-To: <20250327141108.182585-1-richard120310@gmail.com>

On Thu, Mar 27, 2025 at 10:11:08PM +0800, I Hsin Cheng wrote:
> The name of vif which is "vif_name" should be NULL-terminated to be a
> valid string, however "strncpy()" doesn't guarantee that. Replace it
> with "strscpy()" to make sure the content within "vif_name" is
> NULL-terminated.
> 
> Link: https://github.com/KSPP/linux/issues/90
> Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
> ---
>  net/mac80211/trace.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
> index 72fad8ea8bb9..37f5b1c87709 100644
> --- a/net/mac80211/trace.h
> +++ b/net/mac80211/trace.h
> @@ -1725,7 +1725,7 @@ TRACE_EVENT(drv_switch_vif_chanctx,
>  				SWITCH_ENTRY_ASSIGN(vif.vif_type, vif->type);
>  				SWITCH_ENTRY_ASSIGN(vif.p2p, vif->p2p);
>  				SWITCH_ENTRY_ASSIGN(link_id, link_conf->link_id);
> -				strncpy(local_vifs[i].vif.vif_name,
> +				strscpy(local_vifs[i].vif.vif_name,
>  					sdata->name,
>  					sizeof(local_vifs[i].vif.vif_name));
>  				SWITCH_ENTRY_ASSIGN(old_chandef.control_freq,
> -- 
> 2.43.0
>

> The name of vif which is "vif_name" should be NULL-terminated to be a
Or maybe it should be trailing NULL-padding when sources is shorter, if
it's the case we should consider strscpy_pad() or other alternatives.

Let me know if there's any mistakes or tests I can help to validate,
thanks!

Best regards,
I Hsin Cheng

  reply	other threads:[~2025-03-27 14:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27 14:11 [RFC PATCH] wifi: mac80211: Replace strncpy() with strscpy() I Hsin Cheng
2025-03-27 14:24 ` I Hsin Cheng [this message]
2025-03-28  9:26 ` Johannes Berg

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=Z-VftFBpDBT6l1f6@vaxr-BM6660-BM6360 \
    --to=richard120310@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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