Skip to content

staticd: Fix SRv6 SID use-after-free on locator deletion (backport #20660 for 10.5)#20701

Merged
Jafaral merged 2 commits intoFRRouting:stable/10.5from
cscarpitta:fix/backport_fix_srv6_sid_use_after_free_10.5
Feb 5, 2026
Merged

staticd: Fix SRv6 SID use-after-free on locator deletion (backport #20660 for 10.5)#20701
Jafaral merged 2 commits intoFRRouting:stable/10.5from
cscarpitta:fix/backport_fix_srv6_sid_use_after_free_10.5

Conversation

@cscarpitta
Copy link
Contributor

@cscarpitta cscarpitta commented Feb 4, 2026

Manual backport of #20660 for FRR 10.5.

Replaces #20690.

When a locator is removed, we iterate over the list of SIDs and
uninstall them from the data plane. However, the validity flag of
the SID remains set, and the locator pointer still points to the
freed locator memory.

This causes issues in other parts of the code where we check the
SID validity flag. Since the flag is still set, we assume the SID
is valid and attempt to access the locator pointer, resulting in
use-after-free crashes.

Fix this by:
- Unsetting the STATIC_FLAG_SRV6_SID_VALID flag to mark the SID
  as invalid when its locator is deleted
- Setting the locator pointer to NULL to indicate that the SID
  no longer has a locator associated with it

This ensures that when the locator is removed, associated SIDs are
properly marked as invalid and cannot accidentally reference freed
memory.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Add a test case that reproduces and validates the fix for the
locator deletion crash issue.

Without the fix, removing a locator leaves SIDs with the validity
flag set and a dangling pointer to the freed locator. Attempting
to remove those SIDs from configuration causes a use-after-free
crash when the code checks the validity flag and accesses the
freed locator pointer.

The test reproduces this by:
1. Removing a locator
2. Removing specific SIDs (crash point without the fix)
3. Re-adding the locator
4. Re-adding the removed SIDs

With the fix, the test passes and verifies that the locator
removal/re-addition workflow handles SID lifecycle correctly,
preventing future regressions.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
@frrbot frrbot bot added staticd tests Topotests, make check, etc labels Feb 4, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 4, 2026

Target branch is not in the allowed branches list.

@Jafaral Jafaral merged commit b4dea42 into FRRouting:stable/10.5 Feb 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants