Skip to content

Commit ad31c62

Browse files
Elena SalomatkinaPaolo Abeni
authored andcommitted
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: e8e095b ("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> Link: https://lore.kernel.org/r/20231124210802.109763-1-elena.salomatkina.cmc@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent ec2610b commit ad31c62

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • drivers/net/ethernet/marvell/octeontx2/af

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,6 +5505,8 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu,
55055505

55065506
ipolicer = &nix_hw->ipolicer[layer];
55075507
for (idx = 0; idx < req->prof_count[layer]; idx++) {
5508+
if (idx == MAX_BANDPROF_PER_PFFUNC)
5509+
break;
55085510
prof_idx = req->prof_idx[layer][idx];
55095511
if (prof_idx >= ipolicer->band_prof.max ||
55105512
ipolicer->pfvf_map[prof_idx] != pcifunc)
@@ -5518,8 +5520,6 @@ int rvu_mbox_handler_nix_bandprof_free(struct rvu *rvu,
55185520
ipolicer->pfvf_map[prof_idx] = 0x00;
55195521
ipolicer->match_id[prof_idx] = 0;
55205522
rvu_free_rsrc(&ipolicer->band_prof, prof_idx);
5521-
if (idx == MAX_BANDPROF_PER_PFFUNC)
5522-
break;
55235523
}
55245524
}
55255525
mutex_unlock(&rvu->rsrc_lock);

0 commit comments

Comments
 (0)