Re: [Cocci] [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive()

2020-06-15 Thread Dan Carpenter
On Mon, Apr 13, 2020 at 05:15:49PM -0400, Waiman Long wrote: > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 23c7500eea7d..c08bc7eb20bd 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -1707,17 +1707,17 @@ void *krealloc(const void *p, size_t new_size, gfp_t > flags) >

Re: [Cocci] [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive()

2020-06-15 Thread Waiman Long
On 6/15/20 2:07 PM, Dan Carpenter wrote: On Mon, Apr 13, 2020 at 05:15:49PM -0400, Waiman Long wrote: diff --git a/mm/slab_common.c b/mm/slab_common.c index 23c7500eea7d..c08bc7eb20bd 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1707,17 +1707,17 @@ void *krealloc(const void *p,

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Gustavo A. R. Silva
On 6/15/20 13:35, Denis Efremov wrote: > > > On 6/15/20 9:23 PM, Kees Cook wrote: >> On Mon, Jun 15, 2020 at 01:20:45PM +0300, Denis Efremov wrote: >>> Detect an opencoded expression that is used before or after >>> array_size()/array3_size()/struct_size() to compute the same size. >>> >>>

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Denis Efremov
On 6/15/20 9:23 PM, Kees Cook wrote: > On Mon, Jun 15, 2020 at 01:20:45PM +0300, Denis Efremov wrote: >> Detect an opencoded expression that is used before or after >> array_size()/array3_size()/struct_size() to compute the same size. >> >> Cc: Kees Cook >> Signed-off-by: Denis Efremov > >

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Kees Cook
On Mon, Jun 15, 2020 at 01:20:45PM +0300, Denis Efremov wrote: > Detect an opencoded expression that is used before or after > array_size()/array3_size()/struct_size() to compute the same size. > > Cc: Kees Cook > Signed-off-by: Denis Efremov Oh, very cool! How much does this find currently?

Re: [Cocci] coccinelle: api: add device_attr_show script

2020-06-15 Thread Markus Elfring
>> +virtual report, org, context, patch >> >> Is such a SmPL code variant more succinct? > > This doens't matter. Can less duplicate code be a bit nicer? >>> +ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) >>> +{ >>> + <... >>> +* return snprintf@p(...); >>> +

Re: [Cocci] [PATCH] coccinelle: api: add device_attr_show script

2020-06-15 Thread Julia Lawall
On Mon, 15 Jun 2020, Markus Elfring wrote: > > +// Confidence: High > > Would you like to add any suggestion for a possible patch message? > > > … > > +virtual report > > +virtual org > > +virtual context > > +virtual patch > > +virtual report, org, context, patch > > Is such a SmPL code

Re: [Cocci] [PATCH] coccinelle: api: add device_attr_show script

2020-06-15 Thread Markus Elfring
> +// Confidence: High Would you like to add any suggestion for a possible patch message? … > +virtual report > +virtual org > +virtual context > +virtual patch +virtual report, org, context, patch Is such a SmPL code variant more succinct? … > +ssize_t show(struct device *dev, struct

Re: [Cocci] [PATCH] coccinelle: api: add kzfree script

2020-06-15 Thread Denis Efremov
On 6/15/20 3:03 PM, Dan Carpenter wrote: > On Sun, Jun 14, 2020 at 10:42:54PM +0300, Denis Efremov wrote: >> On 6/4/20 7:27 PM, Joe Perches wrote: >>> On Thu, 2020-06-04 at 17:08 +0300, Denis Efremov wrote: Check for memset() with 0 followed by kfree(). >>> >>> Perhaps those uses should be

Re: [Cocci] [PATCH v3] coccinelle: api: add kzfree script

2020-06-15 Thread Markus Elfring
… > +virtual context > +virtual patch > +virtual org > +virtual report +virtual context, patch, org, report Is such a SmPL code variant more succinct? … > +if (...) > + \(memset@ok\|memzero_explicit@ok\)(...); Would you like to tolerate any extra source code around such a function call in an

[Cocci] [PATCH] coccinelle: api: add device_attr_show script

2020-06-15 Thread Denis Efremov
According to the documentation[1] show() methods of device attributes should return the number of bytes printed into the buffer. This is the return value of scnprintf(). show() must not use snprintf() when formatting the value to be returned to user space. snprintf() returns the length the

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-15 Thread Markus Elfring
I suggest to avoid a typo in the previous patch subject. … > +virtual context > +virtual report > +virtual org +virtual context, report, org Is such a SmPL code variant more succinct? … > +@as_next@ > +expression subE1 <= as.E1; > +expression as.E1; … I propose to reduce the repetition of

Re: [Cocci] [PATCH] coccinelle: api: add kzfree script

2020-06-15 Thread Dan Carpenter
On Sun, Jun 14, 2020 at 10:42:54PM +0300, Denis Efremov wrote: > On 6/4/20 7:27 PM, Joe Perches wrote: > > On Thu, 2020-06-04 at 17:08 +0300, Denis Efremov wrote: > >> Check for memset() with 0 followed by kfree(). > > > > Perhaps those uses should be memzero_explicit or kvfree_sensitive. > > >

[Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Denis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Cc: Kees Cook Signed-off-by: Denis Efremov --- scripts/coccinelle/misc/array_size_dup.cocci | 347 +++ 1 file changed, 347 insertions(+) create mode