mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Amirhossein Hajimohammadi <info@hajimohammadi.net>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] staging: rtl8723bs: stop overreading monitor interface name
Date: Thu, 1 Oct 2026 20:47:00 +0300	[thread overview]
Message-ID: <ar6clK3N4by6EN0O@stanley.mountain> (raw)
In-Reply-To: <ar4vH3F5lLFijgTU@stanley.mountain>

On Thu, Oct 01, 2026 at 12:59:59PM +0300, Dan Carpenter wrote:
> > > 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?
> 
> This seems like a legit patch to me, although it's probably AI generated.
> 
> net/wireless/nl80211.c
>   5199          wdev = rdev_add_virtual_intf(rdev,
>   5200                                  nla_data(info->attrs[NL80211_ATTR_IFNAME]),
>                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This means that it is a string up to IFNAMSIZ (16) bytes long counting
> the NUL terminator, but it could be less.  So doing a memcpy() is a
> read overflow.
> 
>   5201                                  NET_NAME_USER, type, &params);
> 

I tasked ChatGPT with writing a Smatch check for this and it noticed
that the "+ 1" in "IFNAMSIZ + 1" is wrong as well.  "name" can only
be 16 characters long (counting the NUL terminator).

drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2164 rtw_cfg80211_add_monitor_if()
warn: buffer 'name' too small user_len=1-16 for 17 byte copy

regards,
dan carpenter

      reply	other threads:[~2026-10-01 17:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 15:48 Amirhossein Hajimohammadi
2026-09-29 16:05 ` Greg KH
2026-09-29 17:28   ` Amirhossein Hajimohammadi
2026-10-01  9:59   ` Dan Carpenter
2026-10-01 17:47     ` Dan Carpenter [this message]

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=ar6clK3N4by6EN0O@stanley.mountain \
    --to=error27@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@hajimohammadi.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®