Skip to content

pimd: Fix crash when up->channel_oil is NULL - #21961

Merged
Jafaral merged 1 commit into
FRRouting:masterfrom
usrivastava-nvidia:usrivastava/pimd_crash
May 18, 2026
Merged

pimd: Fix crash when up->channel_oil is NULL#21961
Jafaral merged 1 commit into
FRRouting:masterfrom
usrivastava-nvidia:usrivastava/pimd_crash

Conversation

@usrivastava-nvidia

Copy link
Copy Markdown
Contributor

The up->channel_oil is being de-referenced
without any NULL check.
In events like VRF migration, where the timer fires in some cases when the up->channel_oil is already deleted it could lead to intermittent crash.

The up->channel_oil is being de-referenced
without any NULL check.
In events like VRF migration, where the timer fires
in some cases when the up->channel_oil is already deleted
it could lead to intermittent crash.

Signed-off-by: usrivastava-nvidia <usrivastava@nvidia.com>
@greptile-apps

greptile-apps Bot commented May 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds NULL checks for up->channel_oil in five timer-driven code paths in pimd/pim_dm.c and pimd/pim_upstream.c to prevent a crash when the oil entry is freed (e.g. during VRF migration) before a pending timer fires.

  • pimd/pim_dm.c: Guards pim_dm_prune_iff_on_timer so that channel_oil->installed is only accessed when channel_oil is non-NULL before calling oil_if_set and pim_upstream_mroute_update.
  • pimd/pim_upstream.c: Applies the same NULL guard pattern to on_graft_timer, on_staterefresh_timer, on_prune_timer, pim_upstream_sg_running_proc, and pim_upstream_sg_running, all of which previously dereferenced channel_oil unconditionally.

Confidence Score: 5/5

Safe to merge β€” the change is a targeted defensive fix that prevents NULL dereference crashes without altering any control flow when channel_oil is present.

All six changed call sites follow the same straightforward pattern: a simple short-circuit guard is added before an unconditional pointer dereference. The guards are consistent with how similar NULL checks appear elsewhere in the codebase, and no logic is changed for the non-NULL path.

No files require special attention. Both changed files are small, focused, and the pattern is uniform across all touch points.

Important Files Changed

Filename Overview
pimd/pim_dm.c Adds NULL guard for channel_oil in pim_dm_prune_iff_on_timer before accessing ->installed and calling downstream mroute functions.
pimd/pim_upstream.c Adds NULL guards for channel_oil in timer/callback functions (on_graft_timer, on_staterefresh_timer, on_prune_timer, pim_upstream_sg_running_proc, pim_upstream_sg_running) to prevent crash when channel_oil is freed during VRF migration.

Sequence Diagram

sequenceDiagram
    participant Timer as Timer Event
    participant Handler as Timer Handler
    participant Oil as channel_oil
    participant MRoute as MRoute Subsystem

    Note over Oil: VRF migration frees channel_oil
    Timer->>Handler: fires (up still alive)
    Handler->>Handler: "up = EVENT_ARG(t)"
    Handler->>Handler: check !up β†’ OK
    Handler->>Oil: "(BEFORE fix) up->channel_oil->installed β†’ CRASH"
    Handler->>Oil: "(AFTER fix) up->channel_oil != NULL?"
    alt channel_oil is NULL
        Handler->>Handler: return early (no crash)
    else channel_oil exists and installed
        Handler->>MRoute: pim_mroute_update_counters / oil_if_set
    end
Loading

Reviews (1): Last reviewed commit: "pimd: Fix crash when up->channel_oil is ..." | Re-trigger Greptile

@Jafaral

Jafaral commented May 18, 2026

Copy link
Copy Markdown
Member

@Mergifyio backport stable/10.6 stable/10.5 stable/10.4

@Jafaral
Jafaral merged commit cb1e694 into FRRouting:master May 18, 2026
25 checks passed
@mergify

mergify Bot commented May 18, 2026

Copy link
Copy Markdown

backport stable/10.6 stable/10.5 stable/10.4

βœ… Backports have been created

Details

Jafaral added a commit that referenced this pull request May 18, 2026
pimd: Fix crash when up->channel_oil is NULL (backport #21961)
donaldsharp added a commit that referenced this pull request May 18, 2026
pimd: Fix crash when up->channel_oil is NULL (backport #21961)
donaldsharp added a commit that referenced this pull request May 18, 2026
pimd: Fix crash when up->channel_oil is NULL (backport #21961)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants