Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: fix potential overflow when multiplying to u32 integers

The multiplication of the u32 variables tx_time and estimated_retx is
performed using a 32 bit multiplication and the result is stored in
a u64 result. This has a potential u32 overflow issue, so avoid this
by casting tx_time to a u64 to force a 64 bit multiply.

Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 050ac52cbe1f ("mac80211: code for on-demand Hybrid Wireless Mesh Protocol")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210205175352.208841-1-colin.king@canonical.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Colin Ian King and committed by
Johannes Berg
6194f7e6 10cb8e61

+1 -1
+1 -1
net/mac80211/mesh_hwmp.c
··· 356 356 */ 357 357 tx_time = (device_constant + 10 * test_frame_len / rate); 358 358 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); 359 - result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT); 359 + result = ((u64)tx_time * estimated_retx) >> (2 * ARITH_SHIFT); 360 360 return (u32)result; 361 361 } 362 362