]> git.puffer.fish Git - matthieu/frr.git/commit
zebra: Fix use-after-free issue in srte cleanup
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Fri, 18 Nov 2022 12:19:14 +0000 (13:19 +0100)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Fri, 18 Nov 2022 12:19:14 +0000 (13:19 +0100)
commit22efe557f148ae43f8a7732bd0865eb3f17ad67c
tree1ad810280e6c17087744e27771615af1b1758916
parentb7de3fe8a9907d37f9f7726a87e488de7f1f9ec4
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>
zebra/zebra_srte.c