pimd: Auto-RP hardening for discovery and announcements - #21745
Conversation
Jafaral
commented
Apr 22, 2026
- Cap learned Auto-RP RPs and groups per RP per message (fixed upper bounds).
- Validate Auto-RP multicast group prefixes; drop bad data and avoid leaking half-built prefix-lists on parse failure.
- When candidate RPs are configured, accept announcements only from the RP address or a matching configured candidate; otherwise drop.
- Delete superseded AUTORP*_ prefix-lists when an RP refresh uses a new group-list name.
Greptile SummaryThis PR hardens the Auto-RP announcement and discovery paths against malformed or malicious traffic by adding a two-pass prescan for announcements, enforcing per-RP group-count and prefix-validity bounds, adding source-authorization gating, and cleaning up orphaned
Confidence Score: 4/5The announcement hardening is structurally sound; the discovery-path changes are more manually managed and carry residual risk around prefix-list ownership across the caller/callee boundary. The prescan-then-apply architecture for announcements cleanly solves the partial-state problem and source-auth bypass. The capacity check in pim_autorp_add_rp is now correctly placed before pim_rp_new. The discovery path grp_parse_ok flag and caller-side prefix_list_delete on failure properly close the orphaned-prefix-list gaps. The interaction between the caller-managed prefix-list lifecycle and the superseded-list deletion inside pim_autorp_add_rp is correct but non-obvious; a regression there would silently install an RP against a stale or double-freed prefix-list object. pimd/pim_autorp.c β specifically the multi-group discovery path's prefix-list ownership handoff between autorp_recv_discovery and pim_autorp_add_rp, and the superseded-list deletion logic for RP group-list name transitions. Important Files Changed
Sequence DiagramsequenceDiagram
participant Net as Network
participant Recv as autorp_recv_msg
participant Pre as autorp_announcement_prescan_ok
participant Apply as autorp_announcement_apply_mapping_rp
participant List as mapping_rp_list
Net->>Recv: PIMv2 Auto-RP Announcement packet
Recv->>Pre: rpcnt, buf, src
loop For each RP in packet (prescan)
Pre->>Pre: Skip PIMv1/unknown RPs (advance offset)
Pre->>Pre: pim_autorp_allowed_announce_src(src, rp_addr)
alt Source unauthorized
Pre-->>Recv: return false (drop entire packet)
end
Pre->>Pre: "grpcnt == 0 continue"
Pre->>Pre: "grpcnt > MAX_GROUPS_PER_RP return false"
Pre->>Pre: Validate each group prefix
Pre->>Pre: Check capacity (pending_new tracking)
end
Pre-->>Recv: return true
loop For each RP in packet (apply)
Recv->>Recv: Skip PIMv1/unknown RPs
alt "grpcnt == 0"
Recv->>List: Find existing RP
List-->>Recv: ma_rp (if exists)
Recv->>Recv: autorp_mapping_rp_restart_holdtimer
else "grpcnt > 0"
Recv->>Apply: holdtime, rp, rp_addr, buf, offset
Apply->>List: autorp_mapping_rp_get_or_create(rp_addr)
Apply->>Apply: Build groups into new_grps (staging list)
alt Parse error or invalid prefix
Apply->>List: Remove RP if newly created (abort)
Apply-->>Recv: return false
end
Apply->>List: Swap new_grps into ma_rp.grp_pfix_list
Apply->>List: autorp_mapping_rp_restart_holdtimer
Apply-->>Recv: return true
end
end
Reviews (13): Last reviewed commit: "pimd: tighten Auto-RP announcement accep..." | Re-trigger Greptile |
ea0eef2 to
363ffd9
Compare
|
@greptile review |
363ffd9 to
bf8afa1
Compare
|
@greptile review |
bf8afa1 to
8ac8e23
Compare
|
@greptile review |
8ac8e23 to
7f68649
Compare
|
@greptile review |
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 |
β Backports have been createdDetails
|
| ma_rp = trp; | ||
| /* Free the existing group prefix list, in case the advertised groups changed */ | ||
| pim_autorp_grppfix_free(&ma_rp->grp_pfix_list); | ||
| { |
There was a problem hiding this comment.
why do we need this open bracket? Seems odd and gives us more lines of code changes
|
|
||
| static bool pim_autorp_group_prefix_valid(const struct prefix *grp) | ||
| { | ||
| return grp->family == AF_INET && grp->prefixlen <= IPV4_MAX_BITLEN && |
There was a problem hiding this comment.
pim_autorp.c is only compiled for v4. Why do we need this test to check it's v4 ?
There was a problem hiding this comment.
We still need to guards against a corrupted struct prefix built from packets received on the wire.
| * announced from an unauthorized source β avoids applying a prefix of RPs | ||
| * before failing mid-packet. | ||
| */ | ||
| { |
There was a problem hiding this comment.
why do we need an open paranthesis here?
| * announced from an unauthorized source β avoids applying a prefix of RPs | ||
| * before failing mid-packet. | ||
| */ | ||
| { |
There was a problem hiding this comment.
I'd like to see this moved to a new announcement validation function
| /* Free the existing group prefix list, in case the advertised groups changed */ | ||
| pim_autorp_grppfix_free(&ma_rp->grp_pfix_list); | ||
| } | ||
| { |
There was a problem hiding this comment.
This can probably be made a bit cleaner as well if the storing of the announced RP is split out into it's own function as well.
|
@greptile review |
1 similar comment
|
@greptile review |
|
@greptile review |
Define fixed upper bounds for mapping-agent learned RPs and for how many group ranges can be advertised per RP in one message. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
|
@greptile review |
|
@greptile review |
Reject bogus mask/address combinations early and discard prefix-list builds when validation fails mid-parse so temporary lists are not leaked. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
When local candidate-RP configuration exists, require announcements to come from the RP address or a configured candidate address; otherwise drop. Drop superseded Auto-RP-generated prefix lists when discovery refreshes an RP with a new group-list name. Apply source authentication in the announcement prescan before skipping RPs with grpcnt zero. Parse advertised groups into a temporary sorted list and only replace the mapping RP prefix list after a full successful parse; discard a newly inserted mapping RP entry if parsing fails. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
pimd: Auto-RP hardening for discovery and announcements (backport #21745)