* [PATCH net] octeontx2-af: Fix possible buffer overflow
@ 2023-11-24 21:08 Elena Salomatkina
2023-11-28 2:31 ` Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Elena Salomatkina @ 2023-11-24 21:08 UTC (permalink / raw)
To: Sunil Goutham
Cc: Elena Salomatkina, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project,
Simon Horman
A loop in rvu_mbox_handler_nix_bandprof_free() contains
a break if (idx == MAX_BANDPROF_PER_PFFUNC),
but if idx may reach MAX_BANDPROF_PER_PFFUNC
buffer '(*req->prof_idx)[layer]' overflow happens before that check.
The patch moves the break to the
beginning of the loop.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support").
Signed-off-by: Elena Salomatkina <elena.salomatkina.cmc@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
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 23c2f2ed2fb8..c112c71ff576 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -5505,6 +5505,8 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu,
ipolicer = &nix_hw->ipolicer[layer];
for (idx = 0; idx < req->prof_count[layer]; idx++) {
+ if (idx == MAX_BANDPROF_PER_PFFUNC)
+ break;
prof_idx = req->prof_idx[layer][idx];
if (prof_idx >= ipolicer->band_prof.max ||
ipolicer->pfvf_map[prof_idx] != pcifunc)
@@ -5518,8 +5520,6 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu,
ipolicer->pfvf_map[prof_idx] = 0x00;
ipolicer->match_id[prof_idx] = 0;
rvu_free_rsrc(&ipolicer->band_prof, prof_idx);
- if (idx == MAX_BANDPROF_PER_PFFUNC)
- break;
}
}
mutex_unlock(&rvu->rsrc_lock);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] octeontx2-af: Fix possible buffer overflow
2023-11-24 21:08 [PATCH net] octeontx2-af: Fix possible buffer overflow Elena Salomatkina
@ 2023-11-28 2:31 ` Jakub Kicinski
2023-11-28 3:16 ` [EXT] " Subbaraya Sundeep Bhatta
2023-11-28 10:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2023-11-28 2:31 UTC (permalink / raw)
To: Elena Salomatkina
Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
hariprasad, Subbaraya Sundeep, David S. Miller, Eric Dumazet,
Paolo Abeni, netdev, linux-kernel, lvc-project, Simon Horman
On Sat, 25 Nov 2023 00:08:02 +0300 Elena Salomatkina wrote:
> A loop in rvu_mbox_handler_nix_bandprof_free() contains
> a break if (idx == MAX_BANDPROF_PER_PFFUNC),
> but if idx may reach MAX_BANDPROF_PER_PFFUNC
> buffer '(*req->prof_idx)[layer]' overflow happens before that check.
>
> The patch moves the break to the
> beginning of the loop.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support").
> Signed-off-by: Elena Salomatkina <elena.salomatkina.cmc@gmail.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
Marvell folks, at least one of you has to review this. Please see:
https://docs.kernel.org/next/maintainer/feature-and-driver-maintainers.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [EXT] [PATCH net] octeontx2-af: Fix possible buffer overflow
2023-11-24 21:08 [PATCH net] octeontx2-af: Fix possible buffer overflow Elena Salomatkina
2023-11-28 2:31 ` Jakub Kicinski
@ 2023-11-28 3:16 ` Subbaraya Sundeep Bhatta
2023-11-28 10:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Subbaraya Sundeep Bhatta @ 2023-11-28 3:16 UTC (permalink / raw)
To: Elena Salomatkina, Sunil Kovvuri Goutham
Cc: Linu Cherian, Geethasowjanya Akula, Jerin Jacob Kollanukkaran,
Hariprasad Kelam, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org, Simon Horman
Hi,
>-----Original Message-----
>From: Elena Salomatkina <elena.salomatkina.cmc@gmail.com>
>Sent: Saturday, November 25, 2023 2:38 AM
>To: Sunil Kovvuri Goutham <sgoutham@marvell.com>
>Cc: Elena Salomatkina <elena.salomatkina.cmc@gmail.com>; Linu Cherian
><lcherian@marvell.com>; Geethasowjanya Akula <gakula@marvell.com>;
>Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Hariprasad Kelam
><hkelam@marvell.com>; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>;
>David S. Miller <davem@davemloft.net>; Eric Dumazet
><edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
><pabeni@redhat.com>; netdev@vger.kernel.org; linux-
>kernel@vger.kernel.org; lvc-project@linuxtesting.org; Simon Horman
><horms@kernel.org>
>Subject: [EXT] [PATCH net] octeontx2-af: Fix possible buffer overflow
>
>----------------------------------------------------------------------
>A loop in rvu_mbox_handler_nix_bandprof_free() contains a break if (idx ==
>MAX_BANDPROF_PER_PFFUNC), but if idx may reach
>MAX_BANDPROF_PER_PFFUNC buffer '(*req->prof_idx)[layer]' overflow
>happens before that check.
>
>The patch moves the break to the
>beginning of the loop.
>
>Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
>Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config
>support").
>Signed-off-by: Elena Salomatkina <elena.salomatkina.cmc@gmail.com>
>Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Subbaraya Sundeep <sbhatta@marvell.com>
Thanks,
Sundeep
>---
> 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 23c2f2ed2fb8..c112c71ff576 100644
>--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
>+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
>@@ -5505,6 +5505,8 @@ int rvu_mbox_handler_nix_bandprof_free(struct
>rvu *rvu,
>
> ipolicer = &nix_hw->ipolicer[layer];
> for (idx = 0; idx < req->prof_count[layer]; idx++) {
>+ if (idx == MAX_BANDPROF_PER_PFFUNC)
>+ break;
> prof_idx = req->prof_idx[layer][idx];
> if (prof_idx >= ipolicer->band_prof.max ||
> ipolicer->pfvf_map[prof_idx] != pcifunc) @@ -
>5518,8 +5520,6 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu
>*rvu,
> ipolicer->pfvf_map[prof_idx] = 0x00;
> ipolicer->match_id[prof_idx] = 0;
> rvu_free_rsrc(&ipolicer->band_prof, prof_idx);
>- if (idx == MAX_BANDPROF_PER_PFFUNC)
>- break;
> }
> }
> mutex_unlock(&rvu->rsrc_lock);
>--
>2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] octeontx2-af: Fix possible buffer overflow
2023-11-24 21:08 [PATCH net] octeontx2-af: Fix possible buffer overflow Elena Salomatkina
2023-11-28 2:31 ` Jakub Kicinski
2023-11-28 3:16 ` [EXT] " Subbaraya Sundeep Bhatta
@ 2023-11-28 10:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-28 10:00 UTC (permalink / raw)
To: Elena Salomatkina
Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
edumazet, kuba, pabeni, netdev, linux-kernel, lvc-project, horms
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sat, 25 Nov 2023 00:08:02 +0300 you wrote:
> A loop in rvu_mbox_handler_nix_bandprof_free() contains
> a break if (idx == MAX_BANDPROF_PER_PFFUNC),
> but if idx may reach MAX_BANDPROF_PER_PFFUNC
> buffer '(*req->prof_idx)[layer]' overflow happens before that check.
>
> The patch moves the break to the
> beginning of the loop.
>
> [...]
Here is the summary with links:
- [net] octeontx2-af: Fix possible buffer overflow
https://git.kernel.org/netdev/net/c/ad31c629ca3c
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:[~2023-11-28 10:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24 21:08 [PATCH net] octeontx2-af: Fix possible buffer overflow Elena Salomatkina
2023-11-28 2:31 ` Jakub Kicinski
2023-11-28 3:16 ` [EXT] " Subbaraya Sundeep Bhatta
2023-11-28 10:00 ` 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).