Re: [PATCH] crypto: mv_cesa - fix up for of_get_named_gen_pool() rename

2015-06-26 Thread Herbert Xu
On Thu, Jun 25, 2015 at 05:56:05PM +0200, Simon Guinot wrote:
 On Thu, Jun 25, 2015 at 11:30:06PM +0800, Herbert Xu wrote:
  On Thu, Jun 25, 2015 at 10:37:50AM +0200, Simon Guinot wrote:
   This patch fixes the following build error:
   
   drivers/crypto/mv_cesa.c: In function 'mv_cesa_get_sram':
   drivers/crypto/mv_cesa.c:1037: error: implicit declaration of function 
   'of_get_named_gen_pool'
   drivers/crypto/mv_cesa.c:1038: warning: assignment makes pointer from 
   integer without a cast
   scripts/Makefile.build:258: recipe for target 'drivers/crypto/mv_cesa.o' 
   failed
   
   Signed-off-by: Simon Guinot simon.gui...@sequanux.org
  
  This patch doesn't compile.
 
 It does compile. How it could not ?
 But since the issue has already been fixed, it doesn't really matter.

It breaks the build of mv_cesa in the crypto tree as well as the
cryptodev tree while without your patch the mv_cesa builds just
fine.  If your patch isn't meant for these trees then you should
clearly say so.

Thanks,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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] QAT: Fix uninitialized variable in qat driver

2015-06-26 Thread Neil Horman
Hit a warning when building QAT, indicating that sz_out might be uninitalized
before use.  Looks like if you hit an error path and jump to err: you might find
yourself trying to unmap an arbirarily long dma region.  Its safe on intel since
intel defines the invalid dma address as zero, but other arches don't, and if
qat makes its way to one of those, that can cause all sorts of corruption.

Fix is pretty easy, just init sz_out to zero, and gate the unmapping on sz_out
being non-zero

Signed-off-by: Neil Horman nhor...@tuxdriver.com
CC: Herbert Xu herb...@gondor.apana.org.au
CC: David S. Miller da...@davemloft.net
CC: Tadeusz Struk tadeusz.st...@intel.com
CC: qat-li...@intel.com (open list:QAT DRIVER)
---
 drivers/crypto/qat/qat_common/qat_algs.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_algs.c 
b/drivers/crypto/qat/qat_common/qat_algs.c
index 067402c..35ab752 100644
--- a/drivers/crypto/qat/qat_common/qat_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_algs.c
@@ -667,8 +667,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance 
*inst,
dma_addr_t blp;
dma_addr_t bloutp = 0;
struct scatterlist *sg;
-   size_t sz_out, sz = sizeof(struct qat_alg_buf_list) +
-   ((1 + n + assoc_n) * sizeof(struct qat_alg_buf));
+   size_t sz_out = 0;
+   size_t sz = sizeof(struct qat_alg_buf_list) +
+ ((1 + n + assoc_n) * sizeof(struct qat_alg_buf));
 
if (unlikely(!n))
return -EINVAL;
@@ -793,7 +794,7 @@ err:
dma_unmap_single(dev, buflout-bufers[i].addr,
 buflout-bufers[i].len,
 DMA_BIDIRECTIONAL);
-   if (!dma_mapping_error(dev, bloutp))
+   if (sz_out  !dma_mapping_error(dev, bloutp))
dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE);
kfree(buflout);
}
-- 
2.1.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] crypto-qat: Deletion of unnecessary checks before two function calls

2015-06-26 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Fri, 26 Jun 2015 20:30:11 +0200

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/crypto/qat/qat_common/adf_accel_engine.c | 5 +
 drivers/crypto/qat/qat_common/adf_transport.c| 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_accel_engine.c 
b/drivers/crypto/qat/qat_common/adf_accel_engine.c
index 7f8b66c..fdda8e7 100644
--- a/drivers/crypto/qat/qat_common/adf_accel_engine.c
+++ b/drivers/crypto/qat/qat_common/adf_accel_engine.c
@@ -88,10 +88,7 @@ void adf_ae_fw_release(struct adf_accel_dev *accel_dev)
 
qat_uclo_del_uof_obj(loader_data-fw_loader);
qat_hal_deinit(loader_data-fw_loader);
-
-   if (loader_data-uof_fw)
-   release_firmware(loader_data-uof_fw);
-
+   release_firmware(loader_data-uof_fw);
loader_data-uof_fw = NULL;
loader_data-fw_loader = NULL;
 }
diff --git a/drivers/crypto/qat/qat_common/adf_transport.c 
b/drivers/crypto/qat/qat_common/adf_transport.c
index ccec3274..db2926b 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.c
+++ b/drivers/crypto/qat/qat_common/adf_transport.c
@@ -449,7 +449,7 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev,
 err:
for (i = 0; i  ADF_ETR_MAX_RINGS_PER_BANK; i++) {
ring = bank-rings[i];
-   if (hw_data-tx_rings_mask  (1  i)  ring-inflights)
+   if (hw_data-tx_rings_mask  (1  i))
kfree(ring-inflights);
}
return -ENOMEM;
-- 
2.4.4

--
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 Fixes for 4.2

2015-06-26 Thread Linus Torvalds
On Fri, Jun 26, 2015 at 3:22 AM, Herbert Xu herb...@gondor.apana.org.au wrote:

 * Kill testmgr warning for gcm-aes-aesni.

Hmm. You killed one of the warnings, but the setkey one remains.

alg: aead: setkey failed on test 1 for rfc4106-gcm-aesni: flags=0

Expected?

   Linus
--
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


arm64 allmodconfig failure in expansion of macro ‘_X’

2015-06-26 Thread Will Deacon
Hi all,

arm64 allmodconfig fails to build with mainline due to the following:


  In file included from include/acpi/platform/aclinux.h:74:0,
   from include/acpi/platform/acenv.h:173,
   from include/acpi/acpi.h:56,
   from include/linux/acpi.h:37,
   from ./arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/crypto/algapi.h:18,
   from crypto/asymmetric_keys/rsa.c:16:
  include/linux/ctype.h:15:12: error: expected ‘;’, ‘,’ or ‘)’ before numeric 
constant
   #define _X 0x40 /* hex digit */
  ^
  crypto/asymmetric_keys/rsa.c:123:47: note: in expansion of macro ‘_X’
   static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
 ^
  crypto/asymmetric_keys/rsa.c: In function ‘RSA_verify_signature’:
  crypto/asymmetric_keys/rsa.c:256:2: error: implicit declaration of function 
‘RSA_I2OSP’ [-Werror=implicit-function-declaration]
ret = RSA_I2OSP(m, k, EM);


This is thanks to the following function type:

  static int RSA_I2OSP(MPI x, size_t xLen, u8 **__X)

conflicting with the _X #define in linux/ctype.h:

  #define _X  0x40/* hex digit */

Simple patch below, but solving this problem with more underscores feels
slightly inhumane.

Will

---8

diff --git a/crypto/asymmetric_keys/rsa.c b/crypto/asymmetric_keys/rsa.c
index 459cf97a75e2..a4e53239448b 100644
--- a/crypto/asymmetric_keys/rsa.c
+++ b/crypto/asymmetric_keys/rsa.c
@@ -120,7 +120,7 @@ static int RSAVP1(const struct public_key *key, MPI s, MPI 
*_m)
 /*
  * Integer to Octet String conversion [RFC3447 sec 4.1]
  */
-static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
+static int RSA_I2OSP(MPI x, size_t xLen, u8 **__X)
 {
unsigned X_size, x_size;
int X_sign;
@@ -147,7 +147,7 @@ static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
return -EBADMSG;
}
 
-   *_X = X;
+   *__X = X;
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


Re: arm64 allmodconfig failure in expansion of macro ‘_X’

2015-06-26 Thread Herbert Xu
On Fri, Jun 26, 2015 at 11:08:05AM +0100, Will Deacon wrote:
 Hi all,
 
 arm64 allmodconfig fails to build with mainline due to the following:
 
 
   In file included from include/acpi/platform/aclinux.h:74:0,
from include/acpi/platform/acenv.h:173,
from include/acpi/acpi.h:56,
from include/linux/acpi.h:37,
from ./arch/arm64/include/asm/dma-mapping.h:21,
from include/linux/dma-mapping.h:86,
from include/linux/skbuff.h:34,
from include/crypto/algapi.h:18,
from crypto/asymmetric_keys/rsa.c:16:
   include/linux/ctype.h:15:12: error: expected ‘;’, ‘,’ or ‘)’ before numeric 
 constant
#define _X 0x40 /* hex digit */
   ^
   crypto/asymmetric_keys/rsa.c:123:47: note: in expansion of macro ‘_X’
static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
  ^
   crypto/asymmetric_keys/rsa.c: In function ‘RSA_verify_signature’:
   crypto/asymmetric_keys/rsa.c:256:2: error: implicit declaration of function 
 ‘RSA_I2OSP’ [-Werror=implicit-function-declaration]
 ret = RSA_I2OSP(m, k, EM);
 
 
 This is thanks to the following function type:
 
   static int RSA_I2OSP(MPI x, size_t xLen, u8 **__X)
 
 conflicting with the _X #define in linux/ctype.h:
 
   #define _X  0x40/* hex digit */
 
 Simple patch below, but solving this problem with more underscores feels
 slightly inhumane.

Thanks but I've already merged a similar patch yesterday.
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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: arm64 allmodconfig failure in expansion of macro ‘_X’

2015-06-26 Thread Will Deacon
On Fri, Jun 26, 2015 at 11:09:44AM +0100, Herbert Xu wrote:
 On Fri, Jun 26, 2015 at 11:08:05AM +0100, Will Deacon wrote:
  Hi all,
  
  arm64 allmodconfig fails to build with mainline due to the following:
  
  
In file included from include/acpi/platform/aclinux.h:74:0,
 from include/acpi/platform/acenv.h:173,
 from include/acpi/acpi.h:56,
 from include/linux/acpi.h:37,
 from ./arch/arm64/include/asm/dma-mapping.h:21,
 from include/linux/dma-mapping.h:86,
 from include/linux/skbuff.h:34,
 from include/crypto/algapi.h:18,
 from crypto/asymmetric_keys/rsa.c:16:
include/linux/ctype.h:15:12: error: expected ‘;’, ‘,’ or ‘)’ before 
  numeric constant
 #define _X 0x40 /* hex digit */
^
crypto/asymmetric_keys/rsa.c:123:47: note: in expansion of macro ‘_X’
 static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
   ^
crypto/asymmetric_keys/rsa.c: In function ‘RSA_verify_signature’:
crypto/asymmetric_keys/rsa.c:256:2: error: implicit declaration of 
  function ‘RSA_I2OSP’ [-Werror=implicit-function-declaration]
  ret = RSA_I2OSP(m, k, EM);
  
  
  This is thanks to the following function type:
  
static int RSA_I2OSP(MPI x, size_t xLen, u8 **__X)
  
  conflicting with the _X #define in linux/ctype.h:
  
#define _X  0x40/* hex digit */
  
  Simple patch below, but solving this problem with more underscores feels
  slightly inhumane.
 
 Thanks but I've already merged a similar patch yesterday.

Perfect, sorry for the noise.

Will
--
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