* [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts
@ 2024-10-10 15:45 Colin Ian King
2024-10-10 18:25 ` Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Colin Ian King @ 2024-10-10 15:45 UTC (permalink / raw)
To: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Naveen Mamindlapalli, netdev
Cc: kernel-janitors, linux-kernel
The left shift int 32 bit integer constants 1 is evaluated using 32 bit
arithmetic and then assigned to a 64 bit unsigned integer. In the case
where the shift is 32 or more this can lead to an overflow. Avoid this
by shifting using the BIT_ULL macro instead.
Fixes: 019aba04f08c ("octeontx2-af: Modify SMQ flush sequence to drop packets")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
V2: Fix both (1 << i) shifts, thanks to Dan Carpenter for spotting the
second shift that I overlooked in the first patch.
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 82832a24fbd8..da69350c6f76 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2411,7 +2411,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));
if (!(cfg & BIT_ULL(12)))
continue;
- bmap |= (1 << i);
+ bmap |= BIT_ULL(i);
cfg &= ~BIT_ULL(12);
rvu_write64(rvu, blkaddr,
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link), cfg);
@@ -2432,7 +2432,7 @@ static int nix_smq_flush(struct rvu *rvu, int blkaddr,
/* Set NIX_AF_TL3_TL2_LINKX_CFG[ENA] for the TL3/TL2 queue */
for (i = 0; i < (rvu->hw->cgx_links + rvu->hw->lbk_links); i++) {
- if (!(bmap & (1 << i)))
+ if (!(bmap & BIT_ULL(i)))
continue;
cfg = rvu_read64(rvu, blkaddr,
NIX_AF_TL3_TL2X_LINKX_CFG(tl2_tl3_link_schq, link));
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts
2024-10-10 15:45 [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts Colin Ian King
@ 2024-10-10 18:25 ` Dan Carpenter
2024-10-15 11:32 ` Paolo Abeni
2024-10-15 11:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-10-10 18:25 UTC (permalink / raw)
To: Colin Ian King
Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Naveen Mamindlapalli, netdev,
kernel-janitors, linux-kernel
On Thu, Oct 10, 2024 at 04:45:19PM +0100, Colin Ian King wrote:
> The left shift int 32 bit integer constants 1 is evaluated using 32 bit
> arithmetic and then assigned to a 64 bit unsigned integer. In the case
> where the shift is 32 or more this can lead to an overflow. Avoid this
> by shifting using the BIT_ULL macro instead.
>
> Fixes: 019aba04f08c ("octeontx2-af: Modify SMQ flush sequence to drop packets")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>
> V2: Fix both (1 << i) shifts, thanks to Dan Carpenter for spotting the
> second shift that I overlooked in the first patch.
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts
2024-10-10 15:45 [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts Colin Ian King
2024-10-10 18:25 ` Dan Carpenter
@ 2024-10-15 11:32 ` Paolo Abeni
2024-10-15 11:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2024-10-15 11:32 UTC (permalink / raw)
To: Colin Ian King, Sunil Goutham, Linu Cherian, Geetha sowjanya,
Jerin Jacob, hariprasad, Subbaraya Sundeep, David S . Miller,
Eric Dumazet, Jakub Kicinski, Naveen Mamindlapalli, netdev
Cc: kernel-janitors, linux-kernel
On 10/10/24 17:45, Colin Ian King wrote:
> The left shift int 32 bit integer constants 1 is evaluated using 32 bit
> arithmetic and then assigned to a 64 bit unsigned integer. In the case
> where the shift is 32 or more this can lead to an overflow. Avoid this
> by shifting using the BIT_ULL macro instead.
>
> Fixes: 019aba04f08c ("octeontx2-af: Modify SMQ flush sequence to drop packets")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>
> V2: Fix both (1 << i) shifts, thanks to Dan Carpenter for spotting the
> second shift that I overlooked in the first patch.
The blamed commit is in the 'net' tree already, I'm applying the patch
there.
Cheers,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts
2024-10-10 15:45 [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts Colin Ian King
2024-10-10 18:25 ` Dan Carpenter
2024-10-15 11:32 ` Paolo Abeni
@ 2024-10-15 11:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-15 11:40 UTC (permalink / raw)
To: Colin Ian King
Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
edumazet, kuba, pabeni, naveenm, netdev, kernel-janitors,
linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 10 Oct 2024 16:45:19 +0100 you wrote:
> The left shift int 32 bit integer constants 1 is evaluated using 32 bit
> arithmetic and then assigned to a 64 bit unsigned integer. In the case
> where the shift is 32 or more this can lead to an overflow. Avoid this
> by shifting using the BIT_ULL macro instead.
>
> Fixes: 019aba04f08c ("octeontx2-af: Modify SMQ flush sequence to drop packets")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>
> [...]
Here is the summary with links:
- [next,V2] octeontx2-af: Fix potential integer overflows on integer shifts
https://git.kernel.org/netdev/net/c/637c4f6fe40b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-15 11:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 15:45 [PATCH][next][V2] octeontx2-af: Fix potential integer overflows on integer shifts Colin Ian King
2024-10-10 18:25 ` Dan Carpenter
2024-10-15 11:32 ` Paolo Abeni
2024-10-15 11:40 ` patchwork-bot+netdevbpf
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).