Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread David Laight
From: Joe Perches > Sent: 27 August 2020 21:30 ... > Perhaps what's necessary is to find any > appropriate .show function and change > any use of strcpy/sprintf within those > function to some other name. > > For instance: > > drivers/isdn/mISDN/core.c-static ssize_t name_show(struct device

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread David Laight
From: Kees Cook > Sent: 27 August 2020 23:21 ... > > Agreed. This just makes me cringe. If the API design declares that when > a show() callback starts, buf has been allocated with PAGE_SIZE bytes, > then that's how the logic should proceed, and it should be using > scnprintf... > > show(...) {

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread David Laight
From: Joe Perches > Sent: 27 August 2020 17:59 > To: Alex Dewar ; Rasmus Villemoes > ; cocci > > Cc: Greg Kroah-Hartman ; Kees Cook > ; Gustavo A. R. > Silva ; accessrunner-gene...@lists.sourceforge.net; > linux-...@vger.kernel.org; > linux-ker...@vger.kernel.org > Subject: Re: [PATCH] usb:

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread Joe Perches
On Fri, 2020-08-28 at 01:10 -0700, Joe Perches wrote: > On Fri, 2020-08-28 at 00:58 -0700, Kees Cook wrote: > > On Thu, Aug 27, 2020 at 09:12:06PM -0700, Joe Perches wrote: > > > Perhaps something like the below with a sample conversion > > > that uses single and multiple sysfs_emit uses. > > > >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread Joe Perches
On Fri, 2020-08-28 at 00:58 -0700, Kees Cook wrote: > On Thu, Aug 27, 2020 at 09:12:06PM -0700, Joe Perches wrote: > > Perhaps something like the below with a sample conversion > > that uses single and multiple sysfs_emit uses. > > On quick review, I like it. :) > > > [...] > > +int

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-28 Thread Kees Cook
On Thu, Aug 27, 2020 at 09:12:06PM -0700, Joe Perches wrote: > Perhaps something like the below with a sample conversion > that uses single and multiple sysfs_emit uses. On quick review, I like it. :) > [...] > +int sysfs_emit(char *buf, char *pos, const char *fmt, ...) > +{ > + int len; > +

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 15:45 -0700, Joe Perches wrote: > On Thu, 2020-08-27 at 15:20 -0700, Kees Cook wrote: > > On Fri, Aug 28, 2020 at 12:01:34AM +0300, Denis Efremov wrote: > > > Just FYI, I've send an addition to the device_attr_show.cocci script[1] > > > to turn > > > simple cases of snprintf

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Fri, 2020-08-28 at 01:38 +0300, Denis Efremov wrote: > > This will match it (the difference is in the ';'): thanks. ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 15:20 -0700, Kees Cook wrote: > On Fri, Aug 28, 2020 at 12:01:34AM +0300, Denis Efremov wrote: > > Just FYI, I've send an addition to the device_attr_show.cocci script[1] to > > turn > > simple cases of snprintf (e.g. "%i") to sprintf. Looks like many developers > > would >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Denis Efremov
> > I tried: > @@ > identifier f_show =~ "^.*_show$"; This will miss this kind of functions: ./drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:1953:static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, ./drivers/gpu/drm/amd/amdgpu/df_v3_6.c:266:static

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 22:03 +, David Laight wrote: > From: Joe Perches > > Sent: 27 August 2020 21:30 > ... > > Perhaps what's necessary is to find any > > appropriate .show function and change > > any use of strcpy/sprintf within those > > function to some other name. > > > > For instance: >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Kees Cook
On Fri, Aug 28, 2020 at 12:01:34AM +0300, Denis Efremov wrote: > Just FYI, I've send an addition to the device_attr_show.cocci script[1] to > turn > simple cases of snprintf (e.g. "%i") to sprintf. Looks like many developers > would > like it more than changing snprintf to scnprintf. As for me,

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Kees Cook
On Thu, Aug 27, 2020 at 03:11:57PM -0700, Joe Perches wrote: > On Thu, 2020-08-27 at 22:03 +, David Laight wrote: > > From: Joe Perches > > > Sent: 27 August 2020 21:30 > > ... > > > Perhaps what's necessary is to find any > > > appropriate .show function and change > > > any use of

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 23:36 +0200, Julia Lawall wrote: > On Fri, 28 Aug 2020, Denis Efremov wrote: [] > Regarding current device_attr_show.cocci implementation, it detects the > functions > > by declaration: > > ssize_t any_name(struct device *dev, struct device_attribute *attr, char > > *buf) >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Julia Lawall
On Fri, 28 Aug 2020, Denis Efremov wrote: > Hi all, > > On 8/27/20 10:42 PM, Julia Lawall wrote: > > > > > > On Thu, 27 Aug 2020, Joe Perches wrote: > > > >> On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > >>> On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > On

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Julia Lawall
On Thu, 27 Aug 2020, Joe Perches wrote: > On Thu, 2020-08-27 at 21:42 +0200, Julia Lawall wrote: > > > > On Thu, 27 Aug 2020, Joe Perches wrote: > > > > > On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > > > > On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > > > > > On

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 13:29 -0700, Joe Perches wrote: > On Thu, 2020-08-27 at 21:42 +0200, Julia Lawall wrote: > > On Thu, 27 Aug 2020, Joe Perches wrote: > > > > > On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > > > > On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > > >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Denis Efremov
Hi all, On 8/27/20 10:42 PM, Julia Lawall wrote: > > > On Thu, 27 Aug 2020, Joe Perches wrote: > >> On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: >>> On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: On 27/08/2020 15.18, Alex Dewar wrote: > On Thu, Aug 27, 2020

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 21:42 +0200, Julia Lawall wrote: > > On Thu, 27 Aug 2020, Joe Perches wrote: > > > On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > > > On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > > > > On 27/08/2020 15.18, Alex Dewar wrote: > > > > > On Thu,

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Julia Lawall
On Thu, 27 Aug 2020, Joe Perches wrote: > On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > > On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > > > On 27/08/2020 15.18, Alex Dewar wrote: > > > > On Thu, Aug 27, 2020 at 09:15:37AM +0200, Greg Kroah-Hartman wrote: > > > >

Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs

2020-08-27 Thread Joe Perches
On Thu, 2020-08-27 at 15:48 +0100, Alex Dewar wrote: > On Thu, Aug 27, 2020 at 03:41:06PM +0200, Rasmus Villemoes wrote: > > On 27/08/2020 15.18, Alex Dewar wrote: > > > On Thu, Aug 27, 2020 at 09:15:37AM +0200, Greg Kroah-Hartman wrote: > > > > On Thu, Aug 27, 2020 at 08:42:06AM +0200, Rasmus