net: mvpp2: fix double free of the replaced rule in mvpp2_ethtool_cls_rule_ins()
Subsystems (3)
PATCH 1/1 net: mvpp2: fix double free of the replaced rule in mvpp2_ethtool_cls_rule_ins()
When a rule already exists at the requested location, mvpp2_ethtool_cls_rule_ins() removes it from the hardware and frees it, but leaves port->rfs_rules[loc] pointing at the freed structure. If inserting the new rule then fails, the next rule insertion will free the rule once again.
Clear the slot as soon as the old rule has been freed.
This bug was statically found and theoretical. Compile tested only.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +1 -0
@@ -1405,6 +1405,7 @@ int mvpp2_ethtool_cls_rule_ins(struct mvpp2_port *port,if (ret) goto clean_eth_rule;kfree (old_efs); + port->rfs_rules[efs->rule.loc] =NULL ; port->n_rfs_rules--; }
Signature · 1 line
2.53.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 4 Nov 2026 13:02:23 +0100 you wrote:
When a rule already exists at the requested location,
mvpp2_ethtool_cls_rule_ins()removes it from the hardware and frees it, but leaves port->rfs_rules[loc] pointing at the freed structure. If inserting the new rule then fails, the next rule insertion will free the rule once again.Clear the slot as soon as the old rule has been freed.
[...]
Here is the summary with links:
- [net] net: mvpp2: fix double free of the replaced rule in mvpp2_ethtool_cls_rule_ins()
https://git.kernel.org/netdev/net-next/c/d26955e57475
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html