All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: testmgr: change `guard` to unsigned char
@ 2018-01-01 10:33 Joey Pabalinas
  2018-01-01 15:03 ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Joey Pabalinas @ 2018-01-01 10:33 UTC (permalink / raw)
  To: linux-crypto; +Cc: herbert, davem, linux-kernel, Joey Pabalinas

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

When char is signed, storing the values 0xba (186) and 0xad (173) in the
`guard` array produces signed overflow. Change the type of `guard` to
unsigned char to remove undefined behavior.

Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
---
 crypto/testmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 29d7020b8826faa3f0..e9a9faecf212bbd742 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,
 	char *state;
 	struct ahash_request *req;
 	int statesize, ret = -EINVAL;
-	const char guard[] = { 0x00, 0xba, 0xad, 0x00 };
+	const unsigned char guard[] = { 0x00, 0xba, 0xad, 0x00 };
 
 	req = *preq;
 	statesize = crypto_ahash_statesize(
-- 
2.15.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto: testmgr: change `guard` to unsigned char
  2018-01-01 10:33 [PATCH] crypto: testmgr: change `guard` to unsigned char Joey Pabalinas
@ 2018-01-01 15:03 ` Joe Perches
  2018-01-01 20:36   ` Joey Pabalinas
  2018-01-01 20:40   ` [PATCH v2] " Joey Pabalinas
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Perches @ 2018-01-01 15:03 UTC (permalink / raw)
  To: Joey Pabalinas, linux-crypto; +Cc: herbert, davem, linux-kernel

On Mon, 2018-01-01 at 00:33 -1000, Joey Pabalinas wrote:
> When char is signed, storing the values 0xba (186) and 0xad (173) in the
> `guard` array produces signed overflow. Change the type of `guard` to
> unsigned char to remove undefined behavior.
[]
> diff --git a/crypto/testmgr.c b/crypto/testmgr.c
[]
> @@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,
>  	char *state;
>  	struct ahash_request *req;
>  	int statesize, ret = -EINVAL;
> -	const char guard[] = { 0x00, 0xba, 0xad, 0x00 };
> +	const unsigned char guard[] = { 0x00, 0xba, 0xad, 0x00 };

Might as well add static too

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] crypto: testmgr: change `guard` to unsigned char
  2018-01-01 15:03 ` Joe Perches
@ 2018-01-01 20:36   ` Joey Pabalinas
  2018-01-01 20:40   ` [PATCH v2] " Joey Pabalinas
  1 sibling, 0 replies; 6+ messages in thread
From: Joey Pabalinas @ 2018-01-01 20:36 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-crypto, herbert, davem, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

On Mon, Jan 01, 2018 at 07:03:46AM -0800, Joe Perches wrote:
> 
> Might as well add static too
> 

That's a good idea; I'll make a v2.

-- 
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] crypto: testmgr: change `guard` to unsigned char
  2018-01-01 15:03 ` Joe Perches
  2018-01-01 20:36   ` Joey Pabalinas
@ 2018-01-01 20:40   ` Joey Pabalinas
  2018-01-12 12:23     ` Herbert Xu
  1 sibling, 1 reply; 6+ messages in thread
From: Joey Pabalinas @ 2018-01-01 20:40 UTC (permalink / raw)
  To: Joe Perches, linux-crypto; +Cc: herbert, davem, linux-kernel, Joey Pabalinas

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

When char is signed, storing the values 0xba (186) and 0xad (173) in the
`guard` array produces signed overflow. Change the type of `guard` to
static unsigned char to correct undefined behavior and reduce function
stack usage.

Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
---
 crypto/testmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 29d7020b8826faa3f0..44a85d4b3561acbca6 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,
 	char *state;
 	struct ahash_request *req;
 	int statesize, ret = -EINVAL;
-	const char guard[] = { 0x00, 0xba, 0xad, 0x00 };
+	static const unsigned char guard[] = { 0x00, 0xba, 0xad, 0x00 };
 
 	req = *preq;
 	statesize = crypto_ahash_statesize(
-- 
2.15.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] crypto: testmgr: change `guard` to unsigned char
  2018-01-01 20:40   ` [PATCH v2] " Joey Pabalinas
@ 2018-01-12 12:23     ` Herbert Xu
  2018-01-12 17:09       ` Joey Pabalinas
  0 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2018-01-12 12:23 UTC (permalink / raw)
  To: Joey Pabalinas; +Cc: Joe Perches, linux-crypto, davem, linux-kernel

On Mon, Jan 01, 2018 at 10:40:14AM -1000, Joey Pabalinas wrote:
> When char is signed, storing the values 0xba (186) and 0xad (173) in the
> `guard` array produces signed overflow. Change the type of `guard` to
> static unsigned char to correct undefined behavior and reduce function
> stack usage.
> 
> Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] crypto: testmgr: change `guard` to unsigned char
  2018-01-12 12:23     ` Herbert Xu
@ 2018-01-12 17:09       ` Joey Pabalinas
  0 siblings, 0 replies; 6+ messages in thread
From: Joey Pabalinas @ 2018-01-12 17:09 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Joe Perches, linux-crypto, davem, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 138 bytes --]

On Fri, Jan 12, 2018 at 11:23:28PM +1100, Herbert Xu wrote:
> 
> Patch applied.  Thanks.

No problem, cheers.

-- 
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-12 17:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-01 10:33 [PATCH] crypto: testmgr: change `guard` to unsigned char Joey Pabalinas
2018-01-01 15:03 ` Joe Perches
2018-01-01 20:36   ` Joey Pabalinas
2018-01-01 20:40   ` [PATCH v2] " Joey Pabalinas
2018-01-12 12:23     ` Herbert Xu
2018-01-12 17:09       ` Joey Pabalinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.