ARM: crypto: work around gcc-15 warning
Subsystems (2)
PATCH 1/1 ARM: crypto: work around gcc-15 warning
From: Arnd Bergmann <[email protected]>
I get a very rare -Wstringop-overread warning with gcc-15 for one function in aesbs_ctr_encrypt():
arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:212:1446: error: '__builtin_memcpy' offset [17, 2147483647] is out of the bounds [0, 16] of object 'buf' with type 'u8[16]' {aka 'unsigned char[16]'} [-Werror=array-bounds=]
212 | src = dst = memcpy(buf + sizeof(buf) - bytes,arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:218:17: error: 'aesbs_ctr_encrypt' reading 1 byte from a region of size 0 [-Werror=stringop-overread]
218 | aesbs_ctr_encrypt(dst, src, ctx->rk, ctx->rounds, bytes, walk.iv);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 2 of type 'const u8[0]' {aka 'const unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 3 of type 'const u8[0]' {aka 'const unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 6 of type 'u8[0]' {aka 'unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:36:17: note: in a call to function 'aesbs_ctr_encrypt'
36 | asmlinkage void aesbs_ctr_encrypt(u8 out[], u8 const in[], u8 const rk[],
This could happen in theory if walk.nbytes is larger than INT_MAX and gets converted to a negative local variable.
Keep the type unsigned like the orignal nbytes to be sure there is no integer overflow.
--- arch/arm/crypto/aes-neonbs-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/crypto/aes-neonbs-glue.c +1 -1
@@ -206,7 +206,7 @@ static int ctr_encrypt(struct skcipher_request *req)while (walk.nbytes >0 ) {const u8 *src = walk.src.virt.addr;u8 *dst = walk.dst.virt.addr; -int bytes = walk.nbytes; +unsigned int bytes = walk.nbytes;if (unlikely (bytes <AES_BLOCK_SIZE )) src = dst = memcpy(buf + sizeof(buf) - bytes,
Signature · 1 line
2.39.5
Quoted 19 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
I get a very rare -Wstringop-overread warning with gcc-15 for one function in
aesbs_ctr_encrypt():
arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:212:1446: error: '__builtin_memcpy' offset [17, 2147483647] is out of the bounds [0, 16] of object 'buf' with type 'u8[16]' {aka 'unsigned char[16]'} [-Werror=array-bounds=]
212 | src = dst = memcpy(buf + sizeof(buf) - bytes,arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:218:17: error: 'aesbs_ctr_encrypt' reading 1 byte from a region of size 0 [-Werror=stringop-overread]218 | aesbs_ctr_encrypt(dst, src, ctx->rk, ctx->rounds, bytes, walk.iv); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 2 of type 'const u8[0]' {aka 'const unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 3 of type 'const u8[0]' {aka 'const unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 6 of type 'u8[0]' {aka 'unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:36:17: note: in a call to function 'aesbs_ctr_encrypt'
36 | asmlinkage void aesbs_ctr_encrypt(u8 out[], u8 const in[], u8 const rk[],
Quoted 8 lines
This could happen in theory if walk.nbytes is larger than
INT_MAXand gets converted to a negative local variable.Keep the type unsigned like the orignal nbytes to be sure there is no integer overflow.
Fixes c8bf850e991a ("crypto: arm/aes-neonbs-ctr - deal with non-multiples of AES block size")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 20 lines
--- arch/arm/crypto/aes-neonbs-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/crypto/aes-neonbs-glue.c +1
-2@@ -206,7 +206,7 @@ static int ctr_encrypt(struct skcipher_request *req)while (walk.nbytes >0 ) {const u8 *src = walk.src.virt.addr;u8 *dst = walk.dst.virt.addr; -int bytes = walk.nbytes; +unsigned int bytes = walk.nbytes;if (unlikely (bytes <AES_BLOCK_SIZE )) src = dst = memcpy(buf + sizeof(buf) - bytes, --2.39.5
Herbert Xu
maintainerQuoted 21 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
I get a very rare -Wstringop-overread warning with gcc-15 for one function in
aesbs_ctr_encrypt():
arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:212:1446: error: '__builtin_memcpy' offset [17, 2147483647] is out of the bounds [0, 16] of object 'buf' with type 'u8[16]' {aka 'unsigned char[16]'} [-Werror=array-bounds=]
212 | src = dst = memcpy(buf + sizeof(buf) - bytes,arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:218:17: error: 'aesbs_ctr_encrypt' reading 1 byte from a region of size 0 [-Werror=stringop-overread]218 | aesbs_ctr_encrypt(dst, src, ctx->rk, ctx->rounds, bytes, walk.iv); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 2 of type 'const u8[0]' {aka 'const unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 3 of type 'const u8[0]' {aka 'const unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 6 of type 'u8[0]' {aka 'unsigned char[]'}arch/arm/crypto/aes-neonbs-glue.c:36:17: note: in a call to function 'aesbs_ctr_encrypt'
36 | asmlinkage void aesbs_ctr_encrypt(u8 out[], u8 const in[], u8 const rk[],This could happen in theory if walk.nbytes is larger than
INT_MAXand gets converted to a negative local variable.
Quoted 8 lines
Keep the type unsigned like the orignal nbytes to be sure there is no integer overflow.
Fixes c8bf850e991a ("crypto: arm/aes-neonbs-ctr - deal with non-multiples of AES block size")Signed-off-by Arnd Bergmann <[email protected]>--- arch/arm/crypto/aes-neonbs-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt