[lvc-project] [EXT] [PATCH net] octeontx2-af: Fix possible buffer overflow
Subbaraya Sundeep Bhatta
sbhatta at marvell.com
Tue Nov 28 06:16:30 MSK 2023
Hi,
>-----Original Message-----
>From: Elena Salomatkina <elena.salomatkina.cmc at gmail.com>
>Sent: Saturday, November 25, 2023 2:38 AM
>To: Sunil Kovvuri Goutham <sgoutham at marvell.com>
>Cc: Elena Salomatkina <elena.salomatkina.cmc at gmail.com>; Linu Cherian
><lcherian at marvell.com>; Geethasowjanya Akula <gakula at marvell.com>;
>Jerin Jacob Kollanukkaran <jerinj at marvell.com>; Hariprasad Kelam
><hkelam at marvell.com>; Subbaraya Sundeep Bhatta <sbhatta at marvell.com>;
>David S. Miller <davem at davemloft.net>; Eric Dumazet
><edumazet at google.com>; Jakub Kicinski <kuba at kernel.org>; Paolo Abeni
><pabeni at redhat.com>; netdev at vger.kernel.org; linux-
>kernel at vger.kernel.org; lvc-project at linuxtesting.org; Simon Horman
><horms at 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 at gmail.com>
>Reviewed-by: Simon Horman <horms at kernel.org>
Reviewed-by: Subbaraya Sundeep <sbhatta at 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
More information about the lvc-project
mailing list