|
| 1 | +From 3fd5c01f6e71de1ca05c1983f8762a7713ead7b2 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Carmine Scarpitta < [email protected]> |
| 3 | +Date: Mon, 2 Feb 2026 20:17:27 +0000 |
| 4 | +Subject: [PATCH] staticd: Unset SID validity flag when locator is deleted |
| 5 | + |
| 6 | +When a locator is removed, we iterate over the list of SIDs and |
| 7 | +uninstall them from the data plane. However, the validity flag of |
| 8 | +the SID remains set, and the locator pointer still points to the |
| 9 | +freed locator memory. |
| 10 | + |
| 11 | +This causes issues in other parts of the code where we check the |
| 12 | +SID validity flag. Since the flag is still set, we assume the SID |
| 13 | +is valid and attempt to access the locator pointer, resulting in |
| 14 | +use-after-free crashes. |
| 15 | + |
| 16 | +Fix this by: |
| 17 | +- Unsetting the STATIC_FLAG_SRV6_SID_VALID flag to mark the SID |
| 18 | + as invalid when its locator is deleted |
| 19 | +- Setting the locator pointer to NULL to indicate that the SID |
| 20 | + no longer has a locator associated with it |
| 21 | + |
| 22 | +This ensures that when the locator is removed, associated SIDs are |
| 23 | +properly marked as invalid and cannot accidentally reference freed |
| 24 | +memory. |
| 25 | + |
| 26 | +Signed-off-by: Carmine Scarpitta < [email protected]> |
| 27 | +--- |
| 28 | + staticd/static_zebra.c | 3 +++ |
| 29 | + 1 file changed, 3 insertions(+) |
| 30 | + |
| 31 | +diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c |
| 32 | +index b6757ed5b1b0..ceb60bfbc00b 100644 |
| 33 | +--- a/staticd/static_zebra.c |
| 34 | ++++ b/staticd/static_zebra.c |
| 35 | +@@ -1259,6 +1259,9 @@ static int static_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) |
| 36 | + static_zebra_srv6_sid_uninstall(sid); |
| 37 | + UNSET_FLAG(sid->flags, STATIC_FLAG_SRV6_SID_SENT_TO_ZEBRA); |
| 38 | + } |
| 39 | ++ |
| 40 | ++ sid->locator = NULL; |
| 41 | ++ UNSET_FLAG(sid->flags, STATIC_FLAG_SRV6_SID_VALID); |
| 42 | + } |
| 43 | + |
| 44 | + listnode_delete(srv6_locators, locator); |
0 commit comments