lib: fix use-after-free of src_table in srcdest_srcnode_destroy - #22722
Open
nsoma-cisco wants to merge 1 commit into
Open
lib: fix use-after-free of src_table in srcdest_srcnode_destroy#22722nsoma-cisco wants to merge 1 commit into
nsoma-cisco wants to merge 1 commit into
Conversation
Greptile SummaryThis PR prevents a dangling source-table pointer during route teardown. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "lib: Fix use-after-free of src_table in ..." | Re-trigger Greptile |
nsoma-cisco
force-pushed
the
nsoma_master_zebra_uaf_src_tbl
branch
2 times, most recently
from
July 27, 2026 18:50
7310525 to
be9f1df
Compare
Null srn->src_table before calling route_table_finish so that any re-entrant call to srcdest_srcnode_destroy (via route_table_free → route_node_free → destroy_node during the finish sweep) reads NULL rather than a pointer to memory that is already being freed. Without this, route_table_finish frees the route_table struct while srn->src_table still points to it. A subsequent dplane FIB notification for the same destination prefix calls srcdest_rnode_get → srcdest_srcnode_get, which checks `if (!srn->src_table)` — the guard evaluates false because the pointer is non-NULL (dangling) — and passes the freed struct to route_node_get, causing a SIGSEGV. This mirrors the identical null-before-finish pattern already used in srcdest_rnode_destroy and described in its comment. Signed-off-by: Nageswara Soma <nsoma@cisco.com>
nsoma-cisco
force-pushed
the
nsoma_master_zebra_uaf_src_tbl
branch
from
July 30, 2026 17:52
be9f1df to
d1b43cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a use-after-free of
src_tableinlib/srcdest_table.c:srcdest_srcnode_destroy().Root cause
srcdest_srcnode_destroy()freedsrn->src_tableviaroute_table_finish()before nulling the pointer. After
route_table_finish()returned,srn->src_tablestill held the address of the freedroute_tablestruct.A subsequent dplane FIB notification for the same destination prefix calls
srcdest_rnode_get() → srcdest_srcnode_get(), which guards new-table creationwith
if (!srn->src_table). Because the pointer was non-NULL (dangling), theguard evaluated false and the freed struct was passed to
route_node_get(),causing a SIGSEGV.
route_table_finish()can also re-entersrcdest_srcnode_destroy()for theremaining nodes during the finish sweep
(
route_table_free → route_node_free → destroy_node); any such re-entrant readof
srn->src_tableobserved the same dangling pointer.Fix
Null
srn->src_tablebefore callingroute_table_finish(), mirroring theidentical null-before-finish pattern already present and commented in
srcdest_rnode_destroy():With the pointer nulled first, any re-entrant call to
srcdest_srcnode_destroy()during the finish sweep seesNULLand exitscleanly, and any subsequent call to
srcdest_srcnode_get()allocates a fresh,valid
route_tableinstead of dereferencing freed memory.Test plan