lib: add missing hook_unregister_arg in mgmt_be_client_destroy#21940
Conversation
mgmt_be_client_create() registers a hook on nb_notification_tree_send but mgmt_be_client_destroy() never unregisters it. During shutdown, the client struct gets freed while the hook still points to it. When the subscription wheel timer fires after that, it dispatches to mgmt_be_send_notification() with the freed pointer and crashes. ZEBRA: Received signal 11 (si_addr 0x108000001d0) libfrr.so.0(nb_notification_tree_send+0x69) libfrr.so.0(nb_notification_send+0x165) libfrr.so.0(nb_notify_subscriptions+0xb8) libfrr.so.0(event_call+0x81) in thread wheel_timer_thread scheduled from ../lib/wheel.c:50 Fix by adding hook_unregister_arg() before freeing the client. Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
Greptile SummaryThis PR fixes a use-after-free crash in
Confidence Score: 5/5Safe to merge — the change adds the single missing teardown call that was already expected by the symmetric create path. The fix is a one-to-one complement of the existing hook_register_arg call in mgmt_be_client_create(). The unregister is placed before any XFREE call, so the client pointer is valid at the time of unregistration. There are no other hook registrations in this file left without matching unregistrations. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "lib: add missing hook_unregister_arg in ..." | Re-trigger Greptile |
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 |
✅ Backports have been createdDetails
|
Issue:
mgmt_be_client_create() registers a hook on nb_notification_tree_send but mgmt_be_client_destroy() never unregisters it. During shutdown, the client struct gets freed while the hook still points to it. When the subscription wheel timer fires after that, it dispatches to mgmt_be_send_notification() with the freed pointer and crashes.
Fix by adding hook_unregister_arg() before freeing the client.
Signed-off-by: Rajesh Varatharaj rvaratharaj@nvidia.com