Re: [PATCH v3] staging: rtl8723bs: stop overreading monitor interface name

From: Greg KH

Date: Tue Sep 29 2026 - 12:05:49 EST


On Tue, Sep 29, 2026 at 07:18:11PM +0330, Amirhossein Hajimohammadi wrote:
> From: AmirHossein HajiMohammadi <info@xxxxxxxxxxxxxxxxx>
>
> cfg80211 passes a NUL-terminated interface name. memcpy() always reads
> IFNAMSIZ + 1 bytes, even when the caller supplied a shorter string.
>
> Use strscpy() to stop at the terminator and bound the write to the
> destination buffer.
>
> Signed-off-by: AmirHossein HajiMohammadi <info@xxxxxxxxxxxxxxxxx>
> ---
> Changes in v3:
> - Add an explicit From header matching the Signed-off-by identity.
>
> Changes in v2:
> - Send the patch inline instead of as a MIME attachment.
>
> drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index 4416d0ec1..8f5032844 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -2158,7 +2158,7 @@ static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, str
> goto out;
>
> *ndev = pwdev_priv->pmon_ndev = mon_ndev;
> - memcpy(pwdev_priv->ifname_mon, name, IFNAMSIZ + 1);
> + strscpy(pwdev_priv->ifname_mon, name);

But we are replacing str*() calls in the kernel with memcpy() calls
where it can happen, so why go backwards here?

What caused you to notice this change is needed? Have you measured a
speed up in throughput with this change applied? How was it tested?

thanks,

greg k-h