octeontx2-af: Fix possible buffer overflow
[ Upstream commit ad31c629ca3c87f6d557488c1f9faaebfbcd203c ]
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: e8e095b3b3
("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c3e974e9c4
commit
334e6378c2
@ -5236,6 +5236,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)
|
||||
@ -5249,8 +5251,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);
|
||||
|
Loading…
Reference in New Issue
Block a user