* [PATCH] crypto: chtls - use 64-bit arithmetic instead of 32-bit
@ 2018-07-04 16:37 Gustavo A. R. Silva
2018-07-13 10:33 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-04 16:37 UTC (permalink / raw)
To: Harsh Jain, Herbert Xu, David S. Miller
Cc: linux-crypto, linux-kernel, Gustavo A. R. Silva
Cast *val* to u64 in order to give the compiler complete
information about the proper arithmetic to use.
Notice that such variable is used in a context that expects an
expression of type u64 (64 bits, unsigned) and the following
expression is currently being evaluated using 32-bit arithmetic:
val << bit_pos
Addresses-Coverity-ID: 1467425 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/crypto/chelsio/chtls/chtls_hw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/chelsio/chtls/chtls_hw.c b/drivers/crypto/chelsio/chtls/chtls_hw.c
index 55d5014..4909607 100644
--- a/drivers/crypto/chelsio/chtls/chtls_hw.c
+++ b/drivers/crypto/chelsio/chtls/chtls_hw.c
@@ -97,7 +97,7 @@ static int chtls_set_tcb_field(struct sock *sk, u16 word, u64 mask, u64 val)
int chtls_set_tcb_tflag(struct sock *sk, unsigned int bit_pos, int val)
{
return chtls_set_tcb_field(sk, 1, 1ULL << bit_pos,
- val << bit_pos);
+ (u64)val << bit_pos);
}
static int chtls_set_tcb_keyid(struct sock *sk, int keyid)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: chtls - use 64-bit arithmetic instead of 32-bit
2018-07-04 16:37 [PATCH] crypto: chtls - use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-07-13 10:33 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2018-07-13 10:33 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Harsh Jain, David S. Miller, linux-crypto, linux-kernel
On Wed, Jul 04, 2018 at 11:37:20AM -0500, Gustavo A. R. Silva wrote:
> Cast *val* to u64 in order to give the compiler complete
> information about the proper arithmetic to use.
>
> Notice that such variable is used in a context that expects an
> expression of type u64 (64 bits, unsigned) and the following
> expression is currently being evaluated using 32-bit arithmetic:
>
> val << bit_pos
>
> Addresses-Coverity-ID: 1467425 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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] 2+ messages in thread
end of thread, other threads:[~2018-07-13 10:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-04 16:37 [PATCH] crypto: chtls - use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-07-13 10:33 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).