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

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

2020-06-14 Thread Joe Perches
On Sun, 2020-06-14 at 22:42 +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. > > > Is it

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

2020-06-14 Thread Denis Efremov
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. > Is it safe to suggest to use kzfree instead of memzero_explicit && kfree? Or

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

2020-06-04 Thread Joe Perches
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 mailing list Cocci@systeme.lip6.fr

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

2020-06-04 Thread Joe Perches
On Thu, 2020-06-04 at 20:30 +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. > >

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

2020-06-04 Thread Denis Efremov
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. Thanks, I will add memzero_explicit(). However, I can't find

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

2020-06-04 Thread Denis Efremov
> Could you send an example of some C code on which the result is not > suitable? I've updated the pattern to handle false positives: @ifok@ position p; expression *E; @@ ( if (...) { ... memset(E, 0, ...)@p; ... } | if (...) { ... } else { ... memset(E, 0,

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

2020-06-04 Thread Julia Lawall
On Thu, 4 Jun 2020, Markus Elfring wrote: > > Check for memset() with 0 followed by kfree(). > > I suggest to simplify the SmPL code a bit like the following. > > > > +virtual context > > +virtual org > > +virtual report > > +virtual patch > > +virtual context, org, report, patch This is

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

2020-06-04 Thread Julia Lawall
On Thu, 4 Jun 2020, Denis Efremov wrote: > > > On 6/4/20 5:15 PM, Julia Lawall wrote: > > Did you try ... here but find that some subexpressions of E could be > > modified in between? > > Yes, I tried to use "... when != E = E1 when != " and results were bad. > Now, I've tried forall and when

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

2020-06-04 Thread Denis Efremov
On 6/4/20 5:15 PM, Julia Lawall wrote: > Did you try ... here but find that some subexpressions of E could be > modified in between? Yes, I tried to use "... when != E = E1 when != " and results were bad. Now, I've tried forall and when strict. Here are examples: // forall added // Works

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

2020-06-04 Thread Markus Elfring
> Check for memset() with 0 followed by kfree(). I suggest to simplify the SmPL code a bit like the following. > +virtual context > +virtual org > +virtual report > +virtual patch +virtual context, org, report, patch … > +@@ > + > +( > +* memset(E, 0, ...); > +| > +* memset(E, '\0', ...); >

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

2020-06-04 Thread Julia Lawall
On Thu, 4 Jun 2020, Denis Efremov wrote: > Check for memset() with 0 followed by kfree(). > > Signed-off-by: Denis Efremov > --- > Patches: > 1. kzfree in drivers/w1 https://lkml.org/lkml/2020/6/4/438 > 2. kzfree in drivers/iommu/ https://lkml.org/lkml/2020/6/4/421 > 3. kzfree in

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

2020-06-04 Thread Denis Efremov
Check for memset() with 0 followed by kfree(). Signed-off-by: Denis Efremov --- Patches: 1. kzfree in drivers/w1 https://lkml.org/lkml/2020/6/4/438 2. kzfree in drivers/iommu/ https://lkml.org/lkml/2020/6/4/421 3. kzfree in drivers/scsi/ https://lkml.org/lkml/2020/6/4/442