Re: [Cocci] Checking the usage of a SmPL disjunction within a sizeof()

2020-08-28 Thread Julia Lawall
T; > @@ > *sizeof( \( T \| *(instance->array) \) ) > No, you can't compbine a type and an expression in a disjunction. julia > > elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci > sizeof-test-20200828.cocci > … > minus: parse error: > File "sizeof-te

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

[Cocci] Checking the usage of a SmPL disjunction within a sizeof()

2020-08-28 Thread Markus Elfring
obe> spatch --parse-cocci sizeof-test-20200828.cocci … minus: parse error: File "sizeof-test-20200828.cocci", line 5, column 17, charpos = 66 around = '*', whole content = *sizeof( \( T \| *(instance->array) \) ) May I expect that such a SmPL disjunction should also wor

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:

[Cocci] [RFC PATCH] coccinelle: api: add flex_array_size.cocci script

2020-08-28 Thread Denis Efremov
Suggest flex_array_size() wrapper to compute the size of a flexible array member in a structure. The macro additionally checks for integer overflows. The cocci script intentionally skips cases where count argument is not a member of a structure because this introduce false positives. Cc: Gustavo

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; > +