Skip to content

Conversation

petrvaganoff
Copy link
Contributor

Found by the static analyzer Svace (ISP RAS): DEREF_OF_NULL.EX.COND. After having been assigned to a NULL value at bgp_updgrp_packet.c:717, pointer 'from' is passed as 9th parameter in call to function 'bgp_packet_attribute' at bgp_updgrp_packet.c:746, where it is dereferenced at bgp_attr.c:4638.

@frrbot frrbot bot added the bgp label Jul 3, 2025
@petrvaganoff petrvaganoff force-pushed the dev-51247 branch 2 times, most recently from 441f721 to c7e6b65 Compare July 3, 2025 10:12
@ton31337
Copy link
Member

ton31337 commented Jul 3, 2025

@Mergifyio backport dev/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0

Copy link

mergify bot commented Jul 3, 2025

backport dev/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0

✅ Backports have been created

Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@petrvaganoff
Copy link
Contributor Author

ci:rerun

bgpd/bgpd.h Outdated
@@ -2909,7 +2909,7 @@ static inline bool peer_dynamic_neighbor_no_nsf(struct peer *peer)

static inline int peer_cap_enhe(struct peer *peer, afi_t afi, safi_t safi)
{
return (CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ENHE_AF_NEGO));
return (peer && CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ENHE_AF_NEGO));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer a assert(peer); There is no reasonable call path that we ever get here where peer is non-null. I'd like to find that call path and fix it instead of silently moving on. I agree that this is a theoretical possibility given the code but the if (path) code is followed every time on 719 in bgp_updgrp_packet.c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, let's leave assert for now, we'll need to figure it out.

Found by the static analyzer Svace (ISP RAS): DEREF_OF_NULL.EX.COND.
After having been assigned to a NULL value at bgp_updgrp_packet.c:717,
pointer 'from' is passed as 9th parameter in call to function
'bgp_packet_attribute' at bgp_updgrp_packet.c:746, where
it is dereferenced at bgp_attr.c:4638.

Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
@donaldsharp donaldsharp merged commit 2d8939f into FRRouting:master Jul 7, 2025
14 checks passed
donaldsharp added a commit that referenced this pull request Jul 7, 2025
bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport #19126)
donaldsharp added a commit that referenced this pull request Jul 7, 2025
bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport #19126)
donaldsharp added a commit that referenced this pull request Jul 7, 2025
bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport #19126)
donaldsharp added a commit that referenced this pull request Jul 7, 2025
bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport #19126)
ton31337 added a commit that referenced this pull request Jul 7, 2025
bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport #19126)
ton31337 added a commit to opensourcerouting/frr that referenced this pull request Aug 2, 2025
* bgpd: correct no form commands (backport FRRouting#18911)
* bgpd: fix to show exist/non-exist-map in 'show run' properly FRRouting#18853
* redhat: make FRR RPM build to work on RedHat 10 (backport FRRouting#18920)
* build: check for libunwind.h, not unwind.h (backport FRRouting#18912)
* bgpd: use AS4B format for BGP loc-rib messages. (backport FRRouting#18936)
* bgpd: fix for the validity and the presence of prefixes in the BGP VPN table. (backport FRRouting#17370)
* bgpd: Force adj-rib-out updates if MRAI is kicked in (backport FRRouting#18959)
* zebra: Provide SID value when sending SRv6 SID release notify message (backport FRRouting#18971)
* bgpd: Fix crash when fetching statistics for bgp instance (backport FRRouting#19003)
* nhrpd: fix crash when accessing invalid memory zone (backport FRRouting#18994)
* zebra: Initialize RB tree for router tables (backport FRRouting#19049)
* zebra: fix null pointer dereference in zebra_evpn_sync_neigh_del (backport FRRouting#19054)
* zebra: fix stale NHG in kernel (backport FRRouting#18899)
* bgpd: Fix incorrect stripping of transitive extended communities (backport FRRouting#19065)
* lib: Fix no on-match goto NUM command (backport FRRouting#19108)
* bgpd: Fix extended community check for IP non-transitive type (backport FRRouting#19097)
* bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport FRRouting#19126)
* lib: revert addition of vtysh_flush() call in vty_out() (backport FRRouting#19109)
* bgpd: Extract link bandwidth value from extcommunity before using for WCMP (backport FRRouting#19165)
* Use ipv4 class E addresses (240.0.0.0/4) as connected routes by default (backport FRRouting#18095)
* bfdd: Set bfd.LocalDiag when transitioning to AdminDown (backport FRRouting#18592)
* zebra: clean up a json object leak (backport FRRouting#19192)
* bgpd: Do not try to reuse freed route-maps (backport FRRouting#19191)
* lib: fix routemap crash (backport FRRouting#19127)
* bgpd: initialize local variable (backport FRRouting#19233)
* ospfd: Use after free cleanup of lsa (backport FRRouting#19224)
* vtysh: copy config from file should actually apply (backport FRRouting#19242)
* bgpd : Fix compilation error in bgpd module: Update TP_ARGS for bgp (backport FRRouting#19266)
* bgpd: Ensure addpath does not withdraw selected route in some situations (backport FRRouting#19210)
* lib, zebra: mark singleton nexthops inactive/active on link state changes for wecmp (backport FRRouting#18947)
* eigrp: validate hello packets and tlvs better (backport FRRouting#19251)
* bgpd: [GR] fixed selectionDeferralTimer to display select_defer_time val FRRouting#19283

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
ton31337 added a commit to opensourcerouting/frr that referenced this pull request Aug 2, 2025
* bgpd: correct no form commands (backport FRRouting#18911)
* build: check for libunwind.h, not unwind.h (backport FRRouting#18912)
* redhat: make FRR RPM build to work on RedHat 10 (backport FRRouting#18920)
* bgpd: use AS4B format for BGP loc-rib messages. (backport FRRouting#18936)
* bgpd: Force adj-rib-out updates if MRAI is kicked in (backport FRRouting#18959)
* zebra: Provide SID value when sending SRv6 SID release notify message (backport FRRouting#18971)
* nhrpd: fix crash when accessing invalid memory zone (backport FRRouting#18994)
* lib: Fix no on-match goto NUM command (backport FRRouting#19108)
* bgpd: Fix DEREF_OF_NULL.EX.COND in bgp_updgrp_packet (backport FRRouting#19126)
* bgpd: Extract link bandwidth value from extcommunity before using for WCMP (backport FRRouting#19165)
* bfdd: Set bfd.LocalDiag when transitioning to AdminDown (backport FRRouting#18592)
* bgpd: Do not try to reuse freed route-maps (backport FRRouting#19191)
* lib: fix routemap crash (backport FRRouting#19127)
* lib, zebra: mark singleton nexthops inactive/active on link state changes for wecmp (backport FRRouting#18947)
* bgpd: [GR] fixed selectionDeferralTimer to display select_defer_time val FRRouting#19284

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
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.

3 participants