Skip to contentSkip to conversation

crypto: chtls - use 64-bit arithmetic instead of 32-bit

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jul 4, 2018 – Jul 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: chtls - use 64-bit arithmetic instead of 32-bit

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")

---
 drivers/crypto/chelsio/chtls/chtls_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/chelsio/chtls/chtls_hw.c +1 -1
index 55d5014..4909607 100644
@@ -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)
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 11 lines · 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")

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