linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Dan Carpenter' <dan.carpenter@oracle.com>,
	Len Baker <len.baker@gmx.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Florian Schilhabel <florian.c.schilhabel@googlemail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Pavel Skripkin <paskripkin@gmail.com>,
	"linux-staging@lists.linux.dev" <linux-staging@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] staging/rtl8712: Remove all strcpy() uses in favor of strscpy()
Date: Mon, 19 Jul 2021 15:24:38 +0000	[thread overview]
Message-ID: <de94438319a84e0985b3ba0f5c00807b@AcuMS.aculab.com> (raw)
In-Reply-To: <20210719053747.GN1931@kadam>

From: Dan Carpenter
> Sent: 19 July 2021 06:38
...
> Not related to your patch but this code is bad.  What it does is the
> "ifname" can be set as a module parameter.  So instead of testing if it
> has been set, it uses the checking inside dev_alloc_name() to see if we
> can allocate what the user requested.  If not then set it to "wlan%d".
> If we cannot allocate what the user wants then we should return an
> error.
> 
> It should do:
> 
> 	if (ifname[0] == '\0')
> 		strscpy(ifname, "wlan%d", sizeof(ifname));
> 
> 	ret = dev_alloc_name(pnetdev, ifname);
> 	if (ret < 0) {
> 		dev_err(pnetdev, "allocating device name failed.\n");
> 		return NULL;
> 	}

I know only root can set module parameters, but having one
that contains a string used as a printf format seems
dangerous at best.

Isn't it best to let userspace rename the interfaces later on?

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  reply	other threads:[~2021-07-19 15:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 15:51 Len Baker
2021-07-19  5:37 ` Dan Carpenter
2021-07-19 15:24   ` David Laight [this message]
2021-07-21  8:06     ` Dan Carpenter
2021-07-23 15:15       ` Len Baker
2021-07-26  8:11         ` Dan Carpenter
2021-07-28 17:45           ` Len Baker

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=de94438319a84e0985b3ba0f5c00807b@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dan.carpenter@oracle.com \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.baker@gmx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --subject='RE: [PATCH] staging/rtl8712: Remove all strcpy() uses in favor of strscpy()' \
    /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

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).