* [PATCH] net: microchip: vcap: stop scanning after deleting key field
@ 2026-09-25 6:39 Harshit Mogalapalli
2026-09-25 13:06 ` Daniel Machon
2026-09-30 9:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Harshit Mogalapalli @ 2026-09-25 6:39 UTC (permalink / raw)
To: Steen Hegelund, Daniel Machon, UNGLinuxDriver, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-arm-kernel, netdev, linux-kernel
Cc: kernel-janitors, error27, harshit.m.mogalapalli
The only call outside the KUnit tests is in
sparx5_tc_add_rule_copy(), which passes a fixed key list with no
duplicate entries. Therefore, the potential double-free is not
currently reachable in tree.
However, vcap_filter_rule_keys() is exported and does not require its
key list entries to be unique. If a future or external caller supplies
the same key at another position that the inner loop visits, it calls
list_del() and kfree() a second time on the freed field, leading to a
potential double-free.
Break the inner loop after removing a matching field. The outer safe
list traversal continues to process the remaining rule fields.
Fixes: 465a38a269e9 ("net: microchip: sparx5: Support for copying and modifying rules in the API")
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/all/ahs-lCAXXikkaHky@stanley.mountain/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
drivers/net/ethernet/microchip/vcap/vcap_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c
index 788c0728d763..0f8d98f2094d 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
@@ -3527,8 +3527,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule,
if (key == keylist[idx]) {
list_del(&ckf->ctrl.list);
kfree(ckf);
- idx++;
err = 0;
+ break;
}
}
}
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: microchip: vcap: stop scanning after deleting key field
2026-09-25 6:39 [PATCH] net: microchip: vcap: stop scanning after deleting key field Harshit Mogalapalli
@ 2026-09-25 13:06 ` Daniel Machon
2026-09-30 9:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Machon @ 2026-09-25 13:06 UTC (permalink / raw)
To: Harshit Mogalapalli
Cc: Steen Hegelund, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-arm-kernel,
netdev, linux-kernel, kernel-janitors, error27
> The only call outside the KUnit tests is in
> sparx5_tc_add_rule_copy(), which passes a fixed key list with no
> duplicate entries. Therefore, the potential double-free is not
> currently reachable in tree.
Agree. Not reachable today.
>
> However, vcap_filter_rule_keys() is exported and does not require its
> key list entries to be unique. If a future or external caller supplies
> the same key at another position that the inner loop visits, it calls
> list_del() and kfree() a second time on the freed field, leading to a
> potential double-free.
>
Also agree.
> Break the inner loop after removing a matching field. The outer safe
> list traversal continues to process the remaining rule fields.
>
> Fixes: 465a38a269e9 ("net: microchip: sparx5: Support for copying and modifying rules in the API")
> Reported-by: Dan Carpenter <error27@gmail.com>
> Closes: https://lore.kernel.org/all/ahs-lCAXXikkaHky@stanley.mountain/
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> drivers/net/ethernet/microchip/vcap/vcap_api.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> index 788c0728d763..0f8d98f2094d 100644
> --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
> +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> @@ -3527,8 +3527,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule,
> if (key == keylist[idx]) {
> list_del(&ckf->ctrl.list);
> kfree(ckf);
> - idx++;
> err = 0;
> + break;
> }
> }
> }
> --
> 2.52.0
>
Patch is missing the target tree (net), the fix LGTM.
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: microchip: vcap: stop scanning after deleting key field
2026-09-25 6:39 [PATCH] net: microchip: vcap: stop scanning after deleting key field Harshit Mogalapalli
2026-09-25 13:06 ` Daniel Machon
@ 2026-09-30 9:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-30 9:30 UTC (permalink / raw)
To: Harshit Mogalapalli
Cc: Steen.Hegelund, daniel.machon, UNGLinuxDriver, andrew+netdev,
davem, edumazet, kuba, pabeni, linux-arm-kernel, netdev,
linux-kernel, kernel-janitors, error27
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 24 Sep 2026 23:39:36 -0700 you wrote:
> The only call outside the KUnit tests is in
> sparx5_tc_add_rule_copy(), which passes a fixed key list with no
> duplicate entries. Therefore, the potential double-free is not
> currently reachable in tree.
>
> However, vcap_filter_rule_keys() is exported and does not require its
> key list entries to be unique. If a future or external caller supplies
> the same key at another position that the inner loop visits, it calls
> list_del() and kfree() a second time on the freed field, leading to a
> potential double-free.
>
> [...]
Here is the summary with links:
- net: microchip: vcap: stop scanning after deleting key field
https://git.kernel.org/netdev/net/c/99b43ede9e35
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-30 9:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 6:39 [PATCH] net: microchip: vcap: stop scanning after deleting key field Harshit Mogalapalli
2026-09-25 13:06 ` Daniel Machon
2026-09-30 9:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®