Skip to content

Commit

Permalink
pimd: prevent invalid memory access
Browse files Browse the repository at this point in the history
Signalize termination to functions so they can avoid accessing pointers
that might be no longer available.

Signed-off-by: Rafael Zalamena <[email protected]>
  • Loading branch information
rzalamena committed Sep 29, 2024
1 parent 2e52de3 commit 8c6f606
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pimd/pim_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

static void pim_instance_terminate(struct pim_instance *pim)
{
pim->stopping = true;

pim_vxlan_exit(pim);

if (pim->ssm_info) {
Expand Down
2 changes: 2 additions & 0 deletions pimd/pim_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ struct pim_instance {

uint64_t gm_rx_drop_sys;

bool stopping;

#if PIM_IPV == 6
struct {
/** Embedded RP enable state. */
Expand Down
7 changes: 7 additions & 0 deletions pimd/pim_tib.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,14 @@ void tib_sg_gm_prune(struct pim_instance *pim, pim_sgaddr sg,
Making the call to pim_channel_del_oif and ignoring the return code
fixes the issue without ill effect, similar to
pim_forward_stop below.
Also on shutdown when the PIM upstream is removed the channel removal
may have already happened, so just return here instead of trying to
access an invalid pointer.
*/
if (pim->stopping)
return;

result = pim_channel_del_oif(*oilp, oif, PIM_OIF_FLAG_PROTO_GM,
__func__);
if (result) {
Expand Down

0 comments on commit 8c6f606

Please sign in to comment.