-
Notifications
You must be signed in to change notification settings - Fork 1.4k
nhrpd: fix crash when accessing invalid memory zone #18994
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
nhrpd: fix crash when accessing invalid memory zone #18994
Conversation
nhrpd/nhrp_packet.c
Outdated
@@ -182,7 +182,7 @@ struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb, | |||
if (!cie) | |||
return NULL; | |||
|
|||
if (cie->nbma_address_len + cie->nbma_subaddress_len > 0) { | |||
if (cie->nbma_address_len + cie->nbma_subaddress_len <= zbuf_used(zb)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this change lose the "> 0" part of the logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. this may explain the test failure..
A crash is detected on an invalid memory access to the 0x0 address zone. > #0 __pthread_kill_implementation (no_tid=0, signo=11, threadid=130889386464320) > at ./nptl/pthread_kill.c:44 > FRRouting#1 __pthread_kill_internal (signo=11, threadid=130889386464320) at ./nptl/pthread_kill.c:78 > FRRouting#2 __GI___pthread_kill (threadid=130889386464320, signo=signo@entry=11) at ./nptl/pthread_kill.c:89 > FRRouting#3 0x0000770b0f042476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26 > FRRouting#4 0x0000770b0f507846 in core_handler (signo=11, siginfo=0x7ffd4f7ec9f0, context=0x7ffd4f7ec8c0) > at /build/make-pkg/output/_packages/cp-routing/src/lib/sigevent.c:262 > FRRouting#5 <signal handler called> > FRRouting#6 __memmove_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:339 > FRRouting#7 0x0000770b0f50bb54 in sockunion_set (su=0x7ffd4f7ed7b0, family=2, addr=0x0, bytes=4) > at /build/make-pkg/output/_packages/cp-routing/src/lib/sockunion.c:500 > FRRouting#8 0x00005f75d5430817 in nhrp_cie_pull (zb=0x5f75f262c4d0, hdr=0x5f75f2627dd8, nbma=0x7ffd4f7ed6d0, > proto=0x7ffd4f7ed7b0) at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_packet.c:180 > FRRouting#9 0x00005f75d5434652 in nhrp_peer_forward (p=0x5f75f2605f30, pp=0x7ffd4f7ed8c0) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_peer.c:1050 > FRRouting#10 0x00005f75d54356cb in nhrp_peer_recv (p=0x5f75f2605f30, zb=0x5f75f2627da0) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_peer.c:1341 > FRRouting#11 0x00005f75d5430d8e in nhrp_packet_recvraw (t=0x7ffd4f7ede80) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_packet.c:332 > FRRouting#12 0x0000770b0f521188 in thread_call (thread=0x7ffd4f7ede80) > at /build/make-pkg/output/_packages/cp-routing/src/lib/thread.c:1825 > FRRouting#13 0x0000770b0f4b7737 in frr_run (master=0x5f75f2440570) > at /build/make-pkg/output/_packages/cp-routing/src/lib/libfrr.c:1155 > FRRouting#14 0x00005f75d542d2b4 in main (argc=3, argv=0x7ffd4f7ee0b8) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_main.c:317 The incoming nhrp packet is too short, and the call to sockunion_set() uses a 0x0 memory zone, because the whole nhrp packet has been parsed, and the zbuf length used was 0. Fix this by detecting the zbuf remaining length before calling sockunion_set. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
b8da713
to
30e479e
Compare
@Mergifyio backport dev/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0 |
✅ Backports have been created
|
nhrpd: fix crash when accessing invalid memory zone (backport #18994)
nhrpd: fix crash when accessing invalid memory zone (backport #18994)
nhrpd: fix crash when accessing invalid memory zone (backport #18994)
nhrpd: fix crash when accessing invalid memory zone (backport #18994)
nhrpd: fix crash when accessing invalid memory zone (backport #18994)
* 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>
* 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>
A crash is detected on an invalid memory access to the 0x0 address zone.
The incoming nhrp packet is too short, and the call to sockunion_set() uses a 0x0 memory zone, because the whole nhrp packet has been parsed, and the zbuf length used was 0. Fix this by detecting the zbuf remaining length before calling sockunion_set.