babeld: fix NULL pointer dereference in babel_clean_routing_process#20727
babeld: fix NULL pointer dereference in babel_clean_routing_process#20727Jafaral merged 1 commit intoFRRouting:masterfrom
Conversation
Greptile OverviewGreptile SummaryAdded NULL pointer check in Key Changes:
Impact:
The fix is minimal, defensive, and follows common NULL-checking patterns used throughout the codebase. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Signal as Signal Handler
participant Exit as babel_exit_properly()
participant Clean as babel_clean_routing_process()
participant BRP as babel_routing_process
participant Event as event_cancel()
Note over Signal,Event: Scenario: SIGINT/SIGTERM received
Signal->>Exit: SIGINT or SIGTERM signal
Exit->>Clean: Call cleanup function
alt babel_routing_process is NULL
Clean->>BRP: Check if babel_routing_process is NULL
Note over Clean,BRP: Early return - prevents crash
Clean-->>Exit: Return early
else babel_routing_process is valid
Clean->>BRP: Check if babel_routing_process is NULL
Clean->>Event: event_cancel(&babel_routing_process->t_read)
Clean->>Event: event_cancel(&babel_routing_process->t_update)
Clean->>BRP: distribute_list_delete()
Clean->>BRP: XFREE(babel_routing_process)
Clean->>BRP: Set babel_routing_process = NULL
Note over Clean,BRP: Prevents use-after-free on subsequent calls
Clean-->>Exit: Return successfully
end
|
c02c53b to
a336398
Compare
|
@Mergifyio backport dev/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 |
✅ Backports have been createdDetails
Cherry-pick of cb76f18 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Cherry-pick of cb76f18 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Cherry-pick of cb76f18 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
you have a great analysis in the PR's comments, so why didn't you put the same thing in the commit message? Why would we not want to have that data preserrved there? |
a336398 to
84f7bfc
Compare
When babeld receives an exit signal (SIGINT/SIGTERM) during shutdown or when `babel_routing_process` is NULL (never initialized or already freed), the program crashes with SIGSEGV due to a NULL pointer dereference in `babel_clean_routing_process()`. The function accesses `babel_routing_process->t_read` and `babel_routing_process->t_update` without checking if `babel_routing_process` is NULL first. This can occur when: 1. The program receives an exit signal before `babel_routing_process` is fully initialized 2. `babel_routing_process` initialization fails but the cleanup function is still called 3. The cleanup function is called multiple times Fix: Add early return if babel_routing_process is NULL, and set it to NULL after freeing to prevent double-free issues. Signed-off-by: LyZephyr <yunzheli@smail.nju.edu.cn>
84f7bfc to
cb76f18
Compare
I’ve updated the commit message as suggested, thanks for the feedback. |
babeld: fix NULL pointer dereference in babel_clean_routing_process (backport #20727)
babeld: fix NULL pointer dereference in babel_clean_routing_process (backport #20727)
When babeld receives an exit signal (SIGINT/SIGTERM) during shutdown or when
babel_routing_processis NULL (never initialized or already freed), the program crashes with SIGSEGV due to a NULL pointer dereference inbabel_clean_routing_process(). The function accessesbabel_routing_process->t_readandbabel_routing_process->t_updatewithout checking ifbabel_routing_processis NULL first.This can occur when:
babel_routing_processis fully initializedbabel_routing_processinitialization fails but the cleanup function is still called