Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses

2018-03-31 Thread Julia Lawall


On Sat, 31 Mar 2018, Varsha Rao wrote:

> On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> > On Thu, 29 Mar 2018, Varsha Rao wrote:
> >
> >> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >> >
> >> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> >> > > This patch fixes the clang warning of extraneous parentheses, with the
> >> > > following coccinelle script.
> >> > >
> >> > > @@
> >> > > identifier i;
> >> > > constant c;
> >> > > @@
> >> > > (
> >> > > -((i == c))
> >> > > +i == c
> >> > > >
> >> > >
> >> > > -((i <= c))
> >> > > +i <= c
> >> >
> >> > Why just the "==" and "<=" cases?
> >> > Why not "<", ">" and ">=" too?
> >> >
> >> > Why not expression instead of constant?
> >>
> >> Initially I had the other cases too and used expression instead of
> >> constant. But the results included only "==" and "<=" cases with
> >> constant. Along with one false positive case.
> >>
> >> --- a/drivers/crypto/cavium/zip/zip_main.c
> >> +++ b/drivers/crypto/cavium/zip/zip_main.c
> >> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
> >>   */
> >>  struct zip_device *zip_get_device(int node)
> >>  {
> >> -if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> >> +if (node < MAX_ZIP_DEVICES && node >= 0)
> >
> > Why is it a false positive?
>
> The parentheses around multiple expressions in if statement is not
> considered extra, right?

< and >= should bind tighter than &&.  But perhaps one could fine the
original code to be more readable.

julia


Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses

2018-03-31 Thread Julia Lawall


On Thu, 29 Mar 2018, Varsha Rao wrote:

> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > >
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > >
> > >
> > > -((i <= c))
> > > +i <= c
> >
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> >
> > Why not expression instead of constant?
>
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
>
> --- a/drivers/crypto/cavium/zip/zip_main.c
> +++ b/drivers/crypto/cavium/zip/zip_main.c
> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>   */
>  struct zip_device *zip_get_device(int node)
>  {
> -if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> +if (node < MAX_ZIP_DEVICES && node >= 0)

Why is it a false positive?

julia

>  return zip_dev[node];
>
>  zip_err("ZIP device not found for node id %d\n", node);
>
> I checked if there was any case of extra parentheses around relational
> operators left, but there were none. Hence, in the script I included
> only the cases present in the result.
>
> Thanks,
> Varsha
> ___
> Cocci mailing list
> co...@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>


Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses

2018-03-31 Thread Julia Lawall


On Fri, 30 Mar 2018, Joe Perches wrote:

> On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> > On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > >
> > > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > > This patch fixes the clang warning of extraneous parentheses, with the
> > > > following coccinelle script.
> > > >
> > > > @@
> > > > identifier i;
> > > > constant c;
> > > > @@
> > > > (
> > > > -((i == c))
> > > > +i == c
> > > > >
> > > >
> > > > -((i <= c))
> > > > +i <= c
> > >
> > > Why just the "==" and "<=" cases?
> > > Why not "<", ">" and ">=" too?
> > >
> > > Why not expression instead of constant?
> >
> > Initially I had the other cases too and used expression instead of
> > constant. But the results included only "==" and "<=" cases with
> > constant. Along with one false positive case.
> hmm
> Perhaps you should use something like this?
> @@
> identifier i;
> constant c;
> @@
>
> -(
> \(i == c\|i <= c\|i < c\|i >= c\|i > c\)
> -)

This is not safe with respect to !.  The following seems to address this
problem:

@@
identifier i;
constant c;
expression e;
@@

(
!(e)
|
-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)
)

julia


Re: [PATCH v11 crypto 01/12] tls: support for Inline tls record (fwd)

2018-03-18 Thread Julia Lawall

ctx is dereferenced on line 258 but has been freed on line 229.

julia

-- Forwarded message --
Date: Sun, 18 Mar 2018 18:05:25 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH v11 crypto 01/12] tls: support for Inline tls record

CC: kbuild-...@01.org
In-Reply-To: <1521214661-28928-1-git-send-email-atul.gu...@chelsio.com>
References: <1521214661-28928-1-git-send-email-atul.gu...@chelsio.com>
TO: Atul Gupta <atul.gu...@chelsio.com>
CC: davejwat...@fb.com, da...@davemloft.net, herb...@gondor.apana.org.au, 
s...@queasysnail.net, sbri...@redhat.com, linux-crypto@vger.kernel.org, 
net...@vger.kernel.org, ganes...@chelsio.com
CC: s...@queasysnail.net, sbri...@redhat.com, linux-crypto@vger.kernel.org, 
net...@vger.kernel.org, ganes...@chelsio.com

Hi Atul,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.16-rc4]
[cannot apply to next-20180316]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Atul-Gupta/tls-support-for-Inline-tls-record/20180318-162840
:: branch date: 2 hours ago
:: commit date: 2 hours ago

>> net/tls/tls_main.c:258:5-8: ERROR: reference preceded by free on line 229

# 
https://github.com/0day-ci/linux/commit/be47378786b9d9874dfc3ab57504565275c7b3ff
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout be47378786b9d9874dfc3ab57504565275c7b3ff
vim +258 net/tls/tls_main.c

3c4d75591 Dave Watson   2017-06-14  218
3c4d75591 Dave Watson   2017-06-14  219  static void tls_sk_proto_close(struct 
sock *sk, long timeout)
3c4d75591 Dave Watson   2017-06-14  220  {
3c4d75591 Dave Watson   2017-06-14  221 struct tls_context *ctx = 
tls_get_ctx(sk);
3c4d75591 Dave Watson   2017-06-14  222 long timeo = sock_sndtimeo(sk, 
0);
3c4d75591 Dave Watson   2017-06-14  223 void (*sk_proto_close)(struct 
sock *sk, long timeout);
3c4d75591 Dave Watson   2017-06-14  224
3c4d75591 Dave Watson   2017-06-14  225 lock_sock(sk);
ff45d820a Ilya Lesokhin 2017-11-13  226 sk_proto_close = 
ctx->sk_proto_close;
ff45d820a Ilya Lesokhin 2017-11-13  227
ff45d820a Ilya Lesokhin 2017-11-13  228 if (ctx->tx_conf == 
TLS_BASE_TX) {
ff45d820a Ilya Lesokhin 2017-11-13 @229 kfree(ctx);
ff45d820a Ilya Lesokhin 2017-11-13  230 goto skip_tx_cleanup;
ff45d820a Ilya Lesokhin 2017-11-13  231 }
3c4d75591 Dave Watson   2017-06-14  232
3c4d75591 Dave Watson   2017-06-14  233 if 
(!tls_complete_pending_work(sk, ctx, 0, ))
3c4d75591 Dave Watson   2017-06-14  234 
tls_handle_open_record(sk, 0);
3c4d75591 Dave Watson   2017-06-14  235
3c4d75591 Dave Watson   2017-06-14  236 if (ctx->partially_sent_record) 
{
3c4d75591 Dave Watson   2017-06-14  237 struct scatterlist *sg 
= ctx->partially_sent_record;
3c4d75591 Dave Watson   2017-06-14  238
3c4d75591 Dave Watson   2017-06-14  239 while (1) {
3c4d75591 Dave Watson   2017-06-14  240 
put_page(sg_page(sg));
3c4d75591 Dave Watson   2017-06-14  241 
sk_mem_uncharge(sk, sg->length);
3c4d75591 Dave Watson   2017-06-14  242
3c4d75591 Dave Watson   2017-06-14  243 if 
(sg_is_last(sg))
3c4d75591 Dave Watson   2017-06-14  244 break;
3c4d75591 Dave Watson   2017-06-14  245 sg++;
3c4d75591 Dave Watson   2017-06-14  246 }
3c4d75591 Dave Watson   2017-06-14  247 }
ff45d820a Ilya Lesokhin 2017-11-13  248
3c4d75591 Dave Watson   2017-06-14  249 kfree(ctx->rec_seq);
3c4d75591 Dave Watson   2017-06-14  250 kfree(ctx->iv);
3c4d75591 Dave Watson   2017-06-14  251
ff45d820a Ilya Lesokhin 2017-11-13  252 if (ctx->tx_conf == TLS_SW_TX)
ff45d820a Ilya Lesokhin 2017-11-13  253 
tls_sw_free_tx_resources(sk);
3c4d75591 Dave Watson   2017-06-14  254
ff45d820a Ilya Lesokhin 2017-11-13  255  skip_tx_cleanup:
3c4d75591 Dave Watson   2017-06-14  256 release_sock(sk);
3c4d75591 Dave Watson   2017-06-14  257 sk_proto_close(sk, timeout);
be4737878 Atul Gupta2018-03-16 @258 if (ctx->tx_conf == 
TLS_HW_RECORD)
be4737878 Atul Gupta2018-03-16  259 kfree(ctx);
3c4d75591 Dave Watson   2017-06-14  260  }
3c4d75591 Dave Watson   2017-06-14  261

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH v11 crypto 12/12] crypto: chtls - Makefile Kconfig (fwd)

2018-03-18 Thread Julia Lawall
Please check the indentation on line 1655.

thanks,
julia

-- Forwarded message --
Date: Sun, 18 Mar 2018 18:15:36 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH v11 crypto 12/12] crypto: chtls - Makefile Kconfig

CC: kbuild-...@01.org
In-Reply-To: <1521214661-28928-12-git-send-email-atul.gu...@chelsio.com>
References: <1521214661-28928-12-git-send-email-atul.gu...@chelsio.com>
TO: Atul Gupta <atul.gu...@chelsio.com>
CC: davejwat...@fb.com, da...@davemloft.net, herb...@gondor.apana.org.au
CC: s...@queasysnail.net, sbri...@redhat.com, linux-crypto@vger.kernel.org, 
net...@vger.kernel.org, ganes...@chelsio.com

Hi Atul,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16-rc4]
[cannot apply to next-20180316]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Atul-Gupta/tls-support-for-Inline-tls-record/20180318-162840
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
:: branch date: 2 hours ago
:: commit date: 2 hours ago

All error/warnings (new ones prefixed by >>):

   drivers/crypto/chelsio/chtls/chtls_io.c: In function 'chtls_expansion_size':
>> drivers/crypto/chelsio/chtls/chtls_io.c:457:2: error: expected ',' or ';' 
>> before 'int'
 int expnsize, frcn, fraglast, fragsize;
 ^~~
>> drivers/crypto/chelsio/chtls/chtls_io.c:461:3: error: 'fragsize' undeclared 
>> (first use in this function); did you mean 'ivs_size'?
  fragsize = hws->mfs;
  ^~~~
  ivs_size
   drivers/crypto/chelsio/chtls/chtls_io.c:461:3: note: each undeclared 
identifier is reported only once for each function it appears in
>> drivers/crypto/chelsio/chtls/chtls_io.c:465:4: error: 'frcnt' undeclared 
>> (first use in this function); did you mean 'pducnt'?
   frcnt = (data_len / fragsize);
   ^
   pducnt
>> drivers/crypto/chelsio/chtls/chtls_io.c:468:4: error: 'expnsize' undeclared 
>> (first use in this function); did you mean 'fragsize'?
   expnsize =  frcnt * expppdu;
   ^~~~
   fragsize
>> drivers/crypto/chelsio/chtls/chtls_io.c:480:4: error: 'fraglast' undeclared 
>> (first use in this function); did you mean 'rb_last'?
   fraglast = data_len % fragsize;
   ^~~~
   rb_last
   drivers/crypto/chelsio/chtls/chtls_io.c: In function 'peekmsg':
>> drivers/crypto/chelsio/chtls/chtls_io.c:1653:5: warning: this 'if' clause 
>> does not guard... [-Wmisleading-indentation]
if (!copied)
^~
   drivers/crypto/chelsio/chtls/chtls_io.c:1655:6: note: ...this statement, but 
the latter is misleadingly indented as if it were guarded by the 'if'
 break;
 ^
   drivers/crypto/chelsio/chtls/chtls_io.c: In function 'chtls_expansion_size':
>> drivers/crypto/chelsio/chtls/chtls_io.c:492:1: warning: control reaches end 
>> of non-void function [-Wreturn-type]
}
^

coccinelle warnings: (new ones prefixed by >>)

>> drivers/crypto/chelsio/chtls/chtls_io.c:1654:5-22: code aligned with 
>> following code on line 1655

# 
https://github.com/0day-ci/linux/commit/635907fe348f84b525d7ce16ae8f2a9b82c631e3
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 635907fe348f84b525d7ce16ae8f2a9b82c631e3
vim +1654 drivers/crypto/chelsio/chtls/chtls_io.c

8ae18d74 Atul Gupta 2018-03-16  1542
8ae18d74 Atul Gupta 2018-03-16  1543  /*
8ae18d74 Atul Gupta 2018-03-16  1544   * Peek at data in a socket's receive 
buffer.
8ae18d74 Atul Gupta 2018-03-16  1545   */
8ae18d74 Atul Gupta 2018-03-16  1546  static int peekmsg(struct sock *sk, 
struct msghdr *msg,
8ae18d74 Atul Gupta 2018-03-16  1547   size_t len, int nonblock, 
int flags)
8ae18d74 Atul Gupta 2018-03-16  1548  {
8ae18d74 Atul Gupta 2018-03-16  1549struct tcp_sock *tp = tcp_sk(sk);
8ae18d74 Atul Gupta 2018-03-16  1550struct sk_buff *skb;
8ae18d74 Atul Gupta 2018-03-16  1551u32 peek_seq, offset;
8ae18d74 Atul Gupta 2018-03-16  1552int copied = 0;
8ae18d74 Atul Gupta 2018-03-16  1553size_t avail;  /* amount of 
available data in current skb */
8ae18d74 Atul Gupta 2018-03-16  1554long timeo;
8ae18d74 Atul Gupta 2018-03-16  1555
8ae18d74 Atul Gupta 2018-03-16  1556lock_sock(sk);
8ae18d74 Atul Gupta 2018-03-16  1557timeo = sock_rcvtimeo(sk, nonblock);
8ae18d74 Atul Gupta 2018-03-16  1558peek_seq = tp->copied_seq;
8ae18d74 Atul Gupta 2018-03-16  1559
8ae18d74 Atul Gupta 2018-03-16  1560do {
8ae18d74 Atul Gupta 2018-03-16  1561if (unlikely(tp->urg_data && 
tp->urg_seq == peek_se

Re: [PATCH] crypto: Use zeroing memory allocator instead of allocator/memset

2017-12-31 Thread Julia Lawall


On Sun, 31 Dec 2017, Himanshu Jha wrote:

> On Sun, Dec 31, 2017 at 07:46:09AM -0800, Joe Perches wrote:
> > On Sun, 2017-12-31 at 17:54 +0530, Himanshu Jha wrote:
> > > Use dma_zalloc_coherent for allocating zeroed
> > > memory and remove unnecessary memset function.
> > >
> > > Done using Coccinelle.
> > > Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> >
> > I thought you were going to change this tag to
> > not use the "-by:" form and use something else
> > like "generated-using:" or "created-with:".
>
> Thanks for pointing that out!
>
> I was going to ask this to Julia for the appropriate tag, but it slipped
> my mind. In future I will definitely choose more appropriate tag
> on the Coccinelle patches.
>
> Just to give an insight of the problem to everyone :
>
> While running checkpatch on patches involving the above Generated-by
> tag, which is generally used to specify the cocci script used,
> checkpatch prompts the below warning and error :
>
> WARNING: Non-standard signature: Generated-by:
> #10:
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
>
> ERROR: Unrecognized email address:
> 'scripts/coccinelle/api/alloc/kzalloc-simple.cocci'
>
> Joe suggested to not use the "-by:" form since it should be reserved
> for actual people's names and email addresses.
> And if you use other tag than the "-by:" tag, then there is no
> error/warning produced.

kbuild uses eg

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

julia


>
> Thanks
> Himanshu Jha
>


Re: [Outreachy kernel] [PATCH v2] Staging: ccree: Use kcalloc instead of kzalloc

2017-09-14 Thread Julia Lawall


On Thu, 14 Sep 2017, Srishti Sharma wrote:

> Use kcalloc instead of kzalloc to check for overflow before
> multiplication. Done using the following semantic patch by
> coccinelle.
>
> http://coccinelle.lip6.fr/rules/kzalloc.cocci
>
> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>

Acked-by: Julia Lawall <julia.law...@lip6.fr>

> ---
> Changes in v2:
>  - eliminate parentheses around the first argument
>
>  drivers/staging/ccree/ssi_sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/ccree/ssi_sysfs.c 
> b/drivers/staging/ccree/ssi_sysfs.c
> index 0655658..f7e0c502 100644
> --- a/drivers/staging/ccree/ssi_sysfs.c
> +++ b/drivers/staging/ccree/ssi_sysfs.c
> @@ -376,7 +376,7 @@ static int sys_init_dir(struct sys_dir *sys_dir, struct 
> ssi_drvdata *drvdata,
>   return -ENOMEM;
>   /* allocate memory for directory's attributes list */
>   sys_dir->sys_dir_attr_list =
> - kzalloc(sizeof(struct attribute *) * (num_of_attrs + 1),
> + kcalloc(num_of_attrs + 1, sizeof(struct attribute *),
>   GFP_KERNEL);
>
>   if (!(sys_dir->sys_dir_attr_list)) {
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1505393293-5941-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH] Staging: ccree: Use kcalloc instead of kzalloc

2017-09-14 Thread Julia Lawall


On Thu, 14 Sep 2017, Srishti Sharma wrote:

> Use kcalloc instead of kzalloc to check for overflow before
> multiplication. Done using the following semantic patch by
> coccinelle.
>
> http://coccinelle.lip6.fr/rules/kzalloc.cocci
>
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/ccree/ssi_sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/ccree/ssi_sysfs.c 
> b/drivers/staging/ccree/ssi_sysfs.c
> index 0655658..65a0529 100644
> --- a/drivers/staging/ccree/ssi_sysfs.c
> +++ b/drivers/staging/ccree/ssi_sysfs.c
> @@ -376,7 +376,7 @@ static int sys_init_dir(struct sys_dir *sys_dir, struct 
> ssi_drvdata *drvdata,
>   return -ENOMEM;
>   /* allocate memory for directory's attributes list */
>   sys_dir->sys_dir_attr_list =
> - kzalloc(sizeof(struct attribute *) * (num_of_attrs + 1),
> + kcalloc((num_of_attrs + 1), sizeof(struct attribute *),

You don't need the parentheses around the first argument.

julia

>   GFP_KERNEL);
>
>   if (!(sys_dir->sys_dir_attr_list)) {
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1505391353-4516-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] Re: [PATCH] Staging: ccree: Don't use volatile for monitor_lock

2017-09-11 Thread Julia Lawall


On Mon, 11 Sep 2017, Srishti Sharma wrote:

> On Mon, Sep 11, 2017 at 9:34 PM, Greg KH  wrote:
> > On Mon, Sep 11, 2017 at 09:29:31PM +0530, Srishti Sharma wrote:
> >> The use of volatile for the variable monitor_lock is unnecessary.
> >>
> >> Signed-off-by: Srishti Sharma 
> >> ---
> >>  drivers/staging/ccree/ssi_request_mgr.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
> >> b/drivers/staging/ccree/ssi_request_mgr.c
> >> index e5c2f92..7d77941 100644
> >> --- a/drivers/staging/ccree/ssi_request_mgr.c
> >> +++ b/drivers/staging/ccree/ssi_request_mgr.c
> >> @@ -49,7 +49,7 @@ struct ssi_request_mgr_handle {
> >>   dma_addr_t dummy_comp_buff_dma;
> >>   struct cc_hw_desc monitor_desc;
> >>
> >> - volatile unsigned long monitor_lock;
> >> + unsigned long monitor_lock;
> >
> > While volatile is not right, odds are, this is still totally wrong as
> > well.  How about using a "real" lock instead?
>
> I tried to find where is this variable being used in the code, but I
> didn't find any usage of it . It might be an important attribute of
> this structure definition but, I don't see it's value being set to
> anything or being used somewhere .

Try removing it and see if the code still compiles.  There is always a
danger that a use of something could be constructed using ## in a macro,
although given the uses of ## for this driver, it doesn't seem likely
here.

julia


Re: [Outreachy kernel] [PATCH] Staging: ccree: Don't use volatile for monitor_lock

2017-09-11 Thread Julia Lawall


On Mon, 11 Sep 2017, Srishti Sharma wrote:

> The use of volatile for the variable monitor_lock is unnecessary.

You need to give more evidence of why this is the case.  How is the
variable used?  I guess this comes from checkpatch, but checkpatch has
only a local view of things, and doesn't know how the variable is used.

julia

>
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/ccree/ssi_request_mgr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
> b/drivers/staging/ccree/ssi_request_mgr.c
> index e5c2f92..7d77941 100644
> --- a/drivers/staging/ccree/ssi_request_mgr.c
> +++ b/drivers/staging/ccree/ssi_request_mgr.c
> @@ -49,7 +49,7 @@ struct ssi_request_mgr_handle {
>   dma_addr_t dummy_comp_buff_dma;
>   struct cc_hw_desc monitor_desc;
>
> - volatile unsigned long monitor_lock;
> + unsigned long monitor_lock;
>  #ifdef COMP_IN_WQ
>   struct workqueue_struct *workq;
>   struct delayed_work compwork;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1505145571-11248-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v4] Staging: ccree: Merge assignment with return

2017-09-09 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> Merge the assignment and the return statements to return the value
> directly. Done using coccinelle.
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>

Acked-by: Julia Lawall <julia.law...@lip6.fr>

> ---
> Changes in v4:
>  -Edit commit message so that it respects 80 character limit
>  -Remove unneeded blank lines
>  -Remove declarations of variables that are not used
>
>  drivers/staging/ccree/ssi_aead.c | 15 +++
>  1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_aead.c 
> b/drivers/staging/ccree/ssi_aead.c
> index 5abe6b2..84fcb75 100644
> --- a/drivers/staging/ccree/ssi_aead.c
> +++ b/drivers/staging/ccree/ssi_aead.c
> @@ -651,7 +651,6 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
>
>   if (keylen < 3)
>   return -EINVAL;
> @@ -659,9 +658,7 @@ static int ssi_rfc4309_ccm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 3;
>   memcpy(ctx->ctr_nonce, key + keylen, 3);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>  #endif /*SSI_CC_HAS_AES_CCM*/
>
> @@ -2214,7 +2211,6 @@ static int ssi_rfc4309_ccm_decrypt(struct aead_request 
> *req)
>  static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
>
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
> @@ -2224,15 +2220,12 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
>
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
> @@ -2242,9 +2235,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504943331-4636-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH] Staging: ccree: Merge assignment with return

2017-09-09 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> Merge the assignment and return statements to return the value
> directly. Done using coccinelle.

Coccinelle is not always perfect about pretty printing, so you have to
watch out for it.

>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/ccree/ssi_sysfs.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_sysfs.c 
> b/drivers/staging/ccree/ssi_sysfs.c
> index 0655658..9fa7be0 100644
> --- a/drivers/staging/ccree/ssi_sysfs.c
> +++ b/drivers/staging/ccree/ssi_sysfs.c
> @@ -412,7 +412,6 @@ static void sys_free_dir(struct sys_dir *sys_dir)
>
>  int ssi_sysfs_init(struct kobject *sys_dev_obj, struct ssi_drvdata *drvdata)
>  {
> - int retval;
>

This is going to leave a single empty line at the top of the function.
That is not needed.

>  #if defined CC_CYCLE_COUNT
>   /* Init. statistics */
> @@ -423,10 +422,9 @@ int ssi_sysfs_init(struct kobject *sys_dev_obj, struct 
> ssi_drvdata *drvdata)
>   SSI_LOG_ERR("setup sysfs under %s\n", sys_dev_obj->name);
>
>   /* Initialize top directory */
> - retval = sys_init_dir(_top_dir, drvdata, sys_dev_obj, "cc_info",
> + return sys_init_dir(_top_dir, drvdata, sys_dev_obj, "cc_info",
> ssi_sys_top_level_attrs,
> ARRAY_SIZE(ssi_sys_top_level_attrs));

Previously the arguments were lined up with the right side of the ( but
now they are not.  So move the above two lines to the left by 2 spaces.

julia

> - return retval;
>  }
>
>  void ssi_sysfs_fini(void)
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504953861-3221-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v3] Staging: ccree: Merge assignment with return

2017-09-09 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> Merge the assignment and return statements to return the value
> directly. Done using coccinelle.
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Srishti Sharma 
> ---
> Changes in v3:
>  -Edit commit message so that it respects 80 character limit.
>  -Remove unneeded blank lines, that were added by mistake.
>
>  drivers/staging/ccree/ssi_aead.c | 14 +++---
>  1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_aead.c 
> b/drivers/staging/ccree/ssi_aead.c
> index 5abe6b2..1d3b580 100644
> --- a/drivers/staging/ccree/ssi_aead.c
> +++ b/drivers/staging/ccree/ssi_aead.c
> @@ -651,7 +651,6 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
>
>   if (keylen < 3)
>   return -EINVAL;
> @@ -659,9 +658,7 @@ static int ssi_rfc4309_ccm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 3;
>   memcpy(ctx->ctr_nonce, key + keylen, 3);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>  #endif /*SSI_CC_HAS_AES_CCM*/
>
> @@ -2224,15 +2221,12 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);

The declaration of rc should be dropped in this case.  You should have
gotten a compiler warning.  Always compile the code before submitting a
patch, and fix up any warnings.

julia

>  }
>
>  static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
>
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
> @@ -2242,9 +2236,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504907654-4914-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v2] Staging: ccree: Merge assignment with return

2017-09-08 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> Merge the assignment and return statements to return the value
> directly. Done using coccinelle.
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Srishti Sharma 
> ---
> Changes in v2:
>  - Edit commit message so that it respects the 80 character limit.
>
>  drivers/staging/ccree/ssi_aead.c | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_aead.c 
> b/drivers/staging/ccree/ssi_aead.c
> index 5abe6b2..f4532ea 100644
> --- a/drivers/staging/ccree/ssi_aead.c
> +++ b/drivers/staging/ccree/ssi_aead.c
> @@ -651,7 +651,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> +
>

There is still a problem here.  You don't need two blank lines under a
variable declaration.

julia

>   if (keylen < 3)
>   return -EINVAL;
> @@ -659,9 +659,7 @@ static int ssi_rfc4309_ccm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 3;
>   memcpy(ctx->ctr_nonce, key + keylen, 3);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>  #endif /*SSI_CC_HAS_AES_CCM*/
>
> @@ -2214,7 +2212,7 @@ static int ssi_rfc4309_ccm_decrypt(struct aead_request 
> *req)
>  static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> +
>
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
> @@ -2224,15 +,13 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> +
>
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
> @@ -2242,9 +2238,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504904135-3973-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH] Staging: ccree: Merge assignment with return

2017-09-08 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> On Sat, Sep 9, 2017 at 1:42 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
> >
> >
> > On Sat, 9 Sep 2017, Srishti Sharma wrote:
> >
> >> Return the return value of a function directly, instead of first saving it 
> >> in a variable and then returning it. This change was made using the 
> >> following
> >
> > Your commit message should respect the 80 character limit. The above is
> > one very long line.
>
> Yes, I'll fix it . Thanks
> >
> >> semantic patch by coccinelle.
> >>
> >> @@
> >> local idexpression ret;
> >> expression e;
> >> @@
> >>
> >> -ret =
> >> +return
> >>  e;
> >> -return ret;
> >>
> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
> >> ---
> >>  drivers/staging/ccree/ssi_aead.c | 21 ++---
> >>  1 file changed, 6 insertions(+), 15 deletions(-)
> >>
> >> diff --git a/drivers/staging/ccree/ssi_aead.c 
> >> b/drivers/staging/ccree/ssi_aead.c
> >> index 5abe6b2..6bb98f7 100644
> >> --- a/drivers/staging/ccree/ssi_aead.c
> >> +++ b/drivers/staging/ccree/ssi_aead.c
> >> @@ -651,17 +651,14 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 
> >> *key, unsigned int keylen)
> >>  static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, 
> >> unsigned int keylen)
> >>  {
> >>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> >> - int rc = 0;
> >> -
> >> +
> >
> > I'm not sure what happened here, but you should not be removing and then
> > adding back a blank line.  Likewise below.
>
> Sorry , I must have removed an already existing blank line by mistake
> and must have re-added it upon realising the same. I'll fix these and
> send again.

There must be some change in spacing.  Otherwise there would be no diff.

julia

>
> Regards,
> Srishti
>
> >
> > julia
> >
> >>   if (keylen < 3)
> >>   return -EINVAL;
> >>
> >>   keylen -= 3;
> >>   memcpy(ctx->ctr_nonce, key + keylen, 3);
> >>
> >> - rc = ssi_aead_setkey(tfm, key, keylen);
> >> -
> >> - return rc;
> >> + return ssi_aead_setkey(tfm, key, keylen);
> >>  }
> >>  #endif /*SSI_CC_HAS_AES_CCM*/
> >>
> >> @@ -2214,8 +2211,7 @@ static int ssi_rfc4309_ccm_decrypt(struct 
> >> aead_request *req)
> >>  static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> >> unsigned int keylen)
> >>  {
> >>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> >> - int rc = 0;
> >> -
> >> +
> >>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
> >>
> >>   if (keylen < 4)
> >> @@ -2224,16 +2220,13 @@ static int ssi_rfc4106_gcm_setkey(struct 
> >> crypto_aead *tfm, const u8 *key, unsign
> >>   keylen -= 4;
> >>   memcpy(ctx->ctr_nonce, key + keylen, 4);
> >>
> >> - rc = ssi_aead_setkey(tfm, key, keylen);
> >> -
> >> - return rc;
> >> + return ssi_aead_setkey(tfm, key, keylen);
> >>  }
> >>
> >>  static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> >> unsigned int keylen)
> >>  {
> >>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> >> - int rc = 0;
> >> -
> >> +
> >>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
> >>
> >>   if (keylen < 4)
> >> @@ -2242,9 +2235,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead 
> >> *tfm, const u8 *key, unsign
> >>   keylen -= 4;
> >>   memcpy(ctx->ctr_nonce, key + keylen, 4);
> >>
> >> - rc = ssi_aead_setkey(tfm, key, keylen);
> >> -
> >> - return rc;
> >> + return ssi_aead_setkey(tfm, key, keylen);
> >>  }
> >>
> >>  static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
> >> --
> >> 2.7.4
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "outreachy-kernel" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an 
> >> email to outreachy-kernel+unsubscr...@googlegroups.com.
> >> To post to this group, send email to outreachy-ker...@googlegroups.com.
> >> To view this discussion on the web visit 
> >> https://groups.google.com/d/msgid/outreachy-kernel/1504900895-13110-1-git-send-email-srishtishar%40gmail.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/CAB3L5ow4-GeOfh%3D23T58JNUmxu4mmOoG1rwH6fccrzwTNvTu1w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH] Staging: ccree: Merge assignment with return

2017-09-08 Thread Julia Lawall


On Sat, 9 Sep 2017, Srishti Sharma wrote:

> Return the return value of a function directly, instead of first saving it in 
> a variable and then returning it. This change was made using the following

Your commit message should respect the 80 character limit. The above is
one very long line.

> semantic patch by coccinelle.
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Srishti Sharma 
> ---
>  drivers/staging/ccree/ssi_aead.c | 21 ++---
>  1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_aead.c 
> b/drivers/staging/ccree/ssi_aead.c
> index 5abe6b2..6bb98f7 100644
> --- a/drivers/staging/ccree/ssi_aead.c
> +++ b/drivers/staging/ccree/ssi_aead.c
> @@ -651,17 +651,14 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> -
> +

I'm not sure what happened here, but you should not be removing and then
adding back a blank line.  Likewise below.

julia

>   if (keylen < 3)
>   return -EINVAL;
>
>   keylen -= 3;
>   memcpy(ctx->ctr_nonce, key + keylen, 3);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>  #endif /*SSI_CC_HAS_AES_CCM*/
>
> @@ -2214,8 +2211,7 @@ static int ssi_rfc4309_ccm_decrypt(struct aead_request 
> *req)
>  static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> -
> +
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
>   if (keylen < 4)
> @@ -2224,16 +2220,13 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, 
> unsigned int keylen)
>  {
>   struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> - int rc = 0;
> -
> +
>   SSI_LOG_DEBUG("%s()  keylen %d, key %p\n", __func__, keylen, key);
>
>   if (keylen < 4)
> @@ -2242,9 +2235,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead 
> *tfm, const u8 *key, unsign
>   keylen -= 4;
>   memcpy(ctx->ctr_nonce, key + keylen, 4);
>
> - rc = ssi_aead_setkey(tfm, key, keylen);
> -
> - return rc;
> + return ssi_aead_setkey(tfm, key, keylen);
>  }
>
>  static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504900895-13110-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v5] Staging: ccree: Remove unused variable.

2017-09-07 Thread Julia Lawall


On Thu, 7 Sep 2017, Srishti Sharma wrote:

> Remove the local variable inflight_counter as it is never used.
>
> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>

Acked-by: Julia Lawall <julia.law...@lip6.fr>

> ---
> Changes in v5:
>  - Correct the format of the subject.
>  drivers/staging/ccree/ssi_cipher.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_cipher.c 
> b/drivers/staging/ccree/ssi_cipher.c
> index 8d31a93..1ff3c8a 100644
> --- a/drivers/staging/ccree/ssi_cipher.c
> +++ b/drivers/staging/ccree/ssi_cipher.c
> @@ -697,13 +697,10 @@ static int ssi_blkcipher_complete(struct device *dev,
> void __iomem *cc_base)
>  {
>   int completion_error = 0;
> - u32 inflight_counter;
>   struct ablkcipher_request *req = (struct ablkcipher_request *)areq;
>
>   ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
>
> - /*Set the inflight couter value to local variable*/
> - inflight_counter =  ctx_p->drvdata->inflight_counter;
>   /*Decrease the inflight counter*/
>   if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
>   ctx_p->drvdata->inflight_counter--;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504770561-5554-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v4] Staging: ccree: ssi_cipher.c: Remove unused variable.

2017-09-07 Thread Julia Lawall
One last detail.  The subject line above is not in the same format as that
of all of the other subject lines one commits affecting this file.  You
can use git log --oneline to see what others have done.  It is not really
possible to guess correctly.  However, one does not generally include the
extension on a filename.

julia

On Thu, 7 Sep 2017, Srishti Sharma wrote:

> Remove local variable inflight_counter, as it is never used.
>
> Signed-off-by: Srishti Sharma 
> ---
> Change in v4:
>  -There is no longer a need to make the comment more comprehensible, as I
>   have deleted the variable associated with it. The v3 of this patch was
>   not based on the original patch, hence v4.
>  drivers/staging/ccree/ssi_cipher.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_cipher.c 
> b/drivers/staging/ccree/ssi_cipher.c
> index 8d31a93..1ff3c8a 100644
> --- a/drivers/staging/ccree/ssi_cipher.c
> +++ b/drivers/staging/ccree/ssi_cipher.c
> @@ -697,13 +697,10 @@ static int ssi_blkcipher_complete(struct device *dev,
> void __iomem *cc_base)
>  {
>   int completion_error = 0;
> - u32 inflight_counter;
>   struct ablkcipher_request *req = (struct ablkcipher_request *)areq;
>
>   ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
>
> - /*Set the inflight couter value to local variable*/
> - inflight_counter =  ctx_p->drvdata->inflight_counter;
>   /*Decrease the inflight counter*/
>   if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
>   ctx_p->drvdata->inflight_counter--;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504735553-13753-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v3] Staging: ccree: ssi_cipher.c: Remove unused variable.

2017-09-06 Thread Julia Lawall


On Thu, 7 Sep 2017, Srishti Sharma wrote:

> On Thu, Sep 7, 2017 at 2:47 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
> >
> >
> > On Thu, 7 Sep 2017, Srishti Sharma wrote:
> >
> >> Remove local variable inflight_counter ,as it is never used.
> >
> > "counter ,as" -> "counter, as"
> >
> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
> >> ---
> >> Changes in v3:
> >>  - There was no longer a need to make the comment more comprehensible as
> >>I have deleted the variable associated with it because it is unused .
> >>  drivers/staging/ccree/ssi_cipher.c | 5 +
> >>  1 file changed, 1 insertion(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/staging/ccree/ssi_cipher.c 
> >> b/drivers/staging/ccree/ssi_cipher.c
> >> index fec2faa..609ebe4 100644
> >> --- a/drivers/staging/ccree/ssi_cipher.c
> >> +++ b/drivers/staging/ccree/ssi_cipher.c
> >> @@ -702,10 +702,7 @@ static int ssi_blkcipher_complete(struct device *dev,
> >>
> >>   ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, 
> >> dst);
> >>
> >> - /*
> >> -  * Save inflight_counter in a local variable.
> >> -  */
> >> - inflight_counter =  ctx_p->drvdata->inflight_counter;
> >> +
> >
> > This is a patch on your previous patch.  It should be a patch on the
> > original code.  Also, don't add a new blank line.  Just remove the line
> > completely.
>
>   so , when I resend it should I version it as v3 or send as a new
> patch as it is now fixing a different problem ?

v3 (or maybe now v4?) would be fine.  It's still the same code that is
under consideration.  Then it will be clear that he previosu patches are
not needed.

julia

>  Regards,
>  Srishti
> >
> > julia
> >
> >>   /*Decrease the inflight counter*/
> >>   if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 
> >> 0)
> >>   ctx_p->drvdata->inflight_counter--;
> >> --
> >> 2.7.4
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "outreachy-kernel" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an 
> >> email to outreachy-kernel+unsubscr...@googlegroups.com.
> >> To post to this group, send email to outreachy-ker...@googlegroups.com.
> >> To view this discussion on the web visit 
> >> https://groups.google.com/d/msgid/outreachy-kernel/1504732426-9765-1-git-send-email-srishtishar%40gmail.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
>


Re: [Outreachy kernel] [PATCH v3] Staging: ccree: ssi_cipher.c: Remove unused variable.

2017-09-06 Thread Julia Lawall


On Thu, 7 Sep 2017, Srishti Sharma wrote:

> Remove local variable inflight_counter ,as it is never used.

"counter ,as" -> "counter, as"

> Signed-off-by: Srishti Sharma 
> ---
> Changes in v3:
>  - There was no longer a need to make the comment more comprehensible as
>I have deleted the variable associated with it because it is unused .
>  drivers/staging/ccree/ssi_cipher.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_cipher.c 
> b/drivers/staging/ccree/ssi_cipher.c
> index fec2faa..609ebe4 100644
> --- a/drivers/staging/ccree/ssi_cipher.c
> +++ b/drivers/staging/ccree/ssi_cipher.c
> @@ -702,10 +702,7 @@ static int ssi_blkcipher_complete(struct device *dev,
>
>   ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
>
> - /*
> -  * Save inflight_counter in a local variable.
> -  */
> - inflight_counter =  ctx_p->drvdata->inflight_counter;
> +

This is a patch on your previous patch.  It should be a patch on the
original code.  Also, don't add a new blank line.  Just remove the line
completely.

julia

>   /*Decrease the inflight counter*/
>   if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
>   ctx_p->drvdata->inflight_counter--;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504732426-9765-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v2] Staging: ccree: ssi_cipher.c: Make comment more comprehensible.

2017-09-06 Thread Julia Lawall


On Thu, 7 Sep 2017, Srishti Sharma wrote:

> Edited comment to make it more comprehensible.
>
> Signed-off-by: Srishti Sharma 
> ---
> Changes in v2:
>  - Make comment more comprehensible , instead of just correcting typos.
>  drivers/staging/ccree/ssi_cipher.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/ccree/ssi_cipher.c 
> b/drivers/staging/ccree/ssi_cipher.c
> index 99232b2..fec2faa 100644
> --- a/drivers/staging/ccree/ssi_cipher.c
> +++ b/drivers/staging/ccree/ssi_cipher.c
> @@ -702,7 +702,9 @@ static int ssi_blkcipher_complete(struct device *dev,
>
>   ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
>
> - /*Set the inflight counter value to local variable*/
> + /*
> +  * Save inflight_counter in a local variable.
> +  */

This is the format for multiline comments.  Your comments is only one
line.  You just need to add spaces around the text, as compared to the
original version.

julia

>   inflight_counter =  ctx_p->drvdata->inflight_counter;
>   /*Decrease the inflight counter*/
>   if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1504731390-9536-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] Re: [PATCH] Staging: ccree: ssi_cipher.c: Correct spelling mistake.

2017-09-06 Thread Julia Lawall


On Wed, 6 Sep 2017, Srishti Sharma wrote:

>
>
> On Thursday, September 7, 2017 at 12:54:49 AM UTC+5:30, Srishti Sharma
> wrote:
>   Correct spelling of counter in comment .
>
>   Signed-off-by: Srishti Sharma 
>   ---
>    drivers/staging/ccree/ssi_cipher.c | 2 +-
>    1 file changed, 1 insertion(+), 1 deletion(-)
>
>   diff --git a/drivers/staging/ccree/ssi_cipher.c
>   b/drivers/staging/ccree/ssi_cipher.c
>   index 8d31a93..99232b2 100644
>   --- a/drivers/staging/ccree/ssi_cipher.c
>   +++ b/drivers/staging/ccree/ssi_cipher.c
>   @@ -702,7 +702,7 @@ static int ssi_blkcipher_complete(struct
>   device *dev,
>
>    ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx,
>   ivsize, src, dst);
>
>   -/*Set the inflight couter value to local variable*/
>   +/*Set the inflight counter value to local variable*/
>    inflight_counter =  ctx_p->drvdata->inflight_counter;
>    /*Decrease the inflight counter*/
>    if (ctx_p->flow_mode == BYPASS &&
>   ctx_p->drvdata->inflight_counter > 0)
>   --
>   2.7.4
>
>
>   Hey,
>
>   Can I say , /* store the value of inflight_counter variable from  driver
> private data context to a local variable */  , to make it more
> comprehensible ? 

I think it could be a bit of overkill.  The "driver private data context"
part can be seen from a quick glance at the code.  Also, it could be good
to bring out the purpose rather than just what the code does.  So "save
inflight_counter in a a local variable" could be better, because it
focuses on the idea of saving some information for later use.  Good job on
figuring out the formatting problem.

julia

>
> Regards,
> Srishti 
>
> --
> You received this message because you are subscribed to the Google Groups
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web 
> visithttps://groups.google.com/d/msgid/outreachy-kernel/2b8bde9c-6e84-48c5-ab93-
> 76127f314429%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

[cryptodev:master 77/100] drivers/crypto/ccp/ccp-debugfs.c:303:3-9: preceding lock on line 299 (fwd)

2017-06-19 Thread Julia Lawall
Please check whether a lock is needed before line 303.

julia

-- Forwarded message --
Date: Mon, 19 Jun 2017 17:34:11 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: [cryptodev:master 77/100] drivers/crypto/ccp/ccp-debugfs.c:303:3-9:
preceding lock on line 299

CC: kbuild-...@01.org
CC: linux-crypto@vger.kernel.org
TO: Gary R Hook <gary.h...@amd.com>
CC: Herbert Xu <herb...@gondor.apana.org.au>

tree:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
head:   88d58ef891d868303acd7951cb1282c911f736ac
commit: 3cdbe346ed3f380eae1cb3e9febfe703e7d8a7b0 [77/100] crypto: ccp - Add 
debugfs entries for CCP information
:: branch date: 3 hours ago
:: commit date: 3 hours ago

>> drivers/crypto/ccp/ccp-debugfs.c:303:3-9: preceding lock on line 299

git remote add cryptodev 
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git remote update cryptodev
git checkout 3cdbe346ed3f380eae1cb3e9febfe703e7d8a7b0
vim +303 drivers/crypto/ccp/ccp-debugfs.c

3cdbe346 Gary R Hook 2017-05-02  293unsigned long flags;
3cdbe346 Gary R Hook 2017-05-02  294int i;
3cdbe346 Gary R Hook 2017-05-02  295
3cdbe346 Gary R Hook 2017-05-02  296if (!debugfs_initialized())
3cdbe346 Gary R Hook 2017-05-02  297return;
3cdbe346 Gary R Hook 2017-05-02  298
3cdbe346 Gary R Hook 2017-05-02 @299write_lock_irqsave(_debugfs_lock, 
flags);
3cdbe346 Gary R Hook 2017-05-02  300if (!ccp_debugfs_dir) {
3cdbe346 Gary R Hook 2017-05-02  301ccp_debugfs_dir = 
debugfs_create_dir(KBUILD_MODNAME, NULL);
3cdbe346 Gary R Hook 2017-05-02  302if (!ccp_debugfs_dir)
3cdbe346 Gary R Hook 2017-05-02 @303return;
3cdbe346 Gary R Hook 2017-05-02  304}
3cdbe346 Gary R Hook 2017-05-02  305
write_unlock_irqrestore(_debugfs_lock, flags);
3cdbe346 Gary R Hook 2017-05-02  306

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH 2/2] crypto: engine - Permit to enqueue skcipher request

2017-05-24 Thread Julia Lawall
Please check whether an unlock is needed before line 454.

julia

-- Forwarded message --
Date: Wed, 24 May 2017 12:16:29 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH 2/2] crypto: engine - Permit to enqueue skcipher request

CC: kbuild-...@01.org
In-Reply-To: <20170523120903.31637-2-clabbe.montj...@gmail.com>
TO: Corentin Labbe <clabbe.montj...@gmail.com>
CC: herb...@gondor.apana.org.au, da...@davemloft.net
CC: linux-crypto@vger.kernel.org, linux-ker...@vger.kernel.org, Corentin Labbe 
<clabbe.montj...@gmail.com>

Hi Corentin,

[auto build test WARNING on cryptodev/master]
[also build test WARNING on v4.12-rc2 next-20170523]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-engine-replace-pr_xxx-by-dev_xxx/20170524-061949
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
:: branch date: 6 hours ago
:: commit date: 6 hours ago

>> crypto/crypto_engine.c:454:2-8: preceding lock on line 444

git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 1d8d483820540c10cd7056015fa0309e27c0b0e7
vim +454 crypto/crypto_engine.c

735d37b5 Baolin Wang2016-01-26  438   * Return 0 on success, else on fail.
735d37b5 Baolin Wang2016-01-26  439   */
735d37b5 Baolin Wang2016-01-26  440  int crypto_engine_start(struct 
crypto_engine *engine)
735d37b5 Baolin Wang2016-01-26  441  {
735d37b5 Baolin Wang2016-01-26  442 unsigned long flags;
735d37b5 Baolin Wang2016-01-26  443
735d37b5 Baolin Wang2016-01-26 @444 
spin_lock_irqsave(>queue_lock, flags);
735d37b5 Baolin Wang2016-01-26  445
735d37b5 Baolin Wang2016-01-26  446 if (engine->running || 
engine->busy) {
735d37b5 Baolin Wang2016-01-26  447 
spin_unlock_irqrestore(>queue_lock, flags);
735d37b5 Baolin Wang2016-01-26  448 return -EBUSY;
735d37b5 Baolin Wang2016-01-26  449 }
735d37b5 Baolin Wang2016-01-26  450
1d8d4838 Corentin Labbe 2017-05-23  451 if 
(!engine->skcipher_one_request && !engine->cipher_one_request &&
1d8d4838 Corentin Labbe 2017-05-23  452 !engine->hash_one_request) {
1d8d4838 Corentin Labbe 2017-05-23  453 dev_err(engine->dev, 
"need at least one request type\n");
1d8d4838 Corentin Labbe 2017-05-23 @454 return -EINVAL;
1d8d4838 Corentin Labbe 2017-05-23  455 }
1d8d4838 Corentin Labbe 2017-05-23  456
1d8d4838 Corentin Labbe 2017-05-23  457 if 
(engine->skcipher_one_request && engine->cipher_one_request) {

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH v11 4/5] LRNG - enable compile (fwd)

2017-05-15 Thread Julia Lawall
Hello,

I received the following report from kbuild about some coccinelle detected
errors.  I wasn't sure what to look at at the URL to check them.  I
already forwarded the patch for the last case.

julia

-- Forwarded message --
Date: Mon, 15 May 2017 14:09:39 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH v11 4/5] LRNG - enable compile

CC: kbuild-...@01.org
In-Reply-To: <2619717.m11260e...@positron.chronox.de>
TO: "Stephan Müller" <smuel...@chronox.de>
CC: linux-ker...@vger.kernel.org
CC: linux-crypto@vger.kernel.org, "Jason A. Donenfeld" <ja...@zx2c4.com>

Hi Stephan,

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc1 next-20170512]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stephan-M-ller/dev-random-a-new-approach/20170514-223633
:: branch date: 16 hours ago
:: commit date: 16 hours ago

>> drivers/char/lrng_base.c:2243:5-25: duplicated argument to && or ||
--
>> drivers/char/lrng_base.c:1245:7-11: ERROR: iterator variable bound on line 
>> 1236 cannot be NULL
--
>> drivers/char/lrng_base.c:1509:19-24: ERROR: reference preceded by free on 
>> line 1453
--
>> drivers/char/lrng_base.c:1461:1-11: alloc with no test, possible model on 
>> line 1466
--
>> drivers/char/lrng_base.c:1526:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation

[PATCH] fix ptr_ret.cocci warnings

2017-05-15 Thread Julia Lawall
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

CC: Stephan Müller <smuel...@chronox.de>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---

Not very important, but the code can be a little simpler.

 lrng_base.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/drivers/char/lrng_base.c
+++ b/drivers/char/lrng_base.c
@@ -1523,10 +1523,7 @@ static int lrng_alloc(void)
lrng_init_rng(key, sizeof(key));
lrng_pool.lrng_hash = lrng_hash_alloc(LRNG_HASH_NAME, key, sizeof(key));
memzero_explicit(key, sizeof(key));
-   if (IS_ERR(lrng_pool.lrng_hash))
-   return PTR_ERR(lrng_pool.lrng_hash);
-
-   return 0;
+   return PTR_ERR_OR_ZERO(lrng_pool.lrng_hash);
 }

 /** LRNG kernel interfaces ***/

Re: [PATCH 04/22] target: Make use of the new sg_map function at 16 call sites (fwd)

2017-04-14 Thread Julia Lawall
It looks like >cmdr_lock should be released at line 512 if it has
not been released otherwise.  The lock was taken at line 438.

julia

-- Forwarded message --
Date: Fri, 14 Apr 2017 22:21:44 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH 04/22] target: Make use of the new sg_map function at 16
call sites

Hi Logan,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.11-rc6]
[cannot apply to next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Logan-Gunthorpe/Introduce-common-scatterlist-map-function/20170414-142518
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
:: branch date: 8 hours ago
:: commit date: 8 hours ago

>> drivers/target/target_core_user.c:512:2-8: preceding lock on line 438
   drivers/target/target_core_user.c:512:2-8: preceding lock on line 471

git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 78082134e7afdc59d744eb8d2def5c588e89c378
vim +512 drivers/target/target_core_user.c

7c9e7a6f Andy Grover  2014-10-01  432   
sizeof(struct tcmu_cmd_entry));
7c9e7a6f Andy Grover  2014-10-01  433   command_size = base_command_size
7c9e7a6f Andy Grover  2014-10-01  434   + 
round_up(scsi_command_size(se_cmd->t_task_cdb), TCMU_OP_ALIGN_SIZE);
7c9e7a6f Andy Grover  2014-10-01  435
7c9e7a6f Andy Grover  2014-10-01  436   WARN_ON(command_size & 
(TCMU_OP_ALIGN_SIZE-1));
7c9e7a6f Andy Grover  2014-10-01  437
7c9e7a6f Andy Grover  2014-10-01 @438   spin_lock_irq(>cmdr_lock);
7c9e7a6f Andy Grover  2014-10-01  439
7c9e7a6f Andy Grover  2014-10-01  440   mb = udev->mb_addr;
7c9e7a6f Andy Grover  2014-10-01  441   cmd_head = mb->cmd_head % 
udev->cmdr_size; /* UAM */
26418649 Sheng Yang   2016-02-26  442   data_length = 
se_cmd->data_length;
26418649 Sheng Yang   2016-02-26  443   if (se_cmd->se_cmd_flags & 
SCF_BIDI) {
26418649 Sheng Yang   2016-02-26  444   
BUG_ON(!(se_cmd->t_bidi_data_sg && se_cmd->t_bidi_data_nents));
26418649 Sheng Yang   2016-02-26  445   data_length += 
se_cmd->t_bidi_data_sg->length;
26418649 Sheng Yang   2016-02-26  446   }
554617b2 Andy Grover  2016-08-25  447   if ((command_size > 
(udev->cmdr_size / 2)) ||
554617b2 Andy Grover  2016-08-25  448   data_length > 
udev->data_size) {
554617b2 Andy Grover  2016-08-25  449   pr_warn("TCMU: Request 
of size %zu/%zu is too big for %u/%zu "
3d9b9555 Andy Grover  2016-08-25  450   "cmd ring/data 
area\n", command_size, data_length,
7c9e7a6f Andy Grover  2014-10-01  451   
udev->cmdr_size, udev->data_size);
554617b2 Andy Grover  2016-08-25  452   
spin_unlock_irq(>cmdr_lock);
554617b2 Andy Grover  2016-08-25  453   return 
TCM_INVALID_CDB_FIELD;
554617b2 Andy Grover  2016-08-25  454   }
7c9e7a6f Andy Grover  2014-10-01  455
26418649 Sheng Yang   2016-02-26  456   while 
(!is_ring_space_avail(udev, command_size, data_length)) {
7c9e7a6f Andy Grover  2014-10-01  457   int ret;
7c9e7a6f Andy Grover  2014-10-01  458   DEFINE_WAIT(__wait);
7c9e7a6f Andy Grover  2014-10-01  459
7c9e7a6f Andy Grover  2014-10-01  460   
prepare_to_wait(>wait_cmdr, &__wait, TASK_INTERRUPTIBLE);
7c9e7a6f Andy Grover  2014-10-01  461
7c9e7a6f Andy Grover  2014-10-01  462   pr_debug("sleeping for 
ring space\n");
7c9e7a6f Andy Grover  2014-10-01  463   
spin_unlock_irq(>cmdr_lock);
7c9e7a6f Andy Grover  2014-10-01  464   ret = 
schedule_timeout(msecs_to_jiffies(TCMU_TIME_OUT));
7c9e7a6f Andy Grover  2014-10-01  465   
finish_wait(>wait_cmdr, &__wait);
7c9e7a6f Andy Grover  2014-10-01  466   if (!ret) {
7c9e7a6f Andy Grover  2014-10-01  467   pr_warn("tcmu: 
command timed out\n");
02eb924f Andy Grover  2016-10-06  468   return 
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
7c9e7a6f Andy Grover  2014-10-01  469   }
7c9e7a6f Andy Grover  2014-10-01  470
7c9e7a6f Andy Grover  2014-10-01  471   
spin_lock_irq(>cmdr_lock);
7c9e7a6f Andy Grover  2014-10-01  472
7c9e7a6f Andy Grover  2014-10-01  473   /* We dropped 
cmdr_lock, cmd_head is stale */
7c9e7a6f Andy Grover  2014-10-01  474   cmd_head = mb->cmd_head 
% udev->cmdr_size; /* UAM */
7c9e7a6f Andy Grover

[PATCH] fix itnull.cocci warnings

2017-01-07 Thread Julia Lawall
The first argument to list_for_each_entry cannot be NULL.

Generated by: scripts/coccinelle/iterators/itnull.cocci

CC: Harsh Jain <ha...@chelsio.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---

This code comes from the following git tree:

url:
https://github.com/0day-ci/linux/commits/Harsh-Jain/crypto-chcr-Bug-fixes/20170107-093356
base:
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
master
In-Reply-To:
<8e0086b56d8fb61637d179c32a09a1bca03c4186.1483599449.git.ha...@chelsio.com>

 chcr_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -61,7 +61,7 @@ int assign_chcr_device(struct chcr_dev *
 */
mutex_lock(_mutex); /* TODO ? */
list_for_each_entry(u_ctx, _ctx_list, entry)
-   if (u_ctx && u_ctx->dev) {
+   if (u_ctx->dev) {
*dev = u_ctx->dev;
ret = 0;
break;
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] Use dma_pool_zalloc

2016-04-29 Thread Julia Lawall
Dma_pool_zalloc combines dma_pool_alloc and memset 0.  The semantic patch
that makes this transformation is as follows: (http://coccinelle.lip6.fr/)

// 
@@
type T;
T *d;
expression e;
statement S;
@@

d =
-dma_pool_alloc
+dma_pool_zalloc
 (...);
if (!d) S
-   memset(d, 0, sizeof(T));

@@
expression d,e;
statement S;
@@

d =
-dma_pool_alloc
+dma_pool_zalloc
 (...);
if (!d) S
-   memset(d, 0, sizeof(*d));
// 

---

 drivers/crypto/marvell/tdma.c|5 ++---
 drivers/dma/fsldma.c |3 +--
 drivers/dma/ioat/init.c  |5 ++---
 drivers/dma/mmp_pdma.c   |3 +--
 drivers/dma/xilinx/xilinx_vdma.c |3 +--
 5 files changed, 7 insertions(+), 12 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 9/26] eCryptfs: Use skcipher and shash

2016-01-24 Thread Julia Lawall
Maybe the goto on line 1726 needs a preceding mutex_unlock?

julia

On Mon, 25 Jan 2016, kbuild test robot wrote:

> Hi Herbert,
>
> [auto build test WARNING on net/master]
> [also build test WARNING on v4.4 next-20160122]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/Herbert-Xu/crypto-Use-skcipher-and-ahash-shash-where-possible/20160124-212323
> :: branch date: 5 hours ago
> :: commit date: 5 hours ago
>
> >> fs/ecryptfs/keystore.c:1761:1-7: preceding lock on line 1719
>
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 0186bf144c1f96606f491be0e7ed47b79ea0d285
> vim +1761 fs/ecryptfs/keystore.c
>
> ac97b9f9 Michael Halcrow 2008-11-19  1713 if (rc < 1 || rc > 2) {
> f4aad16a Michael Halcrow 2007-10-16  1714 printk(KERN_ERR 
> "Internal error whilst attempting to convert "
> f4aad16a Michael Halcrow 2007-10-16  1715 
> "auth_tok->session_key.decrypted_key to scatterlist; "
> f4aad16a Michael Halcrow 2007-10-16  1716 "expected rc = 
> 1; got rc = [%d]\n", rc);
> f4aad16a Michael Halcrow 2007-10-16  1717 goto out;
> 237fead6 Michael Halcrow 2006-10-04  1718 }
> 237fead6 Michael Halcrow 2006-10-04 @1719 mutex_lock(tfm_mutex);
> 0186bf14 Herbert Xu  2016-01-24  1720 req = 
> skcipher_request_alloc(tfm, GFP_KERNEL);
> 0186bf14 Herbert Xu  2016-01-24  1721 if (!req) {
> 0186bf14 Herbert Xu  2016-01-24  1722 printk(KERN_ERR "%s: 
> Out of kernel memory whilst attempting to "
> 0186bf14 Herbert Xu  2016-01-24  1723
> "skcipher_request_alloc for %s\n", __func__,
> 0186bf14 Herbert Xu  2016-01-24  1724
> crypto_skcipher_driver_name(tfm));
> 0186bf14 Herbert Xu  2016-01-24  1725 rc = -ENOMEM;
> 0186bf14 Herbert Xu  2016-01-24  1726 goto out;
> 0186bf14 Herbert Xu  2016-01-24  1727 }
> 0186bf14 Herbert Xu  2016-01-24  1728
> 0186bf14 Herbert Xu  2016-01-24  1729 
> skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
> 0186bf14 Herbert Xu  2016-01-24  1730   
> NULL, NULL);
> 0186bf14 Herbert Xu  2016-01-24  1731 rc = crypto_skcipher_setkey(
> 0186bf14 Herbert Xu  2016-01-24  1732 tfm, 
> auth_tok->token.password.session_key_encryption_key,
> 237fead6 Michael Halcrow 2006-10-04  1733 crypt_stat->key_size);
> f4aad16a Michael Halcrow 2007-10-16  1734 if (unlikely(rc < 0)) {
> f4aad16a Michael Halcrow 2007-10-16  1735 mutex_unlock(tfm_mutex);
> e5d9cbde Michael Halcrow 2006-10-30  1736 printk(KERN_ERR "Error 
> setting key for crypto context\n");
> e5d9cbde Michael Halcrow 2006-10-30  1737 rc = -EINVAL;
> f4aad16a Michael Halcrow 2007-10-16  1738 goto out;
> 237fead6 Michael Halcrow 2006-10-04  1739 }
> 0186bf14 Herbert Xu  2016-01-24  1740 skcipher_request_set_crypt(req, 
> src_sg, dst_sg,
> 0186bf14 Herbert Xu  2016-01-24  1741
> auth_tok->session_key.encrypted_key_size,
> 0186bf14 Herbert Xu  2016-01-24  1742
> NULL);
> 0186bf14 Herbert Xu  2016-01-24  1743 rc = 
> crypto_skcipher_decrypt(req);
> f4aad16a Michael Halcrow 2007-10-16  1744 mutex_unlock(tfm_mutex);
> f4aad16a Michael Halcrow 2007-10-16  1745 if (unlikely(rc)) {
> 8bba066f Michael Halcrow 2006-10-30  1746 printk(KERN_ERR "Error 
> decrypting; rc = [%d]\n", rc);
> f4aad16a Michael Halcrow 2007-10-16  1747 goto out;
> 8bba066f Michael Halcrow 2006-10-30  1748 }
> 237fead6 Michael Halcrow 2006-10-04  1749 auth_tok->session_key.flags |= 
> ECRYPTFS_CONTAINS_DECRYPTED_KEY;
> 237fead6 Michael Halcrow 2006-10-04  1750 memcpy(crypt_stat->key, 
> auth_tok->session_key.decrypted_key,
> 237fead6 Michael Halcrow 2006-10-04  1751
> auth_tok->session_key.decrypted_key_size);
> e2bd99ec Michael Halcrow 2007-02-12  1752 crypt_stat->flags |= 
> ECRYPTFS_KEY_VALID;
> f4aad16a Michael Halcrow 2007-10-16  1753 if (unlikely(ecryptfs_verbosity 
> > 0)) {
> f24b3887 Tyler Hicks 2010-11-15  1754 
> ecryptfs_printk(KERN_DEBUG, "FEK of size [%zd]:\n",
> f4aad16a Michael Halcrow 2007-10-16  1755 
> crypt_stat->key_size);
> 237fead6 Michael Halcrow 2006-10-04  1756 
> ecryptfs_dump_hex(crypt_stat->key,
> 237fead6 Michael Halcrow 2006-10-04  1757   
> crypt_stat->key_size);
> f4aad16a Michael Halcrow 2007-10-16  1758 }
> 237fead6 Michael Halcrow 2006-10-04  1759  out:
> 0186bf14 Herbert Xu  2016-01-24  1760 skcipher_request_free(req);
> 237fead6 Michael Halcrow 2006-10-04 @1761 return rc;
> 237fead6 Michael Halcrow 

Re: crypto: algif_skcipher - Require setkey before accept(2)

2015-12-25 Thread Julia Lawall


On Fri, 25 Dec 2015, Herbert Xu wrote:

> On Fri, Dec 25, 2015 at 07:54:48AM +0100, Julia Lawall wrote:
> > Lines 766, 767 don't look correct at all.
> 
> Thanks Julia.  I have sent an updated patch in the original thread.
> I wonder why I haven't received the original kbuild test robot
> email though.

I goes to me to check for false positives first.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: crypto: algif_skcipher - Require setkey before accept(2)

2015-12-24 Thread Julia Lawall
Lines 766, 767 don't look correct at all.

julia

On Thu, 24 Dec 2015, kbuild test robot wrote:

> In-Reply-To: <20151224093902.ga8...@gondor.apana.org.au>
> 
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
> Hi Herbert,
> 
> [auto build test WARNING on crypto/master]
> [also build test WARNING on next-20151223]
> [cannot apply to v4.4-rc6]
> 
> url:
> https://github.com/0day-ci/linux/commits/Herbert-Xu/crypto-algif_skcipher-Require-setkey-before-accept-2/20151224-174142
> base:   
> https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
> :: branch date: 63 minutes ago
> :: commit date: 63 minutes ago
> 
> >> crypto/algif_skcipher.c:767:18-21: ERROR: reference preceded by free on 
> >> line 766
> 
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 7f3e28b295bcfeb7fba928af15780f1bb3051430
> vim +767 crypto/algif_skcipher.c
> 
> 7f3e28b2 Herbert Xu 2015-12-24  760   tfm = kzalloc(sizeof(*tfm), GFP_KERNEL);
> 7f3e28b2 Herbert Xu 2015-12-24  761   if (!tfm)
> 7f3e28b2 Herbert Xu 2015-12-24  762   return ERR_PTR(-ENOMEM);
> 7f3e28b2 Herbert Xu 2015-12-24  763  
> 7f3e28b2 Herbert Xu 2015-12-24  764   tfm->skcipher = 
> crypto_alloc_skcipher(name, type, mask);
> 7f3e28b2 Herbert Xu 2015-12-24  765   if (IS_ERR(tfm->skcipher)) {
> 7f3e28b2 Herbert Xu 2015-12-24 @766   kfree(tfm);
> 7f3e28b2 Herbert Xu 2015-12-24 @767   return ERR_CAST(tfm->skcipher);
> 7f3e28b2 Herbert Xu 2015-12-24  768   }
> 7f3e28b2 Herbert Xu 2015-12-24  769  
> 7f3e28b2 Herbert Xu 2015-12-24  770   return tfm;
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: constify drbg_state_ops structures

2015-12-07 Thread Julia Lawall
The drbg_state_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 crypto/drbg.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index a7c2314..ab6ef1d 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -626,7 +626,7 @@ out:
return len;
 }
 
-static struct drbg_state_ops drbg_ctr_ops = {
+static const struct drbg_state_ops drbg_ctr_ops = {
.update = drbg_ctr_update,
.generate   = drbg_ctr_generate,
.crypto_init= drbg_init_sym_kernel,
@@ -752,7 +752,7 @@ static int drbg_hmac_generate(struct drbg_state *drbg,
return len;
 }
 
-static struct drbg_state_ops drbg_hmac_ops = {
+static const struct drbg_state_ops drbg_hmac_ops = {
.update = drbg_hmac_update,
.generate   = drbg_hmac_generate,
.crypto_init= drbg_init_hash_kernel,
@@ -1032,7 +1032,7 @@ out:
  * scratchpad usage: as update and generate are used isolated, both
  * can use the scratchpad
  */
-static struct drbg_state_ops drbg_hash_ops = {
+static const struct drbg_state_ops drbg_hash_ops = {
.update = drbg_hash_update,
.generate   = drbg_hash_generate,
.crypto_init= drbg_init_hash_kernel,

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] crypto: constify pci_error_handlers structures

2015-11-14 Thread Julia Lawall
This pci_error_handlers structure is never modified, like all the other
pci_error_handlers structures, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
There are no dependencies between these patches.

 drivers/crypto/qat/qat_common/adf_aer.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/qat/qat_common/adf_aer.c 
b/drivers/crypto/qat/qat_common/adf_aer.c
index 0a5ca0b..d24cfd4 100644
--- a/drivers/crypto/qat/qat_common/adf_aer.c
+++ b/drivers/crypto/qat/qat_common/adf_aer.c
@@ -197,7 +197,7 @@ static void adf_resume(struct pci_dev *pdev)
dev_info(>dev, "Device is up and runnig\n");
 }
 
-static struct pci_error_handlers adf_err_handler = {
+static const struct pci_error_handlers adf_err_handler = {
.error_detected = adf_error_detected,
.slot_reset = adf_slot_reset,
.resume = adf_resume,

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] constify pci_error_handlers structures

2015-11-14 Thread Julia Lawall
Constify never-modified pci_error_handlers structures.

---

 drivers/crypto/qat/qat_common/adf_aer.c |2 +-
 drivers/misc/genwqe/card_base.c |2 +-
 drivers/net/ethernet/cavium/liquidio/lio_main.c |2 +-
 drivers/net/ethernet/sfc/efx.c  |2 +-
 drivers/scsi/be2iscsi/be_main.c |2 +-
 drivers/scsi/bfa/bfad.c |2 +-
 drivers/scsi/csiostor/csio_init.c   |2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c|2 +-
 drivers/vfio/pci/vfio_pci.c |2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/15] don't export static symbol

2015-03-11 Thread Julia Lawall
These patches remove EXPORT_SYMBOL or EXPORT_SYMBOL_GPL declarations on
static functions.

This was done using the following semantic patch:
(http://coccinelle.lip6.fr/)

// smpl
@r@
type T;
identifier f;
@@

static T f (...) { ... }

@@
identifier r.f;
declarer name EXPORT_SYMBOL;
@@

-EXPORT_SYMBOL(f);

@@
identifier r.f;
declarer name EXPORT_SYMBOL_GPL;
@@

-EXPORT_SYMBOL_GPL(f);
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/15] crypto: don't export static symbol

2015-03-11 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@r@
type T;
identifier f;
@@

static T f (...) { ... }

@@
identifier r.f;
declarer name EXPORT_SYMBOL_GPL;
@@

-EXPORT_SYMBOL_GPL(f);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 arch/x86/crypto/glue_helper.c |1 -
 1 file changed, 1 deletion(-)

diff -u -p a/arch/x86/crypto/glue_helper.c b/arch/x86/crypto/glue_helper.c
--- a/arch/x86/crypto/glue_helper.c
+++ b/arch/x86/crypto/glue_helper.c
@@ -232,7 +232,6 @@ static void glue_ctr_crypt_final_128bit(
 
le128_to_be128((be128 *)walk-iv, ctrblk);
 }
-EXPORT_SYMBOL_GPL(glue_ctr_crypt_final_128bit);
 
 static unsigned int __glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
struct blkcipher_desc *desc,

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall ju...@diku.dk

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

I was not able to compile test this one.

 arch/arm/crypto/sha512_neon_glue.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/crypto/sha512_neon_glue.c 
b/arch/arm/crypto/sha512_neon_glue.c
index f3452c6..b124dce 100644
--- a/arch/arm/crypto/sha512_neon_glue.c
+++ b/arch/arm/crypto/sha512_neon_glue.c
@@ -241,7 +241,7 @@ static int sha384_neon_final(struct shash_desc *desc, u8 
*hash)
sha512_neon_final(desc, D);
 
memcpy(hash, D, SHA384_DIGEST_SIZE);
-   memset(D, 0, SHA512_DIGEST_SIZE);
+   memzero_explicit(D, SHA512_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] sparc64: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall ju...@diku.dk

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

I was not able to compile test these.

 arch/sparc/crypto/sha256_glue.c |2 +-
 arch/sparc/crypto/sha512_glue.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/crypto/sha512_glue.c b/arch/sparc/crypto/sha512_glue.c
index 9fff885..11eb36c 100644
--- a/arch/sparc/crypto/sha512_glue.c
+++ b/arch/sparc/crypto/sha512_glue.c
@@ -139,7 +139,7 @@ static int sha384_sparc64_final(struct shash_desc *desc, u8 
*hash)
sha512_sparc64_final(desc, D);
 
memcpy(hash, D, 48);
-   memset(D, 0, 64);
+   memzero_explicit(D, 64);
 
return 0;
 }
diff --git a/arch/sparc/crypto/sha256_glue.c b/arch/sparc/crypto/sha256_glue.c
index 41f27cc..285268c 100644
--- a/arch/sparc/crypto/sha256_glue.c
+++ b/arch/sparc/crypto/sha256_glue.c
@@ -135,7 +135,7 @@ static int sha224_sparc64_final(struct shash_desc *desc, u8 
*hash)
sha256_sparc64_final(desc, D);
 
memcpy(hash, D, SHA224_DIGEST_SIZE);
-   memset(D, 0, SHA256_DIGEST_SIZE);
+   memzero_explicit(D, SHA256_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall ju...@diku.dk

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

 arch/powerpc/crypto/sha1.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 0f88c7b..d3feba5 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -66,7 +66,7 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
src = data + done;
} while (done + 63  len);
 
-   memset(temp, 0, sizeof(temp));
+   memzero_explicit(temp, sizeof(temp));
partial = 0;
}
memcpy(sctx-buffer + partial, src, len - done);

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall ju...@diku.dk

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

 arch/x86/crypto/sha256_ssse3_glue.c |2 +-
 arch/x86/crypto/sha512_ssse3_glue.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/crypto/sha512_ssse3_glue.c 
b/arch/x86/crypto/sha512_ssse3_glue.c
index 26a5898..0b6af26 100644
--- a/arch/x86/crypto/sha512_ssse3_glue.c
+++ b/arch/x86/crypto/sha512_ssse3_glue.c
@@ -219,7 +219,7 @@ static int sha384_ssse3_final(struct shash_desc *desc, u8 
*hash)
sha512_ssse3_final(desc, D);
 
memcpy(hash, D, SHA384_DIGEST_SIZE);
-   memset(D, 0, SHA512_DIGEST_SIZE);
+   memzero_explicit(D, SHA512_DIGEST_SIZE);
 
return 0;
 }
diff --git a/arch/x86/crypto/sha256_ssse3_glue.c 
b/arch/x86/crypto/sha256_ssse3_glue.c
index 4dc100d..8fad72f 100644
--- a/arch/x86/crypto/sha256_ssse3_glue.c
+++ b/arch/x86/crypto/sha256_ssse3_glue.c
@@ -211,7 +211,7 @@ static int sha224_ssse3_final(struct shash_desc *desc, u8 
*hash)
sha256_ssse3_final(desc, D);
 
memcpy(hash, D, SHA224_DIGEST_SIZE);
-   memset(D, 0, SHA256_DIGEST_SIZE);
+   memzero_explicit(D, SHA256_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8 v2] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

I was not able to compile this one.

v2: fixed email address

 arch/arm/crypto/sha512_neon_glue.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/crypto/sha512_neon_glue.c 
b/arch/arm/crypto/sha512_neon_glue.c
index f3452c6..b124dce 100644
--- a/arch/arm/crypto/sha512_neon_glue.c
+++ b/arch/arm/crypto/sha512_neon_glue.c
@@ -241,7 +241,7 @@ static int sha384_neon_final(struct shash_desc *desc, u8 
*hash)
sha512_neon_final(desc, D);
 
memcpy(hash, D, SHA384_DIGEST_SIZE);
-   memset(D, 0, SHA512_DIGEST_SIZE);
+   memzero_explicit(D, SHA512_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8 v2] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

v2: fixed email address

 arch/powerpc/crypto/sha1.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 0f88c7b..d3feba5 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -66,7 +66,7 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
src = data + done;
} while (done + 63  len);
 
-   memset(temp, 0, sizeof(temp));
+   memzero_explicit(temp, sizeof(temp));
partial = 0;
}
memcpy(sctx-buffer + partial, src, len - done);

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8 v2] crypto: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

v2: fixed email address

 arch/x86/crypto/sha256_ssse3_glue.c |2 +-
 arch/x86/crypto/sha512_ssse3_glue.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/crypto/sha512_ssse3_glue.c 
b/arch/x86/crypto/sha512_ssse3_glue.c
index 26a5898..0b6af26 100644
--- a/arch/x86/crypto/sha512_ssse3_glue.c
+++ b/arch/x86/crypto/sha512_ssse3_glue.c
@@ -219,7 +219,7 @@ static int sha384_ssse3_final(struct shash_desc *desc, u8 
*hash)
sha512_ssse3_final(desc, D);
 
memcpy(hash, D, SHA384_DIGEST_SIZE);
-   memset(D, 0, SHA512_DIGEST_SIZE);
+   memzero_explicit(D, SHA512_DIGEST_SIZE);
 
return 0;
 }
diff --git a/arch/x86/crypto/sha256_ssse3_glue.c 
b/arch/x86/crypto/sha256_ssse3_glue.c
index 4dc100d..8fad72f 100644
--- a/arch/x86/crypto/sha256_ssse3_glue.c
+++ b/arch/x86/crypto/sha256_ssse3_glue.c
@@ -211,7 +211,7 @@ static int sha224_ssse3_final(struct shash_desc *desc, u8 
*hash)
sha256_ssse3_final(desc, D);
 
memcpy(hash, D, SHA224_DIGEST_SIZE);
-   memset(D, 0, SHA256_DIGEST_SIZE);
+   memzero_explicit(D, SHA256_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8 v2] sparc64: replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

This change was suggested by Daniel Borkmann dbork...@redhat.com

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

I was not able to compile these.

v2: fixed email address

 arch/sparc/crypto/sha256_glue.c |2 +-
 arch/sparc/crypto/sha512_glue.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/crypto/sha512_glue.c b/arch/sparc/crypto/sha512_glue.c
index 9fff885..11eb36c 100644
--- a/arch/sparc/crypto/sha512_glue.c
+++ b/arch/sparc/crypto/sha512_glue.c
@@ -139,7 +139,7 @@ static int sha384_sparc64_final(struct shash_desc *desc, u8 
*hash)
sha512_sparc64_final(desc, D);
 
memcpy(hash, D, 48);
-   memset(D, 0, 64);
+   memzero_explicit(D, 64);
 
return 0;
 }
diff --git a/arch/sparc/crypto/sha256_glue.c b/arch/sparc/crypto/sha256_glue.c
index 41f27cc..285268c 100644
--- a/arch/sparc/crypto/sha256_glue.c
+++ b/arch/sparc/crypto/sha256_glue.c
@@ -135,7 +135,7 @@ static int sha224_sparc64_final(struct shash_desc *desc, u8 
*hash)
sha256_sparc64_final(desc, D);
 
memcpy(hash, D, SHA224_DIGEST_SIZE);
-   memset(D, 0, SHA256_DIGEST_SIZE);
+   memzero_explicit(D, SHA256_DIGEST_SIZE);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] replace memset by memzero_explicit

2014-11-30 Thread Julia Lawall
Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  The complete semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier x;
local idexpression e;
type T,T1;
@@

{
... when any
T x[...];
... when any
when exists
(
e = (T1)x
|
e = (T1)x[0]
)
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when != e
when strict
}

@@
identifier i,x;
local idexpression e;
type T;
@@

{
... when any
struct i x;
... when any
when exists
e = (T)x
... when any
when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when != e
when strict
}

// 

@@
identifier x;
type T,T1;
expression e;
@@

{
... when any
T x[...];
... when any
when exists
when != e = (T1)x
when != e = (T1)x[0]
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}

@@
identifier i,x;
expression e;
type T;
@@

{
... when any
struct i x;
... when any
when exists
when != e = (T)x
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
when strict
}
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2 v2] scripts/coccinelle: catch freeing cryptographic structures via kfree

2014-11-23 Thread Julia Lawall


On Wed, 19 Nov 2014, Konstantin Khlebnikov wrote:

 On Wed, Nov 19, 2014 at 12:41 PM, Julia Lawall julia.law...@lip6.fr wrote:
  +// Comments: There are false positives in crypto/ where they are
  actually freed.
 
  I didn't really understand this comment.  I ran the semantic patch and got
  around 10 results, but it wasn't clear to me how to see which were false
  positives.
 
 I mean false positives in code inside directory crypto/ where this
 subsystem lives.
 
 ./arch/x86/crypto/fpu.c:143:1-6: WARNING: invalid free of
 crypto_alloc_* allocated data
 ./crypto/algapi.c:846:1-6: WARNING: invalid free of crypto_alloc_*
 allocated data
 ./crypto/lrw.c:378:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/ecb.c:163:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/ctr.c:242:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/ctr.c:419:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/ctr.c:428:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/pcbc.c:273:1-6: WARNING: invalid free of crypto_alloc_* allocated 
 data
 ./crypto/cts.c:329:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/cbc.c:267:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 ./crypto/xts.c:340:1-6: WARNING: invalid free of crypto_alloc_* allocated data
 
 This is kfree calls on error paths in constructors or in destructors
 which actually frees memory when crypto_free_* is called.

Sorry, but I am not sure to fully understand the issue.  Is it actually 
just the case that crypto_alloc_instance and crypto_alloc_instance2 should 
not be in the list of allocation functions, because their results should 
be freed with kfree?

julia


 
 
  I would suggest to extend the rule a little bit to include information
  about where the allocation call is:
 
 Not sure if this is necessary. This part of crypto-api is simple.
 
 
  ///
  /// Structures allocated by crypto_alloc_* must be freed using 
  crypto_free_*.
  /// This finds freeing them by kfree.
  ///
  // Confidence: Moderate
  // Copyright: (C) 2014 Konstantin Khlebnikov,  GPLv2.
  // Comments: There are false positives in crypto/ where they are actually 
  freed.
  // Keywords: crypto, kfree
  // Options: --no-includes --include-headers
 
  virtual org
  virtual report
  virtual context
 
  @r depends on context || org || report@
  expression x;
  position p1;
  @@
 
  (
   x = crypto_alloc_base@p1(...)
  |
   x = crypto_alloc_cipher@p1(...)
  |
   x = crypto_alloc_ablkcipher@p1(...)
  |
   x = crypto_alloc_aead@p1(...)
  |
   x = crypto_alloc_instance@p1(...)
  |
   x = crypto_alloc_instance2@p1(...)
  |
   x = crypto_alloc_comp@p1(...)
  |
   x = crypto_alloc_pcomp@p1(...)
  |
   x = crypto_alloc_hash@p1(...)
  |
   x = crypto_alloc_ahash@p1(...)
  |
   x = crypto_alloc_shash@p1(...)
  |
   x = crypto_alloc_rng@p1(...)
  )
 
  @pb@
  expression r.x;
  position p;
  @@
 
  * kfree@p(x)
 
  @script:python depends on org@
  p  pb.p;
  p1  r.p1;
  @@
 
  msg=WARNING: invalid free of crypto_alloc_* allocated data
  coccilib.org.print_todo(p[0], msg)
  coccilib.org.print_link(p1[0], allocation)
 
  @script:python depends on report@
  p  pb.p;
  p1  r.p1;
  @@
 
  msg=WARNING: invalid free of crypto_alloc_* allocated data, allocated on 
  line %s % (p1[0].line)
  coccilib.report.print_report(p[0], msg)
  --
  To unsubscribe from this list: send the line unsubscribe linux-kernel in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Please read the FAQ at  http://www.tux.org/lkml/
 
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2 v2] scripts/coccinelle: catch freeing cryptographic structures via kfree

2014-11-19 Thread Julia Lawall
 +// Comments: There are false positives in crypto/ where they are
 actually freed.

I didn't really understand this comment.  I ran the semantic patch and got
around 10 results, but it wasn't clear to me how to see which were false
positives.

I would suggest to extend the rule a little bit to include information
about where the allocation call is:

///
/// Structures allocated by crypto_alloc_* must be freed using crypto_free_*.
/// This finds freeing them by kfree.
///
// Confidence: Moderate
// Copyright: (C) 2014 Konstantin Khlebnikov,  GPLv2.
// Comments: There are false positives in crypto/ where they are actually freed.
// Keywords: crypto, kfree
// Options: --no-includes --include-headers

virtual org
virtual report
virtual context

@r depends on context || org || report@
expression x;
position p1;
@@

(
 x = crypto_alloc_base@p1(...)
|
 x = crypto_alloc_cipher@p1(...)
|
 x = crypto_alloc_ablkcipher@p1(...)
|
 x = crypto_alloc_aead@p1(...)
|
 x = crypto_alloc_instance@p1(...)
|
 x = crypto_alloc_instance2@p1(...)
|
 x = crypto_alloc_comp@p1(...)
|
 x = crypto_alloc_pcomp@p1(...)
|
 x = crypto_alloc_hash@p1(...)
|
 x = crypto_alloc_ahash@p1(...)
|
 x = crypto_alloc_shash@p1(...)
|
 x = crypto_alloc_rng@p1(...)
)

@pb@
expression r.x;
position p;
@@

* kfree@p(x)

@script:python depends on org@
p  pb.p;
p1  r.p1;
@@

msg=WARNING: invalid free of crypto_alloc_* allocated data
coccilib.org.print_todo(p[0], msg)
coccilib.org.print_link(p1[0], allocation)

@script:python depends on report@
p  pb.p;
p1  r.p1;
@@

msg=WARNING: invalid free of crypto_alloc_* allocated data, allocated on line 
%s % (p1[0].line)
coccilib.report.print_report(p[0], msg)
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] scripts/coccinelle: catch freeing cryptographic structures via kfree

2014-11-17 Thread Julia Lawall


On Mon, 17 Nov 2014, Konstantin Khlebnikov wrote:

 Structures allocated by crypto_alloc_* must be freed using crypto_free_*.

 Signed-off-by: Konstantin Khlebnikov k.khlebni...@samsung.com
 ---
  scripts/coccinelle/free/crypto_free.cocci |   45 
 +
  1 file changed, 45 insertions(+)
  create mode 100644 scripts/coccinelle/free/crypto_free.cocci

 diff --git a/scripts/coccinelle/free/crypto_free.cocci 
 b/scripts/coccinelle/free/crypto_free.cocci
 new file mode 100644
 index 000..0799b70
 --- /dev/null
 +++ b/scripts/coccinelle/free/crypto_free.cocci
 @@ -0,0 +1,45 @@
 +///
 +/// Structures allocated by crypto_alloc_* must be freed using crypto_free_*.
 +/// This finds freeing them by kfree.
 +///
 +// Confidence: Moderate
 +// Copyright: (C) 2014 Konstantin Khlebnikov,  GPLv2.
 +// Comments: There are false positives in crypto/ where they are actually 
 freed.
 +// Keywords: crypto, kfree
 +// Options: --no-includes --include-headers
 +
 +virtual org
 +virtual report
 +virtual context
 +
 +@r depends on context || org || report@
 +expression x;
 +identifier crypto_alloc =~ ^crypto_alloc_;
 +@@
 +
 +(
 + x = crypto_alloc(...)
 +)

You can drop the outer parentheses, in this case and in the kfree case.

Are there many of these crypto_alloc_ functions?  It would be nicer to
avoid the regular expression.  For one thing, you don't have much control
over what it matches, and for another thing Coccinelle will not be able to
optimize the selection of files.  With the regular expression it will have
to parse every file and analyze every function, which will be slow.

julia

 +
 +@pb@
 +expression r.x;
 +position p;
 +@@
 +
 +(
 +* kfree@p(x)
 +)
 +
 +@script:python depends on org@
 +p  pb.p;
 +@@
 +
 +msg=WARNING: invalid free of crypto_alloc_* allocated data
 +coccilib.org.print_todo(p[0], msg)
 +
 +@script:python depends on report@
 +p  pb.p;
 +@@
 +
 +msg=WARNING: invalid free of crypto_alloc_* allocated data
 +coccilib.report.print_report(p[0], msg)


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] crypto: memzero_explicit - make sure to clear out sensitive data

2014-09-08 Thread Julia Lawall


On Mon, 8 Sep 2014, Hannes Frederic Sowa wrote:

 On So, 2014-09-07 at 23:23 +0200, Daniel Borkmann wrote:
  Recently, in commit 13aa93c70e71 (random: add and use memzero_explicit()
  for clearing data), we have found that GCC may optimize some memset()
  cases away when it detects a stack variable is not being used anymore
  and going out of scope. This can happen, for example, in cases when we
  are clearing out sensitive information such as keying material or any
  e.g. intermediate results from crypto computations, etc.
 
  With the help of Coccinelle, we can figure out and fix such occurences
  in the crypto subsytem as well. Julia Lawall provided the following
  Coccinelle program:
 
@@
type T;
identifier x;
@@
 
T x;
... when exists
when any
-memset
+memzero_explicit
   (x,
-0,
   ...)
... when != x
when strict
 
@@
type T;
identifier x;
@@
 
T x[...];
... when exists
when any
-memset
+memzero_explicit
   (x,
-0,
   ...)
... when != x
when strict

 I think this Coccinelle patch won't make it completely unnecessary for a
 manual audit as it does not take optimizations (dead code eliminitation)
 into account?

I agree.  If you see something else that could be taken into account in
the semantic patch, please let me know.

julia



 
  Therefore, make use of the drop-in replacement memzero_explicit() for
  exactly such cases instead of using memset().
 
  Signed-off-by: Daniel Borkmann dbork...@redhat.com
  Cc: Julia Lawall julia.law...@lip6.fr
  Cc: Herbert Xu herb...@gondor.apana.org.au
  Cc: Theodore Ts'o ty...@mit.edu
  Cc: Hannes Frederic Sowa han...@stressinduktion.org

 Acked-by: Hannes Frederic Sowa han...@stressinduktion.org

 Thanks,
 Hannes



--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] arch/x86/crypto/camellia_glue.c: adjust code alignment

2013-08-14 Thread Julia Lawall


On Wed, 14 Aug 2013, Herbert Xu wrote:

 On Sat, Aug 10, 2013 at 07:34:36PM +0200, Julia Lawall wrote:
  From: Julia Lawall julia.law...@lip6.fr
 
  Adjust alignment in automatically generated code.  If this code
  will not be regenerated in the future, it may as well look nice.
 
  Signed-off-by: Julia Lawall julia.law...@lip6.fr
 
  ---
  This patch was generated from the result of the previous one, which
  replaced commas by semicolons.

 Please fold this patch into the original one.

OK, I will do that.  There is a second patch for another camellia file
that is in the same situation.  I will send new versions of both.

thanks,
julia
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] crypto/camellia_generic.c: replace commas by semicolons and adjust code alignment

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Adjust alignment and replace commas by semicolons in automatically
generated code.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 crypto/camellia_generic.c |   48 +++---
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index 75efa20..26bcd7a 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -388,8 +388,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 6 */
subL[7] ^= subL[1]; subR[7] ^= subR[1];
subL[1] ^= subR[1]  ~subR[9];
-   dw = subL[1]  subL[9],
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
+   dw = subL[1]  subL[9];
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
/* round 8 */
subL[11] ^= subL[1]; subR[11] ^= subR[1];
/* round 10 */
@@ -397,8 +397,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 12 */
subL[15] ^= subL[1]; subR[15] ^= subR[1];
subL[1] ^= subR[1]  ~subR[17];
-   dw = subL[1]  subL[17],
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */
+   dw = subL[1]  subL[17];
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */
/* round 14 */
subL[19] ^= subL[1]; subR[19] ^= subR[1];
/* round 16 */
@@ -413,8 +413,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
kw4l = subL[25]; kw4r = subR[25];
} else {
subL[1] ^= subR[1]  ~subR[25];
-   dw = subL[1]  subL[25],
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl6) */
+   dw = subL[1]  subL[25];
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl6) */
/* round 20 */
subL[27] ^= subL[1]; subR[27] ^= subR[1];
/* round 22 */
@@ -433,8 +433,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 19 */
subL[26] ^= kw4l; subR[26] ^= kw4r;
kw4l ^= kw4r  ~subR[24];
-   dw = kw4l  subL[24],
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl5) */
+   dw = kw4l  subL[24];
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl5) */
}
/* round 17 */
subL[22] ^= kw4l; subR[22] ^= kw4r;
@@ -443,8 +443,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 13 */
subL[18] ^= kw4l; subR[18] ^= kw4r;
kw4l ^= kw4r  ~subR[16];
-   dw = kw4l  subL[16],
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl3) */
+   dw = kw4l  subL[16];
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl3) */
/* round 11 */
subL[14] ^= kw4l; subR[14] ^= kw4r;
/* round 9 */
@@ -452,8 +452,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 7 */
subL[10] ^= kw4l; subR[10] ^= kw4r;
kw4l ^= kw4r  ~subR[8];
-   dw = kw4l  subL[8],
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl1) */
+   dw = kw4l  subL[8];
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl1) */
/* round 5 */
subL[6] ^= kw4l; subR[6] ^= kw4r;
/* round 3 */
@@ -477,8 +477,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(6) = subL[5] ^ subL[7]; /* round 5 */
SUBKEY_R(6) = subR[5] ^ subR[7];
tl = subL[10] ^ (subR[10]  ~subR[8]);
-   dw = tl  subL[8],  /* FL(kl1) */
-   tr = subR[10] ^ rol32(dw, 1);
+   dw = tl  subL[8];  /* FL(kl1) */
+   tr = subR[10] ^ rol32(dw, 1);
SUBKEY_L(7) = subL[6] ^ tl; /* round 6 */
SUBKEY_R(7) = subR[6] ^ tr;
SUBKEY_L(8) = subL[8];   /* FL(kl1) */
@@ -486,8 +486,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(9) = subL[9];   /* FLinv(kl2) */
SUBKEY_R(9) = subR[9];
tl = subL[7] ^ (subR[7]  ~subR[9]);
-   dw = tl  subL[9],  /* FLinv(kl2) */
-   tr = subR[7] ^ rol32(dw, 1);
+   dw = tl  subL[9];  /* FLinv(kl2) */
+   tr = subR[7] ^ rol32(dw, 1);
SUBKEY_L(10) = tl ^ subL[11]; /* round 7 */
SUBKEY_R(10) = tr ^ subR[11];
SUBKEY_L(11) = subL[10] ^ subL[12]; /* round 8 */
@@ -499,8 +499,8 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(14) = subL[13] ^ subL[15]; /* round 11 */
SUBKEY_R(14) = subR[13] ^ subR[15];
tl = subL[18] ^ (subR[18]  ~subR[16]);
-   dw = tl  subL[16], /* FL(kl3) */
-   tr = subR[18] ^ rol32(dw, 1);
+   dw = tl  subL[16]; /* FL(kl3) */
+   tr = subR[18] ^ rol32(dw, 1);
SUBKEY_L(15) = subL[14

[PATCH 1/2] arch/x86/crypto/camellia_glue.c: replace commas by semicolons and adjust code alignment

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Adjust alignment and replace commas by semicolons in automatically
generated code.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 arch/x86/crypto/camellia_glue.c |   48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index 5cb86cc..39aebea 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -828,8 +828,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
subRL[1] ^= (subRL[1]  ~subRL[9])  32;
/* modified for FLinv(kl2) */
-   dw = (subRL[1]  subRL[9])  32,
-   subRL[1] ^= rol32(dw, 1);
+   dw = (subRL[1]  subRL[9])  32;
+   subRL[1] ^= rol32(dw, 1);
 
/* round 8 */
subRL[11] ^= subRL[1];
@@ -840,8 +840,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
subRL[1] ^= (subRL[1]  ~subRL[17])  32;
/* modified for FLinv(kl4) */
-   dw = (subRL[1]  subRL[17])  32,
-   subRL[1] ^= rol32(dw, 1);
+   dw = (subRL[1]  subRL[17])  32;
+   subRL[1] ^= rol32(dw, 1);
 
/* round 14 */
subRL[19] ^= subRL[1];
@@ -859,8 +859,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
} else {
subRL[1] ^= (subRL[1]  ~subRL[25])  32;
/* modified for FLinv(kl6) */
-   dw = (subRL[1]  subRL[25])  32,
-   subRL[1] ^= rol32(dw, 1);
+   dw = (subRL[1]  subRL[25])  32;
+   subRL[1] ^= rol32(dw, 1);
 
/* round 20 */
subRL[27] ^= subRL[1];
@@ -882,8 +882,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[24])  32;
/* modified for FL(kl5) */
-   dw = (kw4  subRL[24])  32,
-   kw4 ^= rol32(dw, 1);
+   dw = (kw4  subRL[24])  32;
+   kw4 ^= rol32(dw, 1);
}
 
/* round 17 */
@@ -895,8 +895,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[16])  32;
/* modified for FL(kl3) */
-   dw = (kw4  subRL[16])  32,
-   kw4 ^= rol32(dw, 1);
+   dw = (kw4  subRL[16])  32;
+   kw4 ^= rol32(dw, 1);
 
/* round 11 */
subRL[14] ^= kw4;
@@ -907,8 +907,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[8])  32;
/* modified for FL(kl1) */
-   dw = (kw4  subRL[8])  32,
-   kw4 ^= rol32(dw, 1);
+   dw = (kw4  subRL[8])  32;
+   kw4 ^= rol32(dw, 1);
 
/* round 5 */
subRL[6] ^= kw4;
@@ -928,8 +928,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(6, subRL[5] ^ subRL[7]);  /* round 5 */
 
tl = (subRL[10]  32) ^ (subRL[10]  ~subRL[8]);
-   dw = tl  (subRL[8]  32), /* FL(kl1) */
-   tr = subRL[10] ^ rol32(dw, 1);
+   dw = tl  (subRL[8]  32); /* FL(kl1) */
+   tr = subRL[10] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(7, subRL[6] ^ tt);/* round 6 */
@@ -937,8 +937,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(9, subRL[9]); /* FLinv(kl2) */
 
tl = (subRL[7]  32) ^ (subRL[7]  ~subRL[9]);
-   dw = tl  (subRL[9]  32), /* FLinv(kl2) */
-   tr = subRL[7] ^ rol32(dw, 1);
+   dw = tl  (subRL[9]  32); /* FLinv(kl2) */
+   tr = subRL[7] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(10, subRL[11] ^ tt);  /* round 7 */
@@ -948,8 +948,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(14, subRL[13] ^ subRL[15]);   /* round 11 */
 
tl = (subRL[18]  32) ^ (subRL[18]  ~subRL[16]);
-   dw = tl  (subRL[16]  32),/* FL(kl3) */
-   tr = subRL[18] ^ rol32(dw, 1);
+   dw = tl  (subRL[16]  32);/* FL(kl3) */
+   tr = subRL[18] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(15, subRL[14] ^ tt);  /* round 12 */
@@ -957,8 +957,8 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(17, subRL[17]);   /* FLinv(kl4) */
 
tl = (subRL[15]  32) ^ (subRL[15]  ~subRL[17]);
-   dw = tl  (subRL[17]  32),/* FLinv(kl4) */
-   tr = subRL[15] ^ rol32(dw, 1);
+   dw = tl  (subRL[17]  32);/* FLinv(kl4) */
+   tr = subRL[15] ^ rol32(dw

[PATCH 3/5] arch/x86/crypto/camellia_glue.c: convert comma to semicolon

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace a comma between expression statements by a semicolon.

A simplified version of the semantic patch that performs this
transformation is as follows: (http://coccinelle.lip6.fr/)

// smpl
@r@
expression e1,e2,e;
type T;
identifier i;
@@

 e1
-,
+;
 e2;
// /smpl

This patch is separate from the others because the source code appears to
be machine-generated.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 arch/x86/crypto/camellia_glue.c |   24 +++---
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index 5cb86cc..ac2b28b 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -828,7 +828,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
subRL[1] ^= (subRL[1]  ~subRL[9])  32;
/* modified for FLinv(kl2) */
-   dw = (subRL[1]  subRL[9])  32,
+   dw = (subRL[1]  subRL[9])  32;
subRL[1] ^= rol32(dw, 1);
 
/* round 8 */
@@ -840,7 +840,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
subRL[1] ^= (subRL[1]  ~subRL[17])  32;
/* modified for FLinv(kl4) */
-   dw = (subRL[1]  subRL[17])  32,
+   dw = (subRL[1]  subRL[17])  32;
subRL[1] ^= rol32(dw, 1);
 
/* round 14 */
@@ -859,7 +859,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
} else {
subRL[1] ^= (subRL[1]  ~subRL[25])  32;
/* modified for FLinv(kl6) */
-   dw = (subRL[1]  subRL[25])  32,
+   dw = (subRL[1]  subRL[25])  32;
subRL[1] ^= rol32(dw, 1);
 
/* round 20 */
@@ -882,7 +882,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[24])  32;
/* modified for FL(kl5) */
-   dw = (kw4  subRL[24])  32,
+   dw = (kw4  subRL[24])  32;
kw4 ^= rol32(dw, 1);
}
 
@@ -895,7 +895,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[16])  32;
/* modified for FL(kl3) */
-   dw = (kw4  subRL[16])  32,
+   dw = (kw4  subRL[16])  32;
kw4 ^= rol32(dw, 1);
 
/* round 11 */
@@ -907,7 +907,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
kw4 ^= (kw4  ~subRL[8])  32;
/* modified for FL(kl1) */
-   dw = (kw4  subRL[8])  32,
+   dw = (kw4  subRL[8])  32;
kw4 ^= rol32(dw, 1);
 
/* round 5 */
@@ -928,7 +928,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(6, subRL[5] ^ subRL[7]);  /* round 5 */
 
tl = (subRL[10]  32) ^ (subRL[10]  ~subRL[8]);
-   dw = tl  (subRL[8]  32), /* FL(kl1) */
+   dw = tl  (subRL[8]  32); /* FL(kl1) */
tr = subRL[10] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
@@ -937,7 +937,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(9, subRL[9]); /* FLinv(kl2) */
 
tl = (subRL[7]  32) ^ (subRL[7]  ~subRL[9]);
-   dw = tl  (subRL[9]  32), /* FLinv(kl2) */
+   dw = tl  (subRL[9]  32); /* FLinv(kl2) */
tr = subRL[7] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
@@ -948,7 +948,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(14, subRL[13] ^ subRL[15]);   /* round 11 */
 
tl = (subRL[18]  32) ^ (subRL[18]  ~subRL[16]);
-   dw = tl  (subRL[16]  32),/* FL(kl3) */
+   dw = tl  (subRL[16]  32);/* FL(kl3) */
tr = subRL[18] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
@@ -957,7 +957,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(17, subRL[17]);   /* FLinv(kl4) */
 
tl = (subRL[15]  32) ^ (subRL[15]  ~subRL[17]);
-   dw = tl  (subRL[17]  32),/* FLinv(kl4) */
+   dw = tl  (subRL[17]  32);/* FLinv(kl4) */
tr = subRL[15] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
@@ -972,7 +972,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
SET_SUBKEY_LR(24, subRL[24] ^ subRL[23]);   /* kw3 */
} else {
tl = (subRL[26]  32) ^ (subRL[26]  ~subRL[24]);
-   dw = tl  (subRL[24]  32),/* FL(kl5) */
+   dw = tl  (subRL[24]  32);/* FL(kl5) */
tr = subRL[26] ^ rol32(dw, 1);
tt = (tr

[PATCH 2/5] crypto/camellia_generic.c: convert comma to semicolon

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace a comma between expression statements by a semicolon.

A simplified version of the semantic patch that performs this
transformation is as follows: (http://coccinelle.lip6.fr/)

// smpl
@r@
expression e1,e2,e;
type T;
identifier i;
@@

 e1
-,
+;
 e2;
// /smpl

This patch is separate from the others because the code appears to be
machine-generated.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 crypto/camellia_generic.c |   24 ++--
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index 75efa20..125cf16 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -388,7 +388,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 6 */
subL[7] ^= subL[1]; subR[7] ^= subR[1];
subL[1] ^= subR[1]  ~subR[9];
-   dw = subL[1]  subL[9],
+   dw = subL[1]  subL[9];
subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
/* round 8 */
subL[11] ^= subL[1]; subR[11] ^= subR[1];
@@ -397,7 +397,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 12 */
subL[15] ^= subL[1]; subR[15] ^= subR[1];
subL[1] ^= subR[1]  ~subR[17];
-   dw = subL[1]  subL[17],
+   dw = subL[1]  subL[17];
subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */
/* round 14 */
subL[19] ^= subL[1]; subR[19] ^= subR[1];
@@ -413,7 +413,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
kw4l = subL[25]; kw4r = subR[25];
} else {
subL[1] ^= subR[1]  ~subR[25];
-   dw = subL[1]  subL[25],
+   dw = subL[1]  subL[25];
subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl6) */
/* round 20 */
subL[27] ^= subL[1]; subR[27] ^= subR[1];
@@ -433,7 +433,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 19 */
subL[26] ^= kw4l; subR[26] ^= kw4r;
kw4l ^= kw4r  ~subR[24];
-   dw = kw4l  subL[24],
+   dw = kw4l  subL[24];
kw4r ^= rol32(dw, 1); /* modified for FL(kl5) */
}
/* round 17 */
@@ -443,7 +443,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 13 */
subL[18] ^= kw4l; subR[18] ^= kw4r;
kw4l ^= kw4r  ~subR[16];
-   dw = kw4l  subL[16],
+   dw = kw4l  subL[16];
kw4r ^= rol32(dw, 1); /* modified for FL(kl3) */
/* round 11 */
subL[14] ^= kw4l; subR[14] ^= kw4r;
@@ -452,7 +452,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
/* round 7 */
subL[10] ^= kw4l; subR[10] ^= kw4r;
kw4l ^= kw4r  ~subR[8];
-   dw = kw4l  subL[8],
+   dw = kw4l  subL[8];
kw4r ^= rol32(dw, 1); /* modified for FL(kl1) */
/* round 5 */
subL[6] ^= kw4l; subR[6] ^= kw4r;
@@ -477,7 +477,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(6) = subL[5] ^ subL[7]; /* round 5 */
SUBKEY_R(6) = subR[5] ^ subR[7];
tl = subL[10] ^ (subR[10]  ~subR[8]);
-   dw = tl  subL[8],  /* FL(kl1) */
+   dw = tl  subL[8];  /* FL(kl1) */
tr = subR[10] ^ rol32(dw, 1);
SUBKEY_L(7) = subL[6] ^ tl; /* round 6 */
SUBKEY_R(7) = subR[6] ^ tr;
@@ -486,7 +486,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(9) = subL[9];   /* FLinv(kl2) */
SUBKEY_R(9) = subR[9];
tl = subL[7] ^ (subR[7]  ~subR[9]);
-   dw = tl  subL[9],  /* FLinv(kl2) */
+   dw = tl  subL[9];  /* FLinv(kl2) */
tr = subR[7] ^ rol32(dw, 1);
SUBKEY_L(10) = tl ^ subL[11]; /* round 7 */
SUBKEY_R(10) = tr ^ subR[11];
@@ -499,7 +499,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(14) = subL[13] ^ subL[15]; /* round 11 */
SUBKEY_R(14) = subR[13] ^ subR[15];
tl = subL[18] ^ (subR[18]  ~subR[16]);
-   dw = tl  subL[16], /* FL(kl3) */
+   dw = tl  subL[16]; /* FL(kl3) */
tr = subR[18] ^ rol32(dw, 1);
SUBKEY_L(15) = subL[14] ^ tl; /* round 12 */
SUBKEY_R(15) = subR[14] ^ tr;
@@ -508,7 +508,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_L(17) = subL[17]; /* FLinv(kl4) */
SUBKEY_R(17) = subR[17];
tl = subL[15] ^ (subR[15]  ~subR[17]);
-   dw = tl  subL[17], /* FLinv(kl4) */
+   dw = tl  subL[17]; /* FLinv(kl4) */
tr = subR[15] ^ rol32(dw, 1);
SUBKEY_L(18) = tl ^ subL[19]; /* round 13 */
SUBKEY_R(18) = tr ^ subR[19

Re: [PATCH 2/5] crypto/camellia_generic.c: convert comma to semicolon

2013-08-10 Thread Julia Lawall
On Sat, 10 Aug 2013, Joe Perches wrote:

 On Sat, 2013-08-10 at 17:40 +0200, Julia Lawall wrote:
  Replace a comma between expression statements by a semicolon.
 []
  This patch is separate from the others because the code appears to be
  machine-generated.
 
 It may have once been machine generated, but it's not now.
 It's been modified several times by human generated patches.
 
  diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
 []
  @@ -388,7 +388,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, 
  u32 *subR, int max)
 []
  -   dw = subL[1]  subL[9],
  +   dw = subL[1]  subL[9];
  subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
 
 Perhaps you can (auto?) fix the indentation
 on the next line too?

OK, I'll take care of it.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] crypto/camellia_generic.c: adjust code alignment

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Adjust alignment in automatically generated code.  If this code
will not be regenerated in the future, it may as well look nice.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
This patch was generated from the result of the previous one, which
replaced commas by semicolons.

 crypto/camellia_generic.c |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index 125cf16..26bcd7a 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -389,7 +389,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
subL[7] ^= subL[1]; subR[7] ^= subR[1];
subL[1] ^= subR[1]  ~subR[9];
dw = subL[1]  subL[9];
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */
/* round 8 */
subL[11] ^= subL[1]; subR[11] ^= subR[1];
/* round 10 */
@@ -398,7 +398,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
subL[15] ^= subL[1]; subR[15] ^= subR[1];
subL[1] ^= subR[1]  ~subR[17];
dw = subL[1]  subL[17];
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */
/* round 14 */
subL[19] ^= subL[1]; subR[19] ^= subR[1];
/* round 16 */
@@ -414,7 +414,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
} else {
subL[1] ^= subR[1]  ~subR[25];
dw = subL[1]  subL[25];
-   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl6) */
+   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl6) */
/* round 20 */
subL[27] ^= subL[1]; subR[27] ^= subR[1];
/* round 22 */
@@ -434,7 +434,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
subL[26] ^= kw4l; subR[26] ^= kw4r;
kw4l ^= kw4r  ~subR[24];
dw = kw4l  subL[24];
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl5) */
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl5) */
}
/* round 17 */
subL[22] ^= kw4l; subR[22] ^= kw4r;
@@ -444,7 +444,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
subL[18] ^= kw4l; subR[18] ^= kw4r;
kw4l ^= kw4r  ~subR[16];
dw = kw4l  subL[16];
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl3) */
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl3) */
/* round 11 */
subL[14] ^= kw4l; subR[14] ^= kw4r;
/* round 9 */
@@ -453,7 +453,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
subL[10] ^= kw4l; subR[10] ^= kw4r;
kw4l ^= kw4r  ~subR[8];
dw = kw4l  subL[8];
-   kw4r ^= rol32(dw, 1); /* modified for FL(kl1) */
+   kw4r ^= rol32(dw, 1); /* modified for FL(kl1) */
/* round 5 */
subL[6] ^= kw4l; subR[6] ^= kw4r;
/* round 3 */
@@ -478,7 +478,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_R(6) = subR[5] ^ subR[7];
tl = subL[10] ^ (subR[10]  ~subR[8]);
dw = tl  subL[8];  /* FL(kl1) */
-   tr = subR[10] ^ rol32(dw, 1);
+   tr = subR[10] ^ rol32(dw, 1);
SUBKEY_L(7) = subL[6] ^ tl; /* round 6 */
SUBKEY_R(7) = subR[6] ^ tr;
SUBKEY_L(8) = subL[8];   /* FL(kl1) */
@@ -487,7 +487,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_R(9) = subR[9];
tl = subL[7] ^ (subR[7]  ~subR[9]);
dw = tl  subL[9];  /* FLinv(kl2) */
-   tr = subR[7] ^ rol32(dw, 1);
+   tr = subR[7] ^ rol32(dw, 1);
SUBKEY_L(10) = tl ^ subL[11]; /* round 7 */
SUBKEY_R(10) = tr ^ subR[11];
SUBKEY_L(11) = subL[10] ^ subL[12]; /* round 8 */
@@ -500,7 +500,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_R(14) = subR[13] ^ subR[15];
tl = subL[18] ^ (subR[18]  ~subR[16]);
dw = tl  subL[16]; /* FL(kl3) */
-   tr = subR[18] ^ rol32(dw, 1);
+   tr = subR[18] ^ rol32(dw, 1);
SUBKEY_L(15) = subL[14] ^ tl; /* round 12 */
SUBKEY_R(15) = subR[14] ^ tr;
SUBKEY_L(16) = subL[16]; /* FL(kl3) */
@@ -509,7 +509,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, u32 
*subR, int max)
SUBKEY_R(17) = subR[17];
tl = subL[15] ^ (subR[15]  ~subR[17]);
dw = tl  subL[17]; /* FLinv(kl4) */
-   tr = subR[15] ^ rol32(dw, 1);
+   tr = subR[15] ^ rol32(dw, 1);
SUBKEY_L(18) = tl ^ subL[19]; /* round 13 */
SUBKEY_R(18) = tr ^ subR[19];
SUBKEY_L(19) = subL[18

[PATCH 1/2] arch/x86/crypto/camellia_glue.c: adjust code alignment

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Adjust alignment in automatically generated code.  If this code
will not be regenerated in the future, it may as well look nice.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
This patch was generated from the result of the previous one, which
replaced commas by semicolons.

 arch/x86/crypto/camellia_glue.c |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index ac2b28b..39aebea 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -829,7 +829,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
subRL[1] ^= (subRL[1]  ~subRL[9])  32;
/* modified for FLinv(kl2) */
dw = (subRL[1]  subRL[9])  32;
-   subRL[1] ^= rol32(dw, 1);
+   subRL[1] ^= rol32(dw, 1);
 
/* round 8 */
subRL[11] ^= subRL[1];
@@ -841,7 +841,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
subRL[1] ^= (subRL[1]  ~subRL[17])  32;
/* modified for FLinv(kl4) */
dw = (subRL[1]  subRL[17])  32;
-   subRL[1] ^= rol32(dw, 1);
+   subRL[1] ^= rol32(dw, 1);
 
/* round 14 */
subRL[19] ^= subRL[1];
@@ -860,7 +860,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
subRL[1] ^= (subRL[1]  ~subRL[25])  32;
/* modified for FLinv(kl6) */
dw = (subRL[1]  subRL[25])  32;
-   subRL[1] ^= rol32(dw, 1);
+   subRL[1] ^= rol32(dw, 1);
 
/* round 20 */
subRL[27] ^= subRL[1];
@@ -883,7 +883,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
kw4 ^= (kw4  ~subRL[24])  32;
/* modified for FL(kl5) */
dw = (kw4  subRL[24])  32;
-   kw4 ^= rol32(dw, 1);
+   kw4 ^= rol32(dw, 1);
}
 
/* round 17 */
@@ -896,7 +896,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
kw4 ^= (kw4  ~subRL[16])  32;
/* modified for FL(kl3) */
dw = (kw4  subRL[16])  32;
-   kw4 ^= rol32(dw, 1);
+   kw4 ^= rol32(dw, 1);
 
/* round 11 */
subRL[14] ^= kw4;
@@ -908,7 +908,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
kw4 ^= (kw4  ~subRL[8])  32;
/* modified for FL(kl1) */
dw = (kw4  subRL[8])  32;
-   kw4 ^= rol32(dw, 1);
+   kw4 ^= rol32(dw, 1);
 
/* round 5 */
subRL[6] ^= kw4;
@@ -929,7 +929,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
tl = (subRL[10]  32) ^ (subRL[10]  ~subRL[8]);
dw = tl  (subRL[8]  32); /* FL(kl1) */
-   tr = subRL[10] ^ rol32(dw, 1);
+   tr = subRL[10] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(7, subRL[6] ^ tt);/* round 6 */
@@ -938,7 +938,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
tl = (subRL[7]  32) ^ (subRL[7]  ~subRL[9]);
dw = tl  (subRL[9]  32); /* FLinv(kl2) */
-   tr = subRL[7] ^ rol32(dw, 1);
+   tr = subRL[7] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(10, subRL[11] ^ tt);  /* round 7 */
@@ -949,7 +949,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
tl = (subRL[18]  32) ^ (subRL[18]  ~subRL[16]);
dw = tl  (subRL[16]  32);/* FL(kl3) */
-   tr = subRL[18] ^ rol32(dw, 1);
+   tr = subRL[18] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(15, subRL[14] ^ tt);  /* round 12 */
@@ -958,7 +958,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
tl = (subRL[15]  32) ^ (subRL[15]  ~subRL[17]);
dw = tl  (subRL[17]  32);/* FLinv(kl4) */
-   tr = subRL[15] ^ rol32(dw, 1);
+   tr = subRL[15] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(18, subRL[19] ^ tt);  /* round 13 */
@@ -973,7 +973,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
} else {
tl = (subRL[26]  32) ^ (subRL[26]  ~subRL[24]);
dw = tl  (subRL[24]  32);/* FL(kl5) */
-   tr = subRL[26] ^ rol32(dw, 1);
+   tr = subRL[26] ^ rol32(dw, 1);
tt = (tr | ((u64)tl  32));
 
SET_SUBKEY_LR(23, subRL[22] ^ tt);  /* round 18 */
@@ -982,7 +982,7 @@ static void camellia_setup_tail(u64 *subkey, u64 *subRL, 
int max)
 
tl = (subRL[23]  32) ^ (subRL[23]  ~subRL[25]);
dw

[PATCH] crypto: use ERR_CAST

2013-01-22 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Replace PTR_ERR followed by ERR_PTR by ERR_CAST, to be more concise.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
expression err,x;
@@
-   err = PTR_ERR(x);
if (IS_ERR(x))
-return ERR_PTR(err);
+return ERR_CAST(x);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 crypto/aead.c   |6 ++
 crypto/algapi.c |4 +---
 crypto/authenc.c|3 +--
 crypto/authencesn.c |3 +--
 crypto/blkcipher.c  |6 ++
 crypto/ccm.c|   23 +++
 crypto/chainiv.c|3 +--
 crypto/ctr.c|3 +--
 crypto/cts.c|3 +--
 crypto/gcm.c|   29 +
 crypto/seqiv.c  |3 +--
 11 files changed, 27 insertions(+), 59 deletions(-)

diff --git a/crypto/aead.c b/crypto/aead.c
index 0b8121e..4d04e12 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -282,18 +282,16 @@ struct crypto_instance *aead_geniv_alloc(struct 
crypto_template *tmpl,
int err;
 
algt = crypto_get_attr_type(tb);
-   err = PTR_ERR(algt);
if (IS_ERR(algt))
-   return ERR_PTR(err);
+   return ERR_CAST(algt);
 
if ((algt-type ^ (CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_GENIV)) 
algt-mask)
return ERR_PTR(-EINVAL);
 
name = crypto_attr_alg_name(tb[1]);
-   err = PTR_ERR(name);
if (IS_ERR(name))
-   return ERR_PTR(err);
+   return ERR_CAST(name);
 
inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
if (!inst)
diff --git a/crypto/algapi.c b/crypto/algapi.c
index c3b9bfe..08c57c8 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -749,12 +749,10 @@ struct crypto_alg *crypto_attr_alg2(struct rtattr *rta,
u32 type, u32 mask)
 {
const char *name;
-   int err;
 
name = crypto_attr_alg_name(rta);
-   err = PTR_ERR(name);
if (IS_ERR(name))
-   return ERR_PTR(err);
+   return ERR_CAST(name);
 
return crypto_find_alg(name, frontend, type, mask);
 }
diff --git a/crypto/authenc.c b/crypto/authenc.c
index d0583a4..ffce19d 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -592,9 +592,8 @@ static struct crypto_instance *crypto_authenc_alloc(struct 
rtattr **tb)
int err;
 
algt = crypto_get_attr_type(tb);
-   err = PTR_ERR(algt);
if (IS_ERR(algt))
-   return ERR_PTR(err);
+   return ERR_CAST(algt);
 
if ((algt-type ^ CRYPTO_ALG_TYPE_AEAD)  algt-mask)
return ERR_PTR(-EINVAL);
diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index 136b68b..ab53762 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -715,9 +715,8 @@ static struct crypto_instance 
*crypto_authenc_esn_alloc(struct rtattr **tb)
int err;
 
algt = crypto_get_attr_type(tb);
-   err = PTR_ERR(algt);
if (IS_ERR(algt))
-   return ERR_PTR(err);
+   return ERR_CAST(algt);
 
if ((algt-type ^ CRYPTO_ALG_TYPE_AEAD)  algt-mask)
return ERR_PTR(-EINVAL);
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index a8d85a1..e9e7244 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -588,18 +588,16 @@ struct crypto_instance *skcipher_geniv_alloc(struct 
crypto_template *tmpl,
int err;
 
algt = crypto_get_attr_type(tb);
-   err = PTR_ERR(algt);
if (IS_ERR(algt))
-   return ERR_PTR(err);
+   return ERR_CAST(algt);
 
if ((algt-type ^ (CRYPTO_ALG_TYPE_GIVCIPHER | CRYPTO_ALG_GENIV)) 
algt-mask)
return ERR_PTR(-EINVAL);
 
name = crypto_attr_alg_name(tb[1]);
-   err = PTR_ERR(name);
if (IS_ERR(name))
-   return ERR_PTR(err);
+   return ERR_CAST(name);
 
inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
if (!inst)
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 32fe1bb..499c917 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -484,18 +484,16 @@ static struct crypto_instance 
*crypto_ccm_alloc_common(struct rtattr **tb,
int err;
 
algt = crypto_get_attr_type(tb);
-   err = PTR_ERR(algt);
if (IS_ERR(algt))
-   return ERR_PTR(err);
+   return ERR_CAST(algt);
 
if ((algt-type ^ CRYPTO_ALG_TYPE_AEAD)  algt-mask)
return ERR_PTR(-EINVAL);
 
cipher = crypto_alg_mod_lookup(cipher_name,  CRYPTO_ALG_TYPE_CIPHER,
   CRYPTO_ALG_TYPE_MASK);
-   err = PTR_ERR(cipher);
if (IS_ERR(cipher))
-   return ERR_PTR(err);
+   return ERR_CAST(cipher);
 
err = -EINVAL;
if (cipher-cra_blocksize != 16)
@@ -573,15 +571,13 @@ out_put_cipher:
 
 static struct crypto_instance

[PATCH] drivers/crypto/amcc/crypto4xx_core.c: move up err_request_irq label

2012-04-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Move the err_request_irq error label up to reflect that tasklet_init and
irq_of_parse_and_map have taken place.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/crypto/amcc/crypto4xx_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/amcc/crypto4xx_core.c 
b/drivers/crypto/amcc/crypto4xx_core.c
index 13f8e1a..802e851 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -1244,9 +1244,9 @@ err_start_dev:
iounmap(core_dev-dev-ce_base);
 err_iomap:
free_irq(core_dev-irq, dev);
+err_request_irq:
irq_dispose_mapping(core_dev-irq);
tasklet_kill(core_dev-tasklet);
-err_request_irq:
crypto4xx_destroy_sdr(core_dev-dev);
 err_build_sdr:
crypto4xx_destroy_gdr(core_dev-dev);

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] drivers/crypto/ixp4xx_crypto.c: convert GFP_KERNEL to GFP_ATOMIC

2012-01-09 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

The function is called with locks held and thus should not use GFP_KERNEL.

The semantic patch that makes this report is available
in scripts/coccinelle/locks/call_kern.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/crypto/ixp4xx_crypto.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 4c20c5b..bc349cc 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -265,7 +265,7 @@ static int setup_crypt_desc(void)
BUILD_BUG_ON(sizeof(struct crypt_ctl) != 64);
crypt_virt = dma_alloc_coherent(dev,
NPE_QLEN * sizeof(struct crypt_ctl),
-   crypt_phys, GFP_KERNEL);
+   crypt_phys, GFP_ATOMIC);
if (!crypt_virt)
return -ENOMEM;
memset(crypt_virt, 0, NPE_QLEN * sizeof(struct crypt_ctl));

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] crypto: Use ERR_CAST

2010-05-22 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)).  The former makes more
clear what is the purpose of the operation, which otherwise looks like a
no-op.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
type T;
T x;
identifier f;
@@

T f (...) { +...
- ERR_PTR(PTR_ERR(x))
+ x
 ...+ }

@@
expression x;
@@

- ERR_PTR(PTR_ERR(x))
+ ERR_CAST(x)
// /smpl

Signed-off-by: Julia Lawall ju...@diku.dk

---
 crypto/authenc.c |2 +-
 crypto/ctr.c |2 +-
 crypto/xts.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff -u -p a/crypto/authenc.c b/crypto/authenc.c
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -612,7 +612,7 @@ static struct crypto_instance *crypto_au
auth = ahash_attr_alg(tb[1], CRYPTO_ALG_TYPE_HASH,
   CRYPTO_ALG_TYPE_AHASH_MASK);
if (IS_ERR(auth))
-   return ERR_PTR(PTR_ERR(auth));
+   return ERR_CAST(auth);
 
auth_base = auth-base;
 
diff -u -p a/crypto/ctr.c b/crypto/ctr.c
--- a/crypto/ctr.c
+++ b/crypto/ctr.c
@@ -185,7 +185,7 @@ static struct crypto_instance *crypto_ct
alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER,
  CRYPTO_ALG_TYPE_MASK);
if (IS_ERR(alg))
-   return ERR_PTR(PTR_ERR(alg));
+   return ERR_CAST(alg);
 
/* Block size must be = 4 bytes. */
err = -EINVAL;
diff -u -p a/crypto/xts.c b/crypto/xts.c
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -224,7 +224,7 @@ static struct crypto_instance *alloc(str
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
  CRYPTO_ALG_TYPE_MASK);
if (IS_ERR(alg))
-   return ERR_PTR(PTR_ERR(alg));
+   return ERR_CAST(alg);
 
inst = crypto_alloc_instance(xts, alg);
if (IS_ERR(inst))
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/12] crypto: Correct size given to memset

2009-12-09 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Memset should be given the size of the structure, not the size of the pointer.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
type T;
T *x;
expression E;
@@

memset(x, E, sizeof(
+ *
 x))
// /smpl

Signed-off-by: Julia Lawall ju...@diku.dk

---
 crypto/gf128mul.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/crypto/gf128mul.c b/crypto/gf128mul.c
--- a/crypto/gf128mul.c
+++ b/crypto/gf128mul.c
@@ -182,7 +182,7 @@ void gf128mul_lle(be128 *r, const be128 
for (i = 0; i  7; ++i)
gf128mul_x_lle(p[i + 1], p[i]);
 
-   memset(r, 0, sizeof(r));
+   memset(r, 0, sizeof(*r));
for (i = 0;;) {
u8 ch = ((u8 *)b)[15 - i];
 
@@ -220,7 +220,7 @@ void gf128mul_bbe(be128 *r, const be128 
for (i = 0; i  7; ++i)
gf128mul_x_bbe(p[i + 1], p[i]);
 
-   memset(r, 0, sizeof(r));
+   memset(r, 0, sizeof(*r));
for (i = 0;;) {
u8 ch = ((u8 *)b)[i];
 
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: Correct kzalloc error test

2008-04-29 Thread Julia Lawall
From: Julia Lawall [EMAIL PROTECTED]

Normally, kzalloc returns NULL or a valid pointer value, not a value to be
tested using IS_ERR.

Signed-off-by: Julia Lawall [EMAIL PROTECTED]
---
diff -u -p  a/crypto/cryptd.c b/crypto/cryptd.c
--- a/crypto/cryptd.c   2008-04-16 13:27:56.0 +0200
+++ b/crypto/cryptd.c   2008-04-29 15:29:54.0 +0200
@@ -190,7 +190,7 @@ static struct crypto_instance *cryptd_al
int err;

inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
-   if (IS_ERR(inst))
+   if (!inst)
goto out;

err = -ENAMETOOLONG;
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html