lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] staging/rtl8712: Remove all strcpy() uses in favor of strscpy()
Date
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)

\
 
 \ /
  Last update: 2021-07-19 17:47    [W:0.076 / U:1.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site