mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 13:22:02 +00:00
zebra: Fix use-after-free issue in srte cleanup
Currently, in `zebra_srte_client_close_cleanup` we use the `RB_FOREACH` macro to traverse the SR policies tree. We remove the SR policies within the loop. Removing elements from the tree and freeing them is not safe and causes a use-after-free crash whenever the `zebra_srte_client_close_cleanup` is called to perform cleanup. This commit replaces the `RB_FOREACH` macro with its variant `RB_FOREACH_SAFE`. Unlike `RB_FOREACH`, `RB_FOREACH_SAFE` permits both the removal of tree elements as well as freeing them from within the loop safely. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
This commit is contained in:
parent
b7de3fe8a9
commit
22efe557f1
@ -387,13 +387,13 @@ int zebra_sr_policy_label_update(mpls_label_t label,
|
|||||||
static int zebra_srte_client_close_cleanup(struct zserv *client)
|
static int zebra_srte_client_close_cleanup(struct zserv *client)
|
||||||
{
|
{
|
||||||
int sock = client->sock;
|
int sock = client->sock;
|
||||||
struct zebra_sr_policy *policy;
|
struct zebra_sr_policy *policy, *policy_temp;
|
||||||
|
|
||||||
if (!sock)
|
if (!sock)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
RB_FOREACH (policy, zebra_sr_policy_instance_head,
|
RB_FOREACH_SAFE (policy, zebra_sr_policy_instance_head,
|
||||||
&zebra_sr_policy_instances) {
|
&zebra_sr_policy_instances, policy_temp) {
|
||||||
if (policy->sock == sock)
|
if (policy->sock == sock)
|
||||||
zebra_sr_policy_del(policy);
|
zebra_sr_policy_del(policy);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user