Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: fix heap-use-after free on ns shutdown (backport #17020) #17141

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion zebra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,23 @@ void zebra_finalize(struct event *dummy)
zebra_ns_notify_close();

/* Final shutdown of ns resources */
ns_walk_func(zebra_ns_final_shutdown, NULL, NULL);
ns_walk_func(zebra_ns_kernel_shutdown, NULL, NULL);

zebra_router_terminate();

<<<<<<< HEAD
=======
zebra_mpls_terminate();

zebra_pw_terminate();

zebra_srv6_terminate();

label_manager_terminate();

ns_walk_func(zebra_ns_final_shutdown, NULL, NULL);

>>>>>>> 7ae70eb5ef (zebra: fix heap-use-after free on ns shutdown)
ns_terminate();
frr_fini();
exit(0);
Expand Down
20 changes: 17 additions & 3 deletions zebra/zebra_ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ int zebra_ns_early_shutdown(struct ns *ns,
return NS_WALK_CONTINUE;
}

/* During zebra shutdown, do kernel cleanup
* netlink sockets, ..
*/
int zebra_ns_kernel_shutdown(struct ns *ns, void *param_in __attribute__((unused)),
void **param_out __attribute__((unused)))
{
struct zebra_ns *zns = ns->info;

if (zns == NULL)
return NS_WALK_CONTINUE;

kernel_terminate(zns, true);

return NS_WALK_CONTINUE;
}

/* During zebra shutdown, do final cleanup
* after all dataplane work is complete.
*/
Expand All @@ -164,9 +180,7 @@ int zebra_ns_final_shutdown(struct ns *ns,
struct zebra_ns *zns = ns->info;

if (zns == NULL)
return 0;

kernel_terminate(zns, true);
return NS_WALK_CONTINUE;

return NS_WALK_CONTINUE;
}
Expand Down
7 changes: 7 additions & 0 deletions zebra/zebra_ns.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ int zebra_ns_early_shutdown(struct ns *ns,
int zebra_ns_final_shutdown(struct ns *ns,
void *param_in __attribute__((unused)),
void **param_out __attribute__((unused)));
<<<<<<< HEAD
int zebra_ns_config_write(struct vty *vty, struct ns *ns);
=======
int zebra_ns_kernel_shutdown(struct ns *ns, void *param_in __attribute__((unused)),
void **param_out __attribute__((unused)));

void zebra_ns_startup_continue(struct zebra_dplane_ctx *ctx);
>>>>>>> 7ae70eb5ef (zebra: fix heap-use-after free on ns shutdown)

#ifdef __cplusplus
}
Expand Down
Loading