mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
net: sparx5: Fix use after free inside sparx5_del_mact_entry
[ Upstream commit 89d72d4125e94aa3c2140fedd97ce07ba9e37674 ]
Based on the static analyzis of the code it looks like when an entry
from the MAC table was removed, the entry was still used after being
freed. More precise the vid of the mac_entry was used after calling
devm_kfree on the mac_entry.
The fix consists in first using the vid of the mac_entry to delete the
entry from the HW and after that to free it.
Fixes: b37a1bae74 ("net: sparx5: add mactable support")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240301080608.3053468-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Sasha Levin
parent
e77e0b0f2a
commit
e46274df11
@@ -344,10 +344,10 @@ int sparx5_del_mact_entry(struct sparx5 *sparx5,
|
||||
list) {
|
||||
if ((vid == 0 || mact_entry->vid == vid) &&
|
||||
ether_addr_equal(addr, mact_entry->mac)) {
|
||||
sparx5_mact_forget(sparx5, addr, mact_entry->vid);
|
||||
|
||||
list_del(&mact_entry->list);
|
||||
devm_kfree(sparx5->dev, mact_entry);
|
||||
|
||||
sparx5_mact_forget(sparx5, addr, mact_entry->vid);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&sparx5->mact_lock);
|
||||
|
||||
Reference in New Issue
Block a user