-
Notifications
You must be signed in to change notification settings - Fork 85
Support SONiC debian8 on FRR 5.0.x #7
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
Open
zhenggen-xu
wants to merge
1
commit into
sonic-net:frr/5.0
Choose a base branch
from
zhenggen-xu:frr/5.0-sonic
base: frr/5.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4359b40
to
93a0ab6
Compare
pavel-shirshov
pushed a commit
that referenced
this pull request
May 1, 2019
If path->net is NULL in the bgp_path_info_free() function, then bgpd would crash in bgp_addpath_free_info_data() with the following backtrace: (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007ff7b267a42a in __GI_abort () at abort.c:89 #2 0x00007ff7b39c1ca0 in core_handler (signo=11, siginfo=0x7ffff66414f0, context=<optimized out>) at lib/sigevent.c:249 #3 <signal handler called> #4 idalloc_free_to_pool (pool_ptr=pool_ptr@entry=0x0, id=3) at lib/id_alloc.c:368 #5 0x0000560096246688 in bgp_addpath_free_info_data (d=d@entry=0x560098665468, nd=0x0) at bgpd/bgp_addpath.c:100 #6 0x00005600961bb522 in bgp_path_info_free (path=0x560098665400) at bgpd/bgp_route.c:252 #7 bgp_path_info_unlock (path=0x560098665400) at bgpd/bgp_route.c:276 #8 0x00005600961bb719 in bgp_path_info_reap (rn=rn@entry=0x5600986b2110, pi=pi@entry=0x560098665400) at bgpd/bgp_route.c:320 #9 0x00005600961bf4db in bgp_process_main_one (safi=SAFI_MPLS_VPN, afi=AFI_IP, rn=0x5600986b2110, bgp=0x560098587320) at bgpd/bgp_route.c:2476 #10 bgp_process_wq (wq=<optimized out>, data=0x56009869b8f0) at bgpd/bgp_route.c:2503 #11 0x00007ff7b39d5fcc in work_queue_run (thread=0x7ffff6641e10) at lib/workqueue.c:294 #12 0x00007ff7b39ce3b1 in thread_call (thread=thread@entry=0x7ffff6641e10) at lib/thread.c:1606 #13 0x00007ff7b39a3538 in frr_run (master=0x5600980795b0) at lib/libfrr.c:1011 #14 0x000056009618a5a3 in main (argc=3, argv=0x7ffff6642078) at bgpd/bgp_main.c:481 Add a null-check protection to fix this problem. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
is this still needed? |
pavel-shirshov
pushed a commit
that referenced
this pull request
Oct 29, 2019
Our Address Sanitizer CI is finding this issue: error 09-Oct-2019 19:28:33 r4: bgpd triggered an exception by AddressSanitizer error 09-Oct-2019 19:28:33 ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdd425b060 at pc 0x00000068575f bp 0x7ffdd4258550 sp 0x7ffdd4258540 error 09-Oct-2019 19:28:33 READ of size 1 at 0x7ffdd425b060 thread T0 error 09-Oct-2019 19:28:33 #0 0x68575e in prefix_cmp lib/prefix.c:776 error 09-Oct-2019 19:28:33 #1 0x5889f5 in rfapiItBiIndexSearch bgpd/rfapi/rfapi_import.c:2230 error 09-Oct-2019 19:28:33 #2 0x5889f5 in rfapiBgpInfoFilteredImportVPN bgpd/rfapi/rfapi_import.c:3520 error 09-Oct-2019 19:28:33 #3 0x58b909 in rfapiProcessWithdraw bgpd/rfapi/rfapi_import.c:4071 error 09-Oct-2019 19:28:33 #4 0x4c459b in bgp_withdraw bgpd/bgp_route.c:3736 error 09-Oct-2019 19:28:33 #5 0x484122 in bgp_nlri_parse_vpn bgpd/bgp_mplsvpn.c:237 error 09-Oct-2019 19:28:33 #6 0x497f52 in bgp_nlri_parse bgpd/bgp_packet.c:315 error 09-Oct-2019 19:28:33 #7 0x49d06d in bgp_update_receive bgpd/bgp_packet.c:1598 error 09-Oct-2019 19:28:33 #8 0x49d06d in bgp_process_packet bgpd/bgp_packet.c:2274 error 09-Oct-2019 19:28:33 #9 0x6b9f54 in thread_call lib/thread.c:1531 error 09-Oct-2019 19:28:33 #10 0x657037 in frr_run lib/libfrr.c:1052 error 09-Oct-2019 19:28:33 #11 0x42d268 in main bgpd/bgp_main.c:486 error 09-Oct-2019 19:28:33 #12 0x7f806032482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) error 09-Oct-2019 19:28:33 #13 0x42bcc8 in _start (/usr/lib/frr/bgpd+0x42bcc8) error 09-Oct-2019 19:28:33 error 09-Oct-2019 19:28:33 Address 0x7ffdd425b060 is located in stack of thread T0 at offset 240 in frame error 09-Oct-2019 19:28:33 #0 0x483945 in bgp_nlri_parse_vpn bgpd/bgp_mplsvpn.c:103 error 09-Oct-2019 19:28:33 error 09-Oct-2019 19:28:33 This frame has 5 object(s): error 09-Oct-2019 19:28:33 [32, 36) 'label' error 09-Oct-2019 19:28:33 [96, 108) 'rd_as' error 09-Oct-2019 19:28:33 [160, 172) 'rd_ip' error 09-Oct-2019 19:28:33 [224, 240) 'prd' <== Memory access at offset 240 overflows this variable error 09-Oct-2019 19:28:33 [288, 336) 'p' error 09-Oct-2019 19:28:33 HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext error 09-Oct-2019 19:28:33 (longjmp and C++ exceptions *are* supported) error 09-Oct-2019 19:28:33 SUMMARY: AddressSanitizer: stack-buffer-overflow lib/prefix.c:776 prefix_cmp error 09-Oct-2019 19:28:33 Shadow bytes around the buggy address: error 09-Oct-2019 19:28:33 0x10003a8435b0: 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00 00 error 09-Oct-2019 19:28:33 0x10003a8435c0: 00 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 error 09-Oct-2019 19:28:33 0x10003a8435d0: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 error 09-Oct-2019 19:28:33 0x10003a8435e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 error 09-Oct-2019 19:28:33 0x10003a8435f0: f1 f1 04 f4 f4 f4 f2 f2 f2 f2 00 04 f4 f4 f2 f2 error 09-Oct-2019 19:28:33 =>0x10003a843600: f2 f2 00 04 f4 f4 f2 f2 f2 f2 00 00[f4]f4 f2 f2 error 09-Oct-2019 19:28:33 0x10003a843610: f2 f2 00 00 00 00 00 00 f4 f4 f3 f3 f3 f3 00 00 error 09-Oct-2019 19:28:33 0x10003a843620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 error 09-Oct-2019 19:28:33 0x10003a843630: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 02 f4 error 09-Oct-2019 19:28:33 0x10003a843640: f4 f4 f2 f2 f2 f2 04 f4 f4 f4 f2 f2 f2 f2 00 00 error 09-Oct-2019 19:28:33 0x10003a843650: f4 f4 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2 00 00 error 09-Oct-2019 19:28:33 Shadow byte legend (one shadow byte represents 8 application bytes): error 09-Oct-2019 19:28:33 Addressable: 00 error 09-Oct-2019 19:28:33 Partially addressable: 01 02 03 04 05 06 07 error 09-Oct-2019 19:28:33 Heap left redzone: fa error 09-Oct-2019 19:28:33 Heap right redzone: fb error 09-Oct-2019 19:28:33 Freed heap region: fd error 09-Oct-2019 19:28:33 Stack left redzone: f1 error 09-Oct-2019 19:28:33 Stack mid redzone: f2 error 09-Oct-2019 19:28:33 Stack right redzone: f3 error 09-Oct-2019 19:28:33 Stack partial redzone: f4 error 09-Oct-2019 19:28:33 Stack after return: f5 error 09-Oct-2019 19:28:33 Stack use after scope: f8 error 09-Oct-2019 19:28:33 Global redzone: f9 error 09-Oct-2019 19:28:33 Global init order: f6 error 09-Oct-2019 19:28:33 Poisoned by user: f7 error 09-Oct-2019 19:28:33 Container overflow: fc error 09-Oct-2019 19:28:33 Array cookie: ac error 09-Oct-2019 19:28:33 Intra object redzone: bb error 09-Oct-2019 19:28:33 ASan internal: fe error 09-Oct-2019 19:28:36 r3: Daemon bgpd not running This is the result of this code pattern in rfapi/rfapi_import.c: prefix_cmp((struct prefix *)&bpi_result->extra->vnc.import.rd, (struct prefix *)prd)) Effectively prd or vnc.import.rd are `struct prefix_rd` which are being typecast to a `struct prefix`. Not a big deal except commit 1315d74 modified the prefix_cmp function to allow for a sorted prefix_cmp. In prefix_cmp we were looking at the offset and shift. In the case of vnc we were passing a prefix length of 64 which is the exact length of the remaining data structure for struct prefix_rd. So we calculated a offset of 8 and a shift of 0. The data structures for the prefix portion happened to be equal to 64 bits of data. So we checked that with the memcmp got a 0 and promptly read off the end of the data structure for the numcmp. The fix is if shift is 0 that means thei the memcmp has checked everything and there is nothing to do. Please note: We will still crash if we set the prefixlen > then ~312 bits currently( ie if the prefixlen specifies a bit length longer than the prefix length ). I do not think there is anything to do here( nor am I sure how to correct this either ) as that we are going to have some severe problems when we muck up the prefixlen. Fixes: #5025 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pavel-shirshov
pushed a commit
that referenced
this pull request
Nov 17, 2020
This problem was reported by the sanitizer - ================================================================= ==24764==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d0000115c8 at pc 0x55cb9cfad312 bp 0x7fffa0552140 sp 0x7fffa0552138 READ of size 8 at 0x60d0000115c8 thread T0 #0 0x55cb9cfad311 in zebra_evpn_remote_es_flush zebra/zebra_evpn_mh.c:2041 #1 0x55cb9cfad311 in zebra_evpn_es_cleanup zebra/zebra_evpn_mh.c:2234 #2 0x55cb9cf6ae78 in zebra_vrf_disable zebra/zebra_vrf.c:205 #3 0x7fc8d478f114 in vrf_delete lib/vrf.c:229 #4 0x7fc8d478f99a in vrf_terminate lib/vrf.c:541 #5 0x55cb9ceba0af in sigint zebra/main.c:176 #6 0x55cb9ceba0af in sigint zebra/main.c:130 #7 0x7fc8d4765d20 in quagga_sigevent_process lib/sigevent.c:103 #8 0x7fc8d4787e8c in thread_fetch lib/thread.c:1396 #9 0x7fc8d4708782 in frr_run lib/libfrr.c:1092 #10 0x55cb9ce931d8 in main zebra/main.c:488 #11 0x7fc8d43ee09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) #12 0x55cb9ce94c09 in _start (/usr/lib/frr/zebra+0x8ac09) ================================================================= Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
pavel-shirshov
pushed a commit
that referenced
this pull request
Nov 17, 2020
When zebra is running with debugs turned on there is a use after free reported by the address sanitizer: 2020/10/16 12:58:02 ZEBRA: rib_delnode: (0:254):4.5.6.16/32: rn 0x60b000026f20, re 0x6080000131a0, removing 2020/10/16 12:58:02 ZEBRA: rib_meta_queue_add: (0:254):4.5.6.16/32: queued rn 0x60b000026f20 into sub-queue 3 ================================================================= ==3101430==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000011d28 at pc 0x555555705ab6 bp 0x7fffffffdab0 sp 0x7fffffffdaa8 READ of size 8 at 0x608000011d28 thread T0 #0 0x555555705ab5 in re_list_const_first zebra/rib.h:222 #1 0x555555705b54 in re_list_first zebra/rib.h:222 #2 0x555555711a4f in process_subq_route zebra/zebra_rib.c:2248 #3 0x555555711d2e in process_subq zebra/zebra_rib.c:2286 #4 0x555555711ec7 in meta_queue_process zebra/zebra_rib.c:2320 #5 0x7ffff74701f7 in work_queue_run lib/workqueue.c:291 #6 0x7ffff7450e9c in thread_call lib/thread.c:1581 #7 0x7ffff738eaf7 in frr_run lib/libfrr.c:1099 #8 0x55555561a578 in main zebra/main.c:455 #9 0x7ffff7079cc9 in __libc_start_main ../csu/libc-start.c:308 #10 0x5555555e3429 in _start (/usr/lib/frr/zebra+0x8f429) 0x608000011d28 is located 8 bytes inside of 88-byte region [0x608000011d20,0x608000011d78) freed by thread T0 here: #0 0x7ffff768bb6f in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.6+0xa9b6f) #1 0x7ffff739ccad in qfree lib/memory.c:129 #2 0x555555709ee4 in rib_gc_dest zebra/zebra_rib.c:746 #3 0x55555570ca76 in rib_process zebra/zebra_rib.c:1240 #4 0x555555711a05 in process_subq_route zebra/zebra_rib.c:2245 #5 0x555555711d2e in process_subq zebra/zebra_rib.c:2286 #6 0x555555711ec7 in meta_queue_process zebra/zebra_rib.c:2320 #7 0x7ffff74701f7 in work_queue_run lib/workqueue.c:291 #8 0x7ffff7450e9c in thread_call lib/thread.c:1581 #9 0x7ffff738eaf7 in frr_run lib/libfrr.c:1099 #10 0x55555561a578 in main zebra/main.c:455 #11 0x7ffff7079cc9 in __libc_start_main ../csu/libc-start.c:308 previously allocated by thread T0 here: #0 0x7ffff768c037 in calloc (/lib/x86_64-linux-gnu/libasan.so.6+0xaa037) #1 0x7ffff739cb98 in qcalloc lib/memory.c:110 #2 0x555555712ace in zebra_rib_create_dest zebra/zebra_rib.c:2515 #3 0x555555712c6c in rib_link zebra/zebra_rib.c:2576 #4 0x555555712faa in rib_addnode zebra/zebra_rib.c:2607 #5 0x555555715bf0 in rib_add_multipath_nhe zebra/zebra_rib.c:3012 #6 0x555555715f56 in rib_add_multipath zebra/zebra_rib.c:3049 #7 0x55555571788b in rib_add zebra/zebra_rib.c:3327 #8 0x5555555e584a in connected_up zebra/connected.c:254 #9 0x5555555e42ff in connected_announce zebra/connected.c:94 #10 0x5555555e4fd3 in connected_update zebra/connected.c:195 #11 0x5555555e61ad in connected_add_ipv4 zebra/connected.c:340 #12 0x5555555f26f5 in netlink_interface_addr zebra/if_netlink.c:1213 #13 0x55555560f756 in netlink_information_fetch zebra/kernel_netlink.c:350 #14 0x555555612e49 in netlink_parse_info zebra/kernel_netlink.c:941 #15 0x55555560f9f1 in kernel_read zebra/kernel_netlink.c:402 #16 0x7ffff7450e9c in thread_call lib/thread.c:1581 #17 0x7ffff738eaf7 in frr_run lib/libfrr.c:1099 #18 0x55555561a578 in main zebra/main.c:455 #19 0x7ffff7079cc9 in __libc_start_main ../csu/libc-start.c:308 SUMMARY: AddressSanitizer: heap-use-after-free zebra/rib.h:222 in re_list_const_first This is happening because we are using the dest pointer after a call into rib_gc_dest. In process_subq_route, we call rib_process() and if the dest is deleted dest pointer is now garbage. We must reload the dest pointer in this case. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lguohan
pushed a commit
that referenced
this pull request
Dec 24, 2020
We are using data after it has been freed and handed back to the OS. Address Sanitizer output: error 23-Nov-2020 18:53:57 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55f825998f58 bp 0x7fffa5b0f5b0 sp 0x7fffa5b0f5a0 error 23-Nov-2020 18:53:57 READ of size 4 at 0x631000024838 thread T0 error 23-Nov-2020 18:53:57 #0 0x55f825998f57 in lde_imsg_compose_parent_sync ldpd/lde.c:226 error 23-Nov-2020 18:53:57 #1 0x55f8259ca9ed in vlog ldpd/log.c:48 error 23-Nov-2020 18:53:57 #2 0x55f8259cb1c8 in log_info ldpd/log.c:102 error 23-Nov-2020 18:53:57 #3 0x55f82599e841 in lde_shutdown ldpd/lde.c:208 error 23-Nov-2020 18:53:57 #4 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666 error 23-Nov-2020 18:53:57 #5 0x55f825ac3815 in thread_call lib/thread.c:1681 error 23-Nov-2020 18:53:57 #6 0x55f825998d5e in lde ldpd/lde.c:160 error 23-Nov-2020 18:53:57 #7 0x55f82598a289 in main ldpd/ldpd.c:320 error 23-Nov-2020 18:53:57 #8 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) error 23-Nov-2020 18:53:57 #9 0x55f825982579 in _start (/usr/lib/frr/ldpd+0xb3579) error 23-Nov-2020 18:53:57 error 23-Nov-2020 18:53:57 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860) error 23-Nov-2020 18:53:57 freed by thread T0 here: error 23-Nov-2020 18:53:57 #0 0x7fe3f8a4d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8) error 23-Nov-2020 18:53:57 #1 0x55f82599e830 in lde_shutdown ldpd/lde.c:206 error 23-Nov-2020 18:53:57 #2 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666 error 23-Nov-2020 18:53:57 #3 0x55f825ac3815 in thread_call lib/thread.c:1681 error 23-Nov-2020 18:53:57 #4 0x55f825998d5e in lde ldpd/lde.c:160 error 23-Nov-2020 18:53:57 #5 0x55f82598a289 in main ldpd/ldpd.c:320 error 23-Nov-2020 18:53:57 #6 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) error 23-Nov-2020 18:53:57 error 23-Nov-2020 18:53:57 previously allocated by thread T0 here: error 23-Nov-2020 18:53:57 #0 0x7fe3f8a4dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) error 23-Nov-2020 18:53:57 #1 0x55f825998cb7 in lde ldpd/lde.c:151 error 23-Nov-2020 18:53:57 #2 0x55f82598a289 in main ldpd/ldpd.c:320 error 23-Nov-2020 18:53:57 #3 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) error 23-Nov-2020 18:53:57 The fix is to put this in global space. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lguohan
pushed a commit
that referenced
this pull request
Dec 24, 2020
error 26-Nov-2020 14:35:02 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55cefae977e9 bp 0x7ffdd3546860 sp 0x7ffdd3546850 error 26-Nov-2020 14:35:02 READ of size 4 at 0x631000024838 thread T0 error 26-Nov-2020 14:35:02 #0 0x55cefae977e8 in ldpe_imsg_compose_parent_sync ldpd/ldpe.c:256 error 26-Nov-2020 14:35:02 #1 0x55cefae9ab13 in vlog ldpd/log.c:53 error 26-Nov-2020 14:35:02 #2 0x55cefae9b21f in log_info ldpd/log.c:102 error 26-Nov-2020 14:35:02 #3 0x55cefae96eae in ldpe_shutdown ldpd/ldpe.c:237 error 26-Nov-2020 14:35:02 #4 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585 error 26-Nov-2020 14:35:02 #5 0x55cefaf93875 in thread_call lib/thread.c:1681 error 26-Nov-2020 14:35:02 #6 0x55cefae97304 in ldpe ldpd/ldpe.c:136 error 26-Nov-2020 14:35:02 #7 0x55cefae5a2e2 in main ldpd/ldpd.c:322 error 26-Nov-2020 14:35:02 #8 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) error 26-Nov-2020 14:35:02 #9 0x55cefae525e9 in _start (/usr/lib/frr/ldpd+0xb35e9) error 26-Nov-2020 14:35:02 error 26-Nov-2020 14:35:02 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860) error 26-Nov-2020 14:35:02 freed by thread T0 here: error 26-Nov-2020 14:35:02 #0 0x7f4ef21e37a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8) error 26-Nov-2020 14:35:02 #1 0x55cefae96e91 in ldpe_shutdown ldpd/ldpe.c:234 error 26-Nov-2020 14:35:02 #2 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585 error 26-Nov-2020 14:35:02 #3 0x55cefaf93875 in thread_call lib/thread.c:1681 error 26-Nov-2020 14:35:02 #4 0x55cefae97304 in ldpe ldpd/ldpe.c:136 error 26-Nov-2020 14:35:02 #5 0x55cefae5a2e2 in main ldpd/ldpd.c:322 error 26-Nov-2020 14:35:02 #6 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) error 26-Nov-2020 14:35:02 error 26-Nov-2020 14:35:02 previously allocated by thread T0 here: error 26-Nov-2020 14:35:02 #0 0x7f4ef21e3d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) error 26-Nov-2020 14:35:02 #1 0x55cefae9725d in ldpe ldpd/ldpe.c:127 error 26-Nov-2020 14:35:02 #2 0x55cefae5a2e2 in main ldpd/ldpd.c:322 error 26-Nov-2020 14:35:02 #3 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) Clean this problem up in the same way as the previous commit Signed-off-by: Donald Sharp <sharpd@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
Config data was being freed just prior to it being used for cleanup in shutdown. Prevent this from happening. ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142-================================================================= ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142:==2274142==ERROR: AddressSanitizer: heap-use-after-free on address 0x61d00000c880 at pc 0x0000004d94d1 bp 0x7ffd46637810 sp 0 x7ffd46637808 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142-READ of size 4 at 0x61d00000c880 thread T0 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- #0 0x4d94d0 in ldp_rtr_id_get /home/sharpd/frr8/ldpd/ldpd.c:983:20 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#1 0x56ff92 in gen_ldp_hdr /home/sharpd/frr8/ldpd/packet.c:47:19 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#2 0x56a4b0 in send_notification_full /home/sharpd/frr8/ldpd/notification.c:49:9 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#3 0x56c4b3 in send_notification /home/sharpd/frr8/ldpd/notification.c:117:2 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#4 0x573fb7 in session_shutdown /home/sharpd/frr8/ldpd/packet.c:666:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#5 0x4e2ef1 in adj_del /home/sharpd/frr8/ldpd/adjacency.c:145:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#6 0x55d425 in ldpe_shutdown /home/sharpd/frr8/ldpd/ldpe.c:231:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#7 0x55a9a0 in ldpe_dispatch_main /home/sharpd/frr8/ldpd/ldpe.c:631:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#8 0x7f0c00c035e6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#9 0x5586f2 in ldpe /home/sharpd/frr8/ldpd/ldpe.c:138:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#10 0x4d46d2 in main /home/sharpd/frr8/ldpd/ldpd.c:339:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#11 0x7f0c00476d09 in __libc_start_main csu/../csu/libc-start.c:308:16 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#12 0x429cb9 in _start (/usr/lib/frr/ldpd+0x429cb9) ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142-0x61d00000c880 is located 0 bytes inside of 2008-byte region [0x61d00000c880,0x61d00000d058) ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142-freed by thread T0 here: ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- #0 0x4a3aad in free (/usr/lib/frr/ldpd+0x4a3aad) ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#1 0x4de6c8 in config_clear /home/sharpd/frr8/ldpd/ldpd.c:2001:2 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#2 0x55d12d in ldpe_shutdown /home/sharpd/frr8/ldpd/ldpe.c:211:2 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#3 0x55a9a0 in ldpe_dispatch_main /home/sharpd/frr8/ldpd/ldpe.c:631:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#4 0x7f0c00c035e6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#5 0x5586f2 in ldpe /home/sharpd/frr8/ldpd/ldpe.c:138:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#6 0x4d46d2 in main /home/sharpd/frr8/ldpd/ldpd.c:339:3 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#7 0x7f0c00476d09 in __libc_start_main csu/../csu/libc-start.c:308:16 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142-previously allocated by thread T0 here: ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- #0 0x4a3ea2 in calloc (/usr/lib/frr/ldpd+0x4a3ea2) ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#1 0x4d6146 in config_new_empty /home/sharpd/frr8/ldpd/ldpd.c:1967:10 ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#2 0x558678 in ldpe /home/sharpd/frr8/ldpd/ldpe.c:134:11 -- ./isis_rlfa_topo1.test_isis_rlfa_topo1/rt8.ldpd.asan.2274142- sonic-net#4 0x7f0c00476d09 in __libc_start_main csu/../csu/libc-start.c:308:16 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
On shutdown a use after free was being seen of a route table. Basically the pointer was kept around and resent for cleanup. Probably something needs to be unwound to make this better in the future. Just cleaning up the use after free. ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929-================================================================= ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929:==911929==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000127a00 at pc 0x7fb9ad546f5b bp 0x7ffc3cff0330 sp 0x7ffc3 cff0328 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929-READ of size 8 at 0x606000127a00 thread T0 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- #0 0x7fb9ad546f5a in route_table_free /home/sharpd/frr8/lib/table.c:103:13 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#1 0x7fb9ad546f04 in route_table_finish /home/sharpd/frr8/lib/table.c:61:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#2 0x6b94ba in zebra_ns_disable_internal /home/sharpd/frr8/zebra/zebra_ns.c:141:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#3 0x6b9158 in zebra_ns_disabled /home/sharpd/frr8/zebra/zebra_ns.c:116:9 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#4 0x7fb9ad43f0f5 in ns_disable_internal /home/sharpd/frr8/lib/netns_linux.c:273:4 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#5 0x7fb9ad43e634 in ns_disable /home/sharpd/frr8/lib/netns_linux.c:368:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#6 0x7fb9ad43e251 in ns_delete /home/sharpd/frr8/lib/netns_linux.c:330:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#7 0x7fb9ad43fbb3 in ns_terminate /home/sharpd/frr8/lib/netns_linux.c:524:3 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#8 0x54f8de in zebra_finalize /home/sharpd/frr8/zebra/main.c:232:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#9 0x7fb9ad5655e6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#10 0x7fb9ad3d3343 in frr_run /home/sharpd/frr8/lib/libfrr.c:1198:3 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#11 0x550b48 in main /home/sharpd/frr8/zebra/main.c:476:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#12 0x7fb9acd30d09 in __libc_start_main csu/../csu/libc-start.c:308:16 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#13 0x443549 in _start (/usr/lib/frr/zebra+0x443549) ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929-0x606000127a00 is located 0 bytes inside of 56-byte region [0x606000127a00,0x606000127a38) ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929-freed by thread T0 here: ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- #0 0x4bd33d in free (/usr/lib/frr/zebra+0x4bd33d) ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#1 0x7fb9ad42cc80 in qfree /home/sharpd/frr8/lib/memory.c:141:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#2 0x7fb9ad547305 in route_table_free /home/sharpd/frr8/lib/table.c:141:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#3 0x7fb9ad546f04 in route_table_finish /home/sharpd/frr8/lib/table.c:61:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#4 0x6b94ba in zebra_ns_disable_internal /home/sharpd/frr8/zebra/zebra_ns.c:141:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#5 0x6b9692 in zebra_ns_early_shutdown /home/sharpd/frr8/zebra/zebra_ns.c:164:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#6 0x7fb9ad43f228 in ns_walk_func /home/sharpd/frr8/lib/netns_linux.c:386:9 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#7 0x55014f in sigint /home/sharpd/frr8/zebra/main.c:194:2 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#8 0x7fb9ad50db99 in frr_sigevent_process /home/sharpd/frr8/lib/sigevent.c:130:6 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#9 0x7fb9ad560d07 in thread_fetch /home/sharpd/frr8/lib/thread.c:1775:4 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#10 0x7fb9ad3d332d in frr_run /home/sharpd/frr8/lib/libfrr.c:1197:9 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#11 0x550b48 in main /home/sharpd/frr8/zebra/main.c:476:2 -- ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- sonic-net#7 0x7fb9acd30d09 in __libc_start_main csu/../csu/libc-start.c:308:16 ./bfd_vrf_topo1.test_bfd_vrf_topo1/r2.zebra.asan.911929- Signed-off-by: Donald Sharp <sharpd@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
When changing the peers sockunion structure the bgp->peer list was not being updated properly. Since the peer's su is being used for a sorted insert then the change of it requires that the value be pulled out of the bgp->peer list and then put back into as well. Additionally ensure that the hash is always released on peer deletion. Lead to this from this decode in a address sanitizer run. ================================================================= ==30778==ERROR: AddressSanitizer: heap-use-after-free on address 0x62a0000d8440 at pc 0x7f48c9c5c547 bp 0x7ffcba272cb0 sp 0x7ffcba272ca8 READ of size 2 at 0x62a0000d8440 thread T0 #0 0x7f48c9c5c546 in sockunion_same lib/sockunion.c:425 sonic-net#1 0x55cfefe3000f in peer_hash_same bgpd/bgpd.c:890 sonic-net#2 0x7f48c9bde039 in hash_release lib/hash.c:209 sonic-net#3 0x55cfefe3373f in bgp_peer_conf_if_to_su_update bgpd/bgpd.c:1541 sonic-net#4 0x55cfefd0be7a in bgp_stop bgpd/bgp_fsm.c:1631 sonic-net#5 0x55cfefe4028f in peer_delete bgpd/bgpd.c:2362 sonic-net#6 0x55cfefdd5e97 in no_neighbor_interface_config bgpd/bgp_vty.c:4267 sonic-net#7 0x7f48c9b9d160 in cmd_execute_command_real lib/command.c:949 sonic-net#8 0x7f48c9ba1112 in cmd_execute_command lib/command.c:1009 sonic-net#9 0x7f48c9ba1573 in cmd_execute lib/command.c:1162 sonic-net#10 0x7f48c9c87402 in vty_command lib/vty.c:526 sonic-net#11 0x7f48c9c87832 in vty_execute lib/vty.c:1291 sonic-net#12 0x7f48c9c8e741 in vtysh_read lib/vty.c:2130 sonic-net#13 0x7f48c9c7a66d in thread_call lib/thread.c:1585 sonic-net#14 0x7f48c9bf64e7 in frr_run lib/libfrr.c:1123 sonic-net#15 0x55cfefc75a15 in main bgpd/bgp_main.c:540 sonic-net#16 0x7f48c96b009a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) sonic-net#17 0x55cfefc787f9 in _start (/usr/lib/frr/bgpd+0xe27f9) 0x62a0000d8440 is located 576 bytes inside of 23376-byte region [0x62a0000d8200,0x62a0000ddd50) freed by thread T0 here: #0 0x7f48c9eb9fb0 in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0xe8fb0) sonic-net#1 0x55cfefe3fe42 in peer_free bgpd/bgpd.c:1113 sonic-net#2 0x55cfefe3fe42 in peer_unlock_with_caller bgpd/bgpd.c:1144 sonic-net#3 0x55cfefe4092e in peer_delete bgpd/bgpd.c:2457 sonic-net#4 0x55cfefdd5e97 in no_neighbor_interface_config bgpd/bgp_vty.c:4267 sonic-net#5 0x7f48c9b9d160 in cmd_execute_command_real lib/command.c:949 sonic-net#6 0x7f48c9ba1112 in cmd_execute_command lib/command.c:1009 sonic-net#7 0x7f48c9ba1573 in cmd_execute lib/command.c:1162 sonic-net#8 0x7f48c9c87402 in vty_command lib/vty.c:526 sonic-net#9 0x7f48c9c87832 in vty_execute lib/vty.c:1291 sonic-net#10 0x7f48c9c8e741 in vtysh_read lib/vty.c:2130 sonic-net#11 0x7f48c9c7a66d in thread_call lib/thread.c:1585 sonic-net#12 0x7f48c9bf64e7 in frr_run lib/libfrr.c:1123 sonic-net#13 0x55cfefc75a15 in main bgpd/bgp_main.c:540 sonic-net#14 0x7f48c96b009a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Signed-off-by: Donald Sharp <sharpd@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
Address Sanitizer found this: ================================================================= ==418623==ERROR: LeakSanitizer: detected memory leaks Direct leak of 128 byte(s) in 4 object(s) allocated from: #0 0x4bd732 in calloc (/usr/lib/frr/zebra+0x4bd732) sonic-net#1 0x7feaeab8f798 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27 sonic-net#2 0x7feaeaba40f4 in nexthop_group_new /home/sharpd/frr8/lib/nexthop_group.c:270:9 sonic-net#3 0x56859b in netlink_route_change_read_unicast /home/sharpd/frr8/zebra/rt_netlink.c:950:9 sonic-net#4 0x5651c2 in netlink_route_change /home/sharpd/frr8/zebra/rt_netlink.c:1204:2 sonic-net#5 0x54af15 in netlink_information_fetch /home/sharpd/frr8/zebra/kernel_netlink.c:407:10 sonic-net#6 0x53e7a3 in netlink_parse_info /home/sharpd/frr8/zebra/kernel_netlink.c:1184:12 sonic-net#7 0x548d46 in kernel_read /home/sharpd/frr8/zebra/kernel_netlink.c:501:2 sonic-net#8 0x7feaeacc87f6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 sonic-net#9 0x7feaeab36503 in frr_run /home/sharpd/frr8/lib/libfrr.c:1198:3 sonic-net#10 0x550d38 in main /home/sharpd/frr8/zebra/main.c:476:2 sonic-net#11 0x7feaea492d09 in __libc_start_main csu/../csu/libc-start.c:308:16 Indirect leak of 576 byte(s) in 4 object(s) allocated from: #0 0x4bd732 in calloc (/usr/lib/frr/zebra+0x4bd732) sonic-net#1 0x7feaeab8f798 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27 sonic-net#2 0x7feaeab9b3f8 in nexthop_new /home/sharpd/frr8/lib/nexthop.c:373:7 sonic-net#3 0x56875e in netlink_route_change_read_unicast /home/sharpd/frr8/zebra/rt_netlink.c:960:15 sonic-net#4 0x5651c2 in netlink_route_change /home/sharpd/frr8/zebra/rt_netlink.c:1204:2 sonic-net#5 0x54af15 in netlink_information_fetch /home/sharpd/frr8/zebra/kernel_netlink.c:407:10 sonic-net#6 0x53e7a3 in netlink_parse_info /home/sharpd/frr8/zebra/kernel_netlink.c:1184:12 sonic-net#7 0x548d46 in kernel_read /home/sharpd/frr8/zebra/kernel_netlink.c:501:2 sonic-net#8 0x7feaeacc87f6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 sonic-net#9 0x7feaeab36503 in frr_run /home/sharpd/frr8/lib/libfrr.c:1198:3 sonic-net#10 0x550d38 in main /home/sharpd/frr8/zebra/main.c:476:2 sonic-net#11 0x7feaea492d09 in __libc_start_main csu/../csu/libc-start.c:308:16 SUMMARY: AddressSanitizer: 704 byte(s) leaked in 8 allocation(s). Fix this! Signed-off-by: Donald Sharp <sharpd@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
ASAN reported the following memleak: ``` Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x4d4342 in calloc (/usr/lib/frr/bgpd+0x4d4342) sonic-net#1 0xbc3d68 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27 sonic-net#2 0xb869f7 in list_new /home/sharpd/frr8/lib/linklist.c:64:9 sonic-net#3 0x5a38bc in bgp_evpn_remote_ip_hash_alloc /home/sharpd/frr8/bgpd/bgp_evpn.c:6789:24 sonic-net#4 0xb358d3 in hash_get /home/sharpd/frr8/lib/hash.c:162:13 sonic-net#5 0x593d39 in bgp_evpn_remote_ip_hash_add /home/sharpd/frr8/bgpd/bgp_evpn.c:6881:7 sonic-net#6 0x59dbbd in install_evpn_route_entry_in_vni_common /home/sharpd/frr8/bgpd/bgp_evpn.c:3049:2 sonic-net#7 0x59cfe0 in install_evpn_route_entry_in_vni_ip /home/sharpd/frr8/bgpd/bgp_evpn.c:3126:8 sonic-net#8 0x59c6f0 in install_evpn_route_entry /home/sharpd/frr8/bgpd/bgp_evpn.c:3318:8 sonic-net#9 0x59bb52 in install_uninstall_route_in_vnis /home/sharpd/frr8/bgpd/bgp_evpn.c:3888:10 sonic-net#10 0x59b6d2 in bgp_evpn_install_uninstall_table /home/sharpd/frr8/bgpd/bgp_evpn.c:4019:5 sonic-net#11 0x578857 in install_uninstall_evpn_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4051:9 sonic-net#12 0x58ada6 in bgp_evpn_import_route /home/sharpd/frr8/bgpd/bgp_evpn.c:6049:9 sonic-net#13 0x713794 in bgp_update /home/sharpd/frr8/bgpd/bgp_route.c:4842:3 sonic-net#14 0x583fa0 in process_type2_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4518:9 sonic-net#15 0x5824ba in bgp_nlri_parse_evpn /home/sharpd/frr8/bgpd/bgp_evpn.c:5732:8 sonic-net#16 0x6ae6a2 in bgp_nlri_parse /home/sharpd/frr8/bgpd/bgp_packet.c:363:10 sonic-net#17 0x6be6fa in bgp_update_receive /home/sharpd/frr8/bgpd/bgp_packet.c:2020:15 sonic-net#18 0x6b7433 in bgp_process_packet /home/sharpd/frr8/bgpd/bgp_packet.c:2929:11 sonic-net#19 0xd00146 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2 ``` The list itself was not being cleaned up when the final list entry was removed, so make sure we do that instead of leaking memory. Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
Fix crash on "show bgp all" when BGP EVPN is set. > #0 raise (sig=11) at ../sysdeps/unix/sysv/linux/raise.c:50 > sonic-net#1 0x00007fdfe03cf53c in core_handler (signo=11, siginfo=0x7ffdebbffe30, context=0x7ffdebbffd00) at lib/sigevent.c:261 > sonic-net#2 <signal handler called> > sonic-net#3 0x00000000004d4fec in bgp_attr_get_community (attr=0x41) at bgpd/bgp_attr.h:553 > sonic-net#4 0x00000000004eee84 in bgp_show_table (vty=0x1a790d0, bgp=0x19d0a00, safi=SAFI_EVPN, table=0x19f6010, type=bgp_show_type_normal, output_arg=0x0, rd=0x0, is_last=1, output_cum=0x0, > total_cum=0x0, json_header_depth=0x7ffdebc00bf8, show_flags=4, rpki_target_state=RPKI_NOT_BEING_USED) at bgpd/bgp_route.c:11329 > sonic-net#5 0x00000000004f7765 in bgp_show (vty=0x1a790d0, bgp=0x19d0a00, afi=AFI_L2VPN, safi=SAFI_EVPN, type=bgp_show_type_normal, output_arg=0x0, show_flags=4, > rpki_target_state=RPKI_NOT_BEING_USED) at bgpd/bgp_route.c:11814 > sonic-net#6 0x00000000004fb53b in show_ip_bgp_magic (self=0x6752b0 <show_ip_bgp_cmd>, vty=0x1a790d0, argc=3, argv=0x19cb050, viewvrfname=0x0, all=0x1395390 "all", aa_nn=0x0, community_list=0, > community_list_str=0x0, community_list_name=0x0, as_path_filter_name=0x0, prefix_list=0x0, accesslist_name=0x0, rmap_name=0x0, version=0, version_str=0x0, alias_name=0x0, > orr_group_name=0x0, detail_routes=0x0, uj=0x0, detail_json=0x0, wide=0x0) at bgpd/bgp_route.c:13040 > sonic-net#7 0x00000000004fa322 in show_ip_bgp (self=0x6752b0 <show_ip_bgp_cmd>, vty=0x1a790d0, argc=3, argv=0x19cb050) at ./bgpd/bgp_route_clippy.c:519 > sonic-net#8 0x00007fdfe033ccc8 in cmd_execute_command_real (vline=0x19c9300, filter=FILTER_RELAXED, vty=0x1a790d0, cmd=0x0, up_level=0) at lib/command.c:996 > sonic-net#9 0x00007fdfe033c739 in cmd_execute_command (vline=0x19c9300, vty=0x1a790d0, cmd=0x0, vtysh=0) at lib/command.c:1056 > sonic-net#10 0x00007fdfe033cdf5 in cmd_execute (vty=0x1a790d0, cmd=0x19c9eb0 "show bgp all", matched=0x0, vtysh=0) at lib/command.c:1223 > sonic-net#11 0x00007fdfe03f65c6 in vty_command (vty=0x1a790d0, buf=0x19c9eb0 "show bgp all") at lib/vty.c:486 > sonic-net#12 0x00007fdfe03f603b in vty_execute (vty=0x1a790d0) at lib/vty.c:1249 > sonic-net#13 0x00007fdfe03f533b in vtysh_read (thread=0x7ffdebc03838) at lib/vty.c:2148 > sonic-net#14 0x00007fdfe03e815d in thread_call (thread=0x7ffdebc03838) at lib/thread.c:2006 > sonic-net#15 0x00007fdfe0379b54 in frr_run (master=0x1246880) at lib/libfrr.c:1198 > sonic-net#16 0x000000000042b2a8 in main (argc=7, argv=0x7ffdebc03af8) at bgpd/bgp_main.c:520 Link: FRRouting/frr#12576 Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
Prevent a use after free and tell the bfd subsystem we are shutting down in staticd. ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460:==2264460==ERROR: AddressSanitizer: heap-use-after-free on address 0x61f000004698 at pc 0x7f65d1eb11b2 bp 0x7ffdbface490 sp 0x7ffdbface488 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-READ of size 4 at 0x61f000004698 thread T0 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- #0 0x7f65d1eb11b1 in zclient_bfd_command lib/bfd.c:307 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#1 0x7f65d1eb20f5 in _bfd_sess_send lib/bfd.c:507 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#2 0x7f65d20510aa in thread_call lib/thread.c:1989 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#3 0x7f65d2051f0a in _thread_execute lib/thread.c:2081 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#4 0x7f65d1eb271b in _bfd_sess_remove lib/bfd.c:544 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#5 0x7f65d1eb278d in bfd_sess_free lib/bfd.c:553 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#6 0x7f65d1eb5400 in bfd_protocol_integration_finish lib/bfd.c:1029 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#7 0x7f65d1f42f77 in hook_call_frr_fini lib/libfrr.c:41 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#8 0x7f65d1f494a1 in frr_fini lib/libfrr.c:1199 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#9 0x563b7abefd76 in sigint staticd/static_main.c:70 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#10 0x7f65d200ef91 in frr_sigevent_process lib/sigevent.c:115 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#11 0x7f65d204fac6 in thread_fetch lib/thread.c:1758 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#12 0x7f65d1f49377 in frr_run lib/libfrr.c:1184 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#13 0x563b7abefed1 in main staticd/static_main.c:160 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#14 0x7f65d1b92d09 in __libc_start_main ../csu/libc-start.c:308 ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- sonic-net#15 0x563b7abefa99 in _start (/usr/lib/frr/staticd+0x15a99) ./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460- Signed-off-by: Donald Sharp <sharpd@nvidia.com> (cherry picked from commit 7a185ac)
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
Memory leaks are observed in the cleanup code. When “no router bgp" is executed, cleanup in that flow for aggregate-address command is not taken care. fixes the below leak: -- ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444:Direct leak of 152 byte(s) in 1 object(s) allocated from: ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- #0 0x7f163e911037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#1 0x7f163e4b9259 in qcalloc lib/memory.c:105 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#2 0x562bf42ebbd5 in bgp_aggregate_new bgpd/bgp_route.c:7239 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#3 0x562bf42f14e8 in bgp_aggregate_set bgpd/bgp_route.c:8421 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#4 0x562bf42f1e55 in aggregate_addressv6_magic bgpd/bgp_route.c:8592 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#5 0x562bf42be3f5 in aggregate_addressv6 bgpd/bgp_route_clippy.c:341 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#6 0x7f163e3f1e1b in cmd_execute_command_real lib/command.c:988 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#7 0x7f163e3f219c in cmd_execute_command lib/command.c:1048 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#8 0x7f163e3f2df4 in cmd_execute lib/command.c:1215 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#9 0x7f163e5a2d73 in vty_command lib/vty.c:544 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#10 0x7f163e5a79c8 in vty_execute lib/vty.c:1307 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#11 0x7f163e5ad299 in vtysh_read lib/vty.c:2216 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#12 0x7f163e593f16 in event_call lib/event.c:1995 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#13 0x7f163e47c839 in frr_run lib/libfrr.c:1185 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#14 0x562bf414e58d in main bgpd/bgp_main.c:505 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#15 0x7f163de66d09 in __libc_start_main ../csu/libc-start.c:308 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444:Direct leak of 152 byte(s) in 1 object(s) allocated from: ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- #0 0x7f163e911037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#1 0x7f163e4b9259 in qcalloc lib/memory.c:105 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#2 0x562bf42ebbd5 in bgp_aggregate_new bgpd/bgp_route.c:7239 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#3 0x562bf42f14e8 in bgp_aggregate_set bgpd/bgp_route.c:8421 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#4 0x562bf42f1cde in aggregate_addressv4_magic bgpd/bgp_route.c:8543 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#5 0x562bf42bd258 in aggregate_addressv4 bgpd/bgp_route_clippy.c:255 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#6 0x7f163e3f1e1b in cmd_execute_command_real lib/command.c:988 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#7 0x7f163e3f219c in cmd_execute_command lib/command.c:1048 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#8 0x7f163e3f2df4 in cmd_execute lib/command.c:1215 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#9 0x7f163e5a2d73 in vty_command lib/vty.c:544 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#10 0x7f163e5a79c8 in vty_execute lib/vty.c:1307 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#11 0x7f163e5ad299 in vtysh_read lib/vty.c:2216 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#12 0x7f163e593f16 in event_call lib/event.c:1995 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#13 0x7f163e47c839 in frr_run lib/libfrr.c:1185 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#14 0x562bf414e58d in main bgpd/bgp_main.c:505 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- sonic-net#15 0x7f163de66d09 in __libc_start_main ../csu/libc-start.c:308 ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444- ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-SUMMARY: AddressSanitizer: 304 byte(s) leaked in 2 allocation(s). Signed-off-by: Samanvitha B Bhargav <bsamanvitha@vmware.com> (cherry picked from commit 7a70d99) Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
dgsudharsan
pushed a commit
to dgsudharsan/sonic-frr
that referenced
this pull request
Jun 6, 2023
two things: On shutdown cleanup any events associated with the update walker. Also do not allow new events to be created. Fixes this mem-leak: ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790:Direct leak of 8 byte(s) in 1 object(s) allocated from: ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- #0 0x7f0dd0b08037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#1 0x7f0dd06c19f9 in qcalloc lib/memory.c:105 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#2 0x55b42fb605bc in rib_update_ctx_init zebra/zebra_rib.c:4383 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#3 0x55b42fb6088f in rib_update zebra/zebra_rib.c:4421 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#4 0x55b42fa00344 in netlink_link_change zebra/if_netlink.c:2221 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#5 0x55b42fa24622 in netlink_information_fetch zebra/kernel_netlink.c:399 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#6 0x55b42fa28c02 in netlink_parse_info zebra/kernel_netlink.c:1183 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#7 0x55b42fa24951 in kernel_read zebra/kernel_netlink.c:493 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#8 0x7f0dd0797f0c in event_call lib/event.c:1995 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#9 0x7f0dd0684fd9 in frr_run lib/libfrr.c:1185 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#10 0x55b42fa30caa in main zebra/main.c:465 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#11 0x7f0dd01b5d09 in __libc_start_main ../csu/libc-start.c:308 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s). Signed-off-by: Donald Sharp <sharpd@nvidia.com> (cherry picked from commit 3cd0acc) Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
dgsudharsan
pushed a commit
that referenced
this pull request
Dec 7, 2023
Fix a crash because a use-after-free. > ================================================================= > ==1249835==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000074210 at pc 0x7fa1b42a652c bp 0x7ffc477a2aa0 sp 0x7ffc477a2a98 > READ of size 8 at 0x604000074210 thread T0 > #0 0x7fa1b42a652b in list_delete_all_node git/frr/lib/linklist.c:299:20 > #1 0x7fa1b42a683f in list_delete git/frr/lib/linklist.c:312:2 > #2 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4 > #3 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2 > #4 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2 > #5 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4 > #6 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > #7 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > #8 0x556808 in main git/frr/zebra/main.c:488:2 > #9 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > #10 0x4453e9 in _start (/usr/lib/frr/zebra+0x4453e9) > > 0x604000074210 is located 0 bytes inside of 40-byte region [0x604000074210,0x604000074238) > freed by thread T0 here: > #0 0x4bf1dd in free (/usr/lib/frr/zebra+0x4bf1dd) > #1 0x7fa1b42df0c0 in qfree git/frr/lib/memory.c:130:2 > #2 0x7fa1b42a68ce in list_free_internal git/frr/lib/linklist.c:24:2 > #3 0x7fa1b42a6870 in list_delete git/frr/lib/linklist.c:313:2 > #4 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4 > #5 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2 > #6 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2 > #7 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4 > #8 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > #9 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > #10 0x556808 in main git/frr/zebra/main.c:488:2 > #11 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > > previously allocated by thread T0 here: > #0 0x4bf5d2 in calloc (/usr/lib/frr/zebra+0x4bf5d2) > #1 0x7fa1b42dee18 in qcalloc git/frr/lib/memory.c:105:27 > #2 0x7fa1b42a3784 in list_new git/frr/lib/linklist.c:18:9 > #3 0x6d165f in pbr_iptable_alloc_intern git/frr/zebra/zebra_pbr.c:1015:29 > #4 0x7fa1b426ad1f in hash_get git/frr/lib/hash.c:147:13 > #5 0x6d15f2 in zebra_pbr_add_iptable git/frr/zebra/zebra_pbr.c:1030:13 > #6 0x5db2a3 in zread_iptable git/frr/zebra/zapi_msg.c:3759:3 > #7 0x5e365d in zserv_handle_commands git/frr/zebra/zapi_msg.c:4039:3 > #8 0x7e09fc in zserv_process_messages git/frr/zebra/zserv.c:520:3 > #9 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > #10 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > #11 0x556808 in main git/frr/zebra/main.c:488:2 > #12 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 Fixes: 1cc3806 ("zebra: Actually free all memory associated ctx->u.iptable.interface_name_list") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 45140bb)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
This commit addresses a memory leak issue in the BGP Flowspec NLRI parsing function. Previously when processing NLRI, dynamically allocated memory to `temp` was not being freed, leading to a memory leak. The commit introduces the necessary code (XFREE) to properly free the temp memory after processing Flowspec NLRI. The ASan leak log for reference: ``` ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689:Direct leak of 56 byte(s) in 2 object(s) allocated from: ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- #0 0x7fc9872b5037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#1 0x7fc986e5b1ee in qcalloc lib/memory.c:105 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#2 0x560421351bfe in bgp_nlri_parse_flowspec bgpd/bgp_flowspec.c:155 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#3 0x56042107d01c in bgp_nlri_parse bgpd/bgp_packet.c:350 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#4 0x560421086cf3 in bgp_update_receive bgpd/bgp_packet.c:2023 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#5 0x56042108deed in bgp_process_packet bgpd/bgp_packet.c:2933 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#6 0x7fc986f35bf7 in event_call lib/event.c:1995 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#7 0x7fc986e1e99d in frr_run lib/libfrr.c:1185 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#8 0x560420f3f59d in main bgpd/bgp_main.c:505 ./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689- sonic-net#9 0x7fc986805d09 in __libc_start_main ../csu/libc-start.c:308 ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
This commit ensures proper cleanup by deleting the gm_join_list when a PIM interface is deleted. The gm_join_list was previously not being freed, causing a memory leak. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in multicast_mld_join_topo1.test_multicast_mld_local_join/r1.asan.pim6d.28070 ================================================================= ==28070==ERROR: LeakSanitizer: detected memory leaks Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105 sonic-net#2 0x56230372180f in list_new lib/linklist.c:49 sonic-net#3 0x56230361b589 in pim_if_gm_join_add pimd/pim_iface.c:1313 sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868 sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235 sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579 sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710 sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104 sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137 sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49 sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88 sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991 sonic-net#13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053 sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221 sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591 sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354 sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362 sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995 sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213 sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184 sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 192 byte(s) in 4 object(s) allocated from: #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105 sonic-net#2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288 sonic-net#3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326 sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868 sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235 sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579 sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710 sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104 sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137 sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49 sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88 sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991 sonic-net#13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053 sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221 sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591 sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354 sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362 sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995 sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213 sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184 sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 96 byte(s) in 4 object(s) allocated from: #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105 sonic-net#2 0x562303721651 in listnode_new lib/linklist.c:71 sonic-net#3 0x56230372182b in listnode_add lib/linklist.c:92 sonic-net#4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295 sonic-net#5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326 sonic-net#6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868 sonic-net#7 0x562303767280 in nb_callback_create lib/northbound.c:1235 sonic-net#8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579 sonic-net#9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710 sonic-net#10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104 sonic-net#11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137 sonic-net#12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49 sonic-net#13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88 sonic-net#14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991 sonic-net#15 0x5623036c5f1b in cmd_execute_command lib/command.c:1053 sonic-net#16 0x5623036c6392 in cmd_execute lib/command.c:1221 sonic-net#17 0x5623037e75da in vty_command lib/vty.c:591 sonic-net#18 0x5623037e7a74 in vty_execute lib/vty.c:1354 sonic-net#19 0x5623037f0253 in vtysh_read lib/vty.c:2362 sonic-net#20 0x5623037db4e8 in event_call lib/event.c:1995 sonic-net#21 0x562303720f97 in frr_run lib/libfrr.c:1213 sonic-net#22 0x56230368615d in main pimd/pim6_main.c:184 sonic-net#23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105 sonic-net#2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288 sonic-net#3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326 sonic-net#4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868 sonic-net#5 0x562303767280 in nb_callback_create lib/northbound.c:1235 sonic-net#6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579 sonic-net#7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710 sonic-net#8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104 sonic-net#9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137 sonic-net#10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49 sonic-net#11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88 sonic-net#12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991 sonic-net#13 0x5623036c5f6f in cmd_execute_command lib/command.c:1072 sonic-net#14 0x5623036c6392 in cmd_execute lib/command.c:1221 sonic-net#15 0x5623037e75da in vty_command lib/vty.c:591 sonic-net#16 0x5623037e7a74 in vty_execute lib/vty.c:1354 sonic-net#17 0x5623037f0253 in vtysh_read lib/vty.c:2362 sonic-net#18 0x5623037db4e8 in event_call lib/event.c:1995 sonic-net#19 0x562303720f97 in frr_run lib/libfrr.c:1213 sonic-net#20 0x56230368615d in main pimd/pim6_main.c:184 sonic-net#21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x56230373dd6b in qcalloc lib/memory.c:105 sonic-net#2 0x562303721651 in listnode_new lib/linklist.c:71 sonic-net#3 0x56230372182b in listnode_add lib/linklist.c:92 sonic-net#4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295 sonic-net#5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326 sonic-net#6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868 sonic-net#7 0x562303767280 in nb_callback_create lib/northbound.c:1235 sonic-net#8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579 sonic-net#9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710 sonic-net#10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104 sonic-net#11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137 sonic-net#12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49 sonic-net#13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88 sonic-net#14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991 sonic-net#15 0x5623036c5f6f in cmd_execute_command lib/command.c:1072 sonic-net#16 0x5623036c6392 in cmd_execute lib/command.c:1221 sonic-net#17 0x5623037e75da in vty_command lib/vty.c:591 sonic-net#18 0x5623037e7a74 in vty_execute lib/vty.c:1354 sonic-net#19 0x5623037f0253 in vtysh_read lib/vty.c:2362 sonic-net#20 0x5623037db4e8 in event_call lib/event.c:1995 sonic-net#21 0x562303720f97 in frr_run lib/libfrr.c:1213 sonic-net#22 0x56230368615d in main pimd/pim6_main.c:184 sonic-net#23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 400 byte(s) leaked in 11 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Memory leaks started flowing: ``` AddressSanitizer Topotests Part 0: 15 KB -> 283 KB AddressSanitizer Topotests Part 1: 1 KB -> 495 KB AddressSanitizer Topotests Part 2: 13 KB -> 478 KB AddressSanitizer Topotests Part 3: 39 KB -> 213 KB AddressSanitizer Topotests Part 4: 30 KB -> 836 KB AddressSanitizer Topotests Part 5: 0 bytes -> 356 KB AddressSanitizer Topotests Part 6: 86 KB -> 783 KB AddressSanitizer Topotests Part 7: 0 bytes -> 354 KB AddressSanitizer Topotests Part 8: 0 bytes -> 62 KB AddressSanitizer Topotests Part 9: 408 KB -> 518 KB ``` ``` Direct leak of 3584 byte(s) in 1 object(s) allocated from: #0 0x7f1957b02d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x559895c55df0 in qcalloc lib/memory.c:105 sonic-net#2 0x559895bc1cdf in zserv_client_create zebra/zserv.c:743 sonic-net#3 0x559895bc1cdf in zserv_accept zebra/zserv.c:880 sonic-net#4 0x559895cf3438 in event_call lib/event.c:1995 sonic-net#5 0x559895c3901c in frr_run lib/libfrr.c:1213 sonic-net#6 0x559895a698f1 in main zebra/main.c:472 sonic-net#7 0x7f195635ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) ``` Fixes b20acd0 ("bgpd: Use synchronous way to get labels from Zebra") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
The loading_done event needs a event pointer to prevent use after free's. Testing found this: ERROR: AddressSanitizer: heap-use-after-free on address 0x613000035130 at pc 0x55ad42d54e5f bp 0x7ffff1e942a0 sp 0x7ffff1e94290 READ of size 1 at 0x613000035130 thread T0 #0 0x55ad42d54e5e in loading_done ospf6d/ospf6_neighbor.c:447 sonic-net#1 0x55ad42ed7be4 in event_call lib/event.c:1995 sonic-net#2 0x55ad42e1df75 in frr_run lib/libfrr.c:1213 sonic-net#3 0x55ad42cf332e in main ospf6d/ospf6_main.c:250 sonic-net#4 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) sonic-net#5 0x55ad42cf2b19 in _start (/usr/lib/frr/ospf6d+0x248b19) 0x613000035130 is located 48 bytes inside of 384-byte region [0x613000035100,0x613000035280) freed by thread T0 here: #0 0x7f57998d77a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8) sonic-net#1 0x55ad42e3b4b6 in qfree lib/memory.c:130 sonic-net#2 0x55ad42d5d049 in ospf6_neighbor_delete ospf6d/ospf6_neighbor.c:180 sonic-net#3 0x55ad42d1e1ea in interface_down ospf6d/ospf6_interface.c:930 sonic-net#4 0x55ad42ed7be4 in event_call lib/event.c:1995 sonic-net#5 0x55ad42ed84fe in _event_execute lib/event.c:2086 sonic-net#6 0x55ad42d26d7b in ospf6_interface_clear ospf6d/ospf6_interface.c:2847 sonic-net#7 0x55ad42d73f16 in ospf6_process_reset ospf6d/ospf6_top.c:755 sonic-net#8 0x55ad42d7e98c in clear_router_ospf6_magic ospf6d/ospf6_top.c:778 sonic-net#9 0x55ad42d7e98c in clear_router_ospf6 ospf6d/ospf6_top_clippy.c:42 sonic-net#10 0x55ad42dc2665 in cmd_execute_command_real lib/command.c:994 sonic-net#11 0x55ad42dc2b32 in cmd_execute_command lib/command.c:1053 sonic-net#12 0x55ad42dc2fa9 in cmd_execute lib/command.c:1221 sonic-net#13 0x55ad42ee3cd6 in vty_command lib/vty.c:591 sonic-net#14 0x55ad42ee4170 in vty_execute lib/vty.c:1354 sonic-net#15 0x55ad42eec94f in vtysh_read lib/vty.c:2362 sonic-net#16 0x55ad42ed7be4 in event_call lib/event.c:1995 sonic-net#17 0x55ad42e1df75 in frr_run lib/libfrr.c:1213 sonic-net#18 0x55ad42cf332e in main ospf6d/ospf6_main.c:250 sonic-net#19 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) previously allocated by thread T0 here: #0 0x7f57998d7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x55ad42e3ab22 in qcalloc lib/memory.c:105 sonic-net#2 0x55ad42d5c8ff in ospf6_neighbor_create ospf6d/ospf6_neighbor.c:119 sonic-net#3 0x55ad42d4c86a in ospf6_hello_recv ospf6d/ospf6_message.c:464 sonic-net#4 0x55ad42d4c86a in ospf6_read_helper ospf6d/ospf6_message.c:1884 sonic-net#5 0x55ad42d4c86a in ospf6_receive ospf6d/ospf6_message.c:1925 sonic-net#6 0x55ad42ed7be4 in event_call lib/event.c:1995 sonic-net#7 0x55ad42e1df75 in frr_run lib/libfrr.c:1213 sonic-net#8 0x55ad42cf332e in main ospf6d/ospf6_main.c:250 sonic-net#9 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Add an actual event pointer and just track it appropriately. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
The function ospf6_router_lsa_contains_adj(), ospf6_gr_check_adjs() and ospf6_find_interf_prefix_lsa() iterate through LSDB and lock each LSA. During testing, it was discovered that the lock count did not reach zero upon termination. The stack trace below indicates the leak. To resolve this issue, it was found that unlocking the LSA before returning from the functions solves the problem. This suggests that there was a missing unlock that caused the lock count to remain nonzero. ================================================================= ==22565==ERROR: LeakSanitizer: detected memory leaks Direct leak of 400 byte(s) in 2 object(s) allocated from: #0 0x7fa744ccea37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7fa744867562 in qcalloc ../lib/memory.c:105 sonic-net#2 0x555cdbb37506 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:710 sonic-net#3 0x555cdbb375d6 in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725 sonic-net#4 0x555cdbaf1008 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912 sonic-net#5 0x555cdbb48ceb in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621 sonic-net#6 0x555cdbb4ac90 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896 sonic-net#7 0x555cdbb4aecc in ospf6_receive ../ospf6d/ospf6_message.c:1925 sonic-net#8 0x7fa744950c33 in event_call ../lib/event.c:1995 sonic-net#9 0x7fa74483b34a in frr_run ../lib/libfrr.c:1213 sonic-net#10 0x555cdbacf1eb in main ../ospf6d/ospf6_main.c:250 sonic-net#11 0x7fa7443f9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x6110000606c0 (200 bytes) 0x611000060940 (200 bytes) Indirect leak of 80 byte(s) in 2 object(s) allocated from: #0 0x7fa744cce867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 sonic-net#1 0x7fa744867525 in qmalloc ../lib/memory.c:100 sonic-net#2 0x555cdbb37520 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:711 sonic-net#3 0x555cdbb375d6 in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725 sonic-net#4 0x555cdbaf1008 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912 sonic-net#5 0x555cdbb48ceb in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621 sonic-net#6 0x555cdbb4ac90 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896 sonic-net#7 0x555cdbb4aecc in ospf6_receive ../ospf6d/ospf6_message.c:1925 sonic-net#8 0x7fa744950c33 in event_call ../lib/event.c:1995 sonic-net#9 0x7fa74483b34a in frr_run ../lib/libfrr.c:1213 sonic-net#10 0x555cdbacf1eb in main ../ospf6d/ospf6_main.c:250 sonic-net#11 0x7fa7443f9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x6040000325d0 (40 bytes) 0x604000032650 (40 bytes) SUMMARY: AddressSanitizer: 480 byte(s) leaked in 4 allocation(s). ================================================================= ==5483==ERROR: LeakSanitizer: detected memory leaks Direct leak of 2000 byte(s) in 10 object(s) allocated from: #0 0x7f2c3faeea37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7f2c3f68a6d9 in qcalloc ../lib/memory.c:105 sonic-net#2 0x56431b83633d in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:710 sonic-net#3 0x56431b83640d in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725 sonic-net#4 0x56431b7efe13 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912 sonic-net#5 0x56431b847b31 in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621 sonic-net#6 0x56431b849ad6 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896 sonic-net#7 0x56431b849d12 in ospf6_receive ../ospf6d/ospf6_message.c:1925 sonic-net#8 0x7f2c3f773c62 in event_call ../lib/event.c:1995 sonic-net#9 0x7f2c3f65e2de in frr_run ../lib/libfrr.c:1213 sonic-net#10 0x56431b7cdff6 in main ../ospf6d/ospf6_main.c:221 sonic-net#11 0x7f2c3f21dd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x611000060800 (200 bytes) 0x611000060a80 (200 bytes) 0x611000060d00 (200 bytes) 0x611000060f80 (200 bytes) 0x611000061200 (200 bytes) 0x611000061480 (200 bytes) 0x611000061840 (200 bytes) 0x611000061ac0 (200 bytes) 0x61100006c740 (200 bytes) 0x61100006d500 (200 bytes) Indirect leak of 460 byte(s) in 10 object(s) allocated from: #0 0x7f2c3faee867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 sonic-net#1 0x7f2c3f68a69c in qmalloc ../lib/memory.c:100 sonic-net#2 0x56431b836357 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:711 sonic-net#3 0x56431b83640d in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725 sonic-net#4 0x56431b7efe13 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912 sonic-net#5 0x56431b847b31 in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621 sonic-net#6 0x56431b849ad6 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896 sonic-net#7 0x56431b849d12 in ospf6_receive ../ospf6d/ospf6_message.c:1925 sonic-net#8 0x7f2c3f773c62 in event_call ../lib/event.c:1995 sonic-net#9 0x7f2c3f65e2de in frr_run ../lib/libfrr.c:1213 sonic-net#10 0x56431b7cdff6 in main ../ospf6d/ospf6_main.c:221 sonic-net#11 0x7f2c3f21dd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x604000033110 (40 bytes) 0x604000033190 (40 bytes) 0x604000033210 (44 bytes) 0x604000033290 (44 bytes) 0x604000033310 (44 bytes) 0x604000033390 (44 bytes) 0x604000033410 (44 bytes) 0x604000033490 (44 bytes) 0x604000034c90 (44 bytes) 0x6070000d3830 (72 bytes) SUMMARY: AddressSanitizer: 2460 byte(s) leaked in 20 allocation(s). Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
The bgp vpn policy had some attribute not free when the function bgp_free was called leading to memory leak as shown below. ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 592 byte(s) in 2 object(s) allocated from: ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#2 0x7f4b7aa9bec9 in srv6_locator_chunk_alloc lib/srv6.c:135 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#3 0x56396f8e56f8 in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:752 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#4 0x56396f8e608a in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:846 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#5 0x56396f8e075d in vpn_leak_postchange bgpd/bgp_mplsvpn.h:259 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#6 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#7 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#8 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#9 0x7f4b7ab62010 in thread_call lib/thread.c:1991 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#10 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#11 0x56396f7d756d in main bgpd/bgp_main.c:505 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#12 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 32 byte(s) in 2 object(s) allocated from: ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#2 0x56396f8e31b8 in vpn_leak_zebra_vrf_sid_update_per_af bgpd/bgp_mplsvpn.c:386 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#3 0x56396f8e3ae8 in vpn_leak_zebra_vrf_sid_update bgpd/bgp_mplsvpn.c:448 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#4 0x56396f8e09b0 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:271 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#5 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#6 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#7 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#8 0x7f4b7ab62010 in thread_call lib/thread.c:1991 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#9 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#10 0x56396f7d756d in main bgpd/bgp_main.c:505 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#11 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 32 byte(s) in 2 object(s) allocated from: ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#2 0x56396f8e5730 in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:753 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#3 0x56396f8e608a in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:846 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#4 0x56396f8e075d in vpn_leak_postchange bgpd/bgp_mplsvpn.h:259 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#5 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#6 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#7 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#8 0x7f4b7ab62010 in thread_call lib/thread.c:1991 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#9 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#10 0x56396f7d756d in main bgpd/bgp_main.c:505 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- sonic-net#11 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308 ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251- ./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-SUMMARY: AddressSanitizer: 656 byte(s) leaked in 6 allocation(s). Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
The `bgp_vrf->vrf_prd_pretty` string was not properly freed, leading to a memory leak. This commit resolves the memory leak by freeing the memory allocated for `bgp_vrf->vrf_prd_pretty` before returning from the function. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in evpn_type5_test_topo1.test_evpn_type5_topo1/e1.asan.bgpd.17689 ================================================================= ==17689==ERROR: LeakSanitizer: detected memory leaks Direct leak of 15 byte(s) in 1 object(s) allocated from: #0 0x7fdd94fc0538 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x77538) sonic-net#1 0x55e28d9c4c6c in qstrdup lib/memory.c:117 sonic-net#2 0x55e28d6c0d27 in evpn_configure_vrf_rd bgpd/bgp_evpn_vty.c:2297 sonic-net#3 0x55e28d6c0d27 in bgp_evpn_vrf_rd bgpd/bgp_evpn_vty.c:6271 sonic-net#4 0x55e28d94c155 in cmd_execute_command_real lib/command.c:994 sonic-net#5 0x55e28d94c622 in cmd_execute_command lib/command.c:1053 sonic-net#6 0x55e28d94ca99 in cmd_execute lib/command.c:1221 sonic-net#7 0x55e28da6d7d4 in vty_command lib/vty.c:591 sonic-net#8 0x55e28da6dc6e in vty_execute lib/vty.c:1354 sonic-net#9 0x55e28da7644d in vtysh_read lib/vty.c:2362 sonic-net#10 0x55e28da616e2 in event_call lib/event.c:1995 sonic-net#11 0x55e28d9a7a65 in frr_run lib/libfrr.c:1213 sonic-net#12 0x55e28d63ef00 in main bgpd/bgp_main.c:505 sonic-net#13 0x7fdd93883c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 15 byte(s) leaked in 1 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
`bmnc->nh` was not properly freed, leading to a memory leak. The commit adds a check to ensure that the `bmnc->nh` member variable is freed if it exists. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in bgp_vpnv4_asbr.test_bgp_vpnv4_asbr/r2.asan.bgpd.6382 ================================================================= ==6382==ERROR: LeakSanitizer: detected memory leaks Direct leak of 720 byte(s) in 5 object(s) allocated from: #0 0x7f6a80d02d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x55c9afd7c81c in qcalloc lib/memory.c:105 sonic-net#2 0x55c9afd9166b in nexthop_new lib/nexthop.c:358 sonic-net#3 0x55c9afd93aaa in nexthop_dup lib/nexthop.c:843 sonic-net#4 0x55c9afad39bb in bgp_mplsvpn_nh_label_bind_register_local_label bgpd/bgp_mplsvpn.c:4259 sonic-net#5 0x55c9afb1c5e9 in bgp_mplsvpn_handle_label_allocation bgpd/bgp_route.c:3239 sonic-net#6 0x55c9afb1c5e9 in bgp_process_main_one bgpd/bgp_route.c:3339 sonic-net#7 0x55c9afb1d2c1 in bgp_process_wq bgpd/bgp_route.c:3591 sonic-net#8 0x55c9afe33df9 in work_queue_run lib/workqueue.c:266 sonic-net#9 0x55c9afe198e2 in event_call lib/event.c:1995 sonic-net#10 0x55c9afd5fc6f in frr_run lib/libfrr.c:1213 sonic-net#11 0x55c9af9f6f00 in main bgpd/bgp_main.c:505 sonic-net#12 0x7f6a7f55ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 16 byte(s) in 2 object(s) allocated from: #0 0x7f6a80d02d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x55c9afd7c81c in qcalloc lib/memory.c:105 sonic-net#2 0x55c9afd91ce8 in nexthop_add_labels lib/nexthop.c:536 sonic-net#3 0x55c9afd93754 in nexthop_copy_no_recurse lib/nexthop.c:802 sonic-net#4 0x55c9afd939fb in nexthop_copy lib/nexthop.c:821 sonic-net#5 0x55c9afd93abb in nexthop_dup lib/nexthop.c:845 sonic-net#6 0x55c9afad39bb in bgp_mplsvpn_nh_label_bind_register_local_label bgpd/bgp_mplsvpn.c:4259 sonic-net#7 0x55c9afb1c5e9 in bgp_mplsvpn_handle_label_allocation bgpd/bgp_route.c:3239 sonic-net#8 0x55c9afb1c5e9 in bgp_process_main_one bgpd/bgp_route.c:3339 sonic-net#9 0x55c9afb1d2c1 in bgp_process_wq bgpd/bgp_route.c:3591 sonic-net#10 0x55c9afe33df9 in work_queue_run lib/workqueue.c:266 sonic-net#11 0x55c9afe198e2 in event_call lib/event.c:1995 sonic-net#12 0x55c9afd5fc6f in frr_run lib/libfrr.c:1213 sonic-net#13 0x55c9af9f6f00 in main bgpd/bgp_main.c:505 sonic-net#14 0x7f6a7f55ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 736 byte(s) leaked in 7 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
In the function ospf_lsa_translated_nssa_new the newly created lsa is lock however, the return lsa from ospf_lsa_new already has a lock. Therefore removing the addition lock resolve the leak below. ospf_basic_functionality.test_ospf_nssa#r3.asan.ospfd.5456 ================================================================= ==5456==ERROR: LeakSanitizer: detected memory leaks Direct leak of 640 byte(s) in 5 object(s) allocated from: #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7f294eeed562 in qcalloc ../lib/memory.c:105 sonic-net#2 0x561a16004f60 in ospf_lsa_new ../ospfd/ospf_lsa.c:186 sonic-net#3 0x561a160051a1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:205 sonic-net#4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762 sonic-net#5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863 sonic-net#6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985 sonic-net#7 0x561a16011cfb in ospf_translated_nssa_refresh ../ospfd/ospf_lsa.c:2152 sonic-net#8 0x561a16014bb2 in ospf_external_lsa_install ../ospfd/ospf_lsa.c:2871 sonic-net#9 0x561a1601596b in ospf_lsa_install ../ospfd/ospf_lsa.c:3076 sonic-net#10 0x561a16168b3c in ospf_flood ../ospfd/ospf_flood.c:482 sonic-net#11 0x561a160462f8 in ospf_ls_upd ../ospfd/ospf_packet.c:2115 sonic-net#12 0x561a1604c66c in ospf_read_helper ../ospfd/ospf_packet.c:3198 sonic-net#13 0x561a1604c88e in ospf_read ../ospfd/ospf_packet.c:3229 sonic-net#14 0x7f294efd6c33 in event_call ../lib/event.c:1995 sonic-net#15 0x7f294eec134a in frr_run ../lib/libfrr.c:1213 sonic-net#16 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249 sonic-net#17 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x60c000062800 (128 bytes) 0x60c000062c80 (128 bytes) 0x60c0000631c0 (128 bytes) 0x60c000063700 (128 bytes) 0x60c000063d00 (128 bytes) Direct leak of 640 byte(s) in 5 object(s) allocated from: #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7f294eeed562 in qcalloc ../lib/memory.c:105 sonic-net#2 0x561a16004f60 in ospf_lsa_new ../ospfd/ospf_lsa.c:186 sonic-net#3 0x561a160051a1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:205 sonic-net#4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762 sonic-net#5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863 sonic-net#6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985 sonic-net#7 0x561a16010e10 in ospf_translated_nssa_originate ../ospfd/ospf_lsa.c:2034 sonic-net#8 0x561a16136559 in ospf_abr_translate_nssa ../ospfd/ospf_abr.c:668 sonic-net#9 0x561a161383da in ospf_abr_process_nssa_translates ../ospfd/ospf_abr.c:968 sonic-net#10 0x561a1613f9b8 in ospf_abr_nssa_task ../ospfd/ospf_abr.c:2054 sonic-net#11 0x561a161402e5 in ospf_abr_task_timer ../ospfd/ospf_abr.c:2168 sonic-net#12 0x7f294efd6c33 in event_call ../lib/event.c:1995 sonic-net#13 0x7f294eec134a in frr_run ../lib/libfrr.c:1213 sonic-net#14 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249 sonic-net#15 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x60c00003e380 (128 bytes) 0x60c00003e740 (128 bytes) 0x60c00003eb00 (128 bytes) 0x60c00005fd40 (128 bytes) 0x60c00005ff80 (128 bytes) Indirect leak of 180 byte(s) in 5 object(s) allocated from: #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7f294eeed562 in qcalloc ../lib/memory.c:105 sonic-net#2 0x561a16005a43 in ospf_lsa_data_new ../ospfd/ospf_lsa.c:296 sonic-net#3 0x561a160051b1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:206 sonic-net#4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762 sonic-net#5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863 sonic-net#6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985 sonic-net#7 0x561a16011cfb in ospf_translated_nssa_refresh ../ospfd/ospf_lsa.c:2152 sonic-net#8 0x561a16014bb2 in ospf_external_lsa_install ../ospfd/ospf_lsa.c:2871 sonic-net#9 0x561a1601596b in ospf_lsa_install ../ospfd/ospf_lsa.c:3076 sonic-net#10 0x561a16168b3c in ospf_flood ../ospfd/ospf_flood.c:482 sonic-net#11 0x561a160462f8 in ospf_ls_upd ../ospfd/ospf_packet.c:2115 sonic-net#12 0x561a1604c66c in ospf_read_helper ../ospfd/ospf_packet.c:3198 sonic-net#13 0x561a1604c88e in ospf_read ../ospfd/ospf_packet.c:3229 sonic-net#14 0x7f294efd6c33 in event_call ../lib/event.c:1995 sonic-net#15 0x7f294eec134a in frr_run ../lib/libfrr.c:1213 sonic-net#16 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249 sonic-net#17 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x60400003f890 (36 bytes) 0x60400003f990 (36 bytes) 0x60400003fa50 (36 bytes) 0x60400003fb10 (36 bytes) 0x60400003fbd0 (36 bytes) Indirect leak of 180 byte(s) in 5 object(s) allocated from: #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 sonic-net#1 0x7f294eeed562 in qcalloc ../lib/memory.c:105 sonic-net#2 0x561a16005a43 in ospf_lsa_data_new ../ospfd/ospf_lsa.c:296 sonic-net#3 0x561a160051b1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:206 sonic-net#4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762 sonic-net#5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863 sonic-net#6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985 sonic-net#7 0x561a16010e10 in ospf_translated_nssa_originate ../ospfd/ospf_lsa.c:2034 sonic-net#8 0x561a16136559 in ospf_abr_translate_nssa ../ospfd/ospf_abr.c:668 sonic-net#9 0x561a161383da in ospf_abr_process_nssa_translates ../ospfd/ospf_abr.c:968 sonic-net#10 0x561a1613f9b8 in ospf_abr_nssa_task ../ospfd/ospf_abr.c:2054 sonic-net#11 0x561a161402e5 in ospf_abr_task_timer ../ospfd/ospf_abr.c:2168 sonic-net#12 0x7f294efd6c33 in event_call ../lib/event.c:1995 sonic-net#13 0x7f294eec134a in frr_run ../lib/libfrr.c:1213 sonic-net#14 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249 sonic-net#15 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Objects leaked above: 0x60400003c6d0 (36 bytes) 0x60400003c790 (36 bytes) 0x60400003c810 (36 bytes) 0x60400003c890 (36 bytes) 0x60400003c910 (36 bytes) SUMMARY: AddressSanitizer: 1640 byte(s) leaked in 20 allocation(s). Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
When `dplane_fpm_nl` receives a route, it allocates memory for a dplane context and calls `netlink_route_change_read_unicast_internal` without initializing the `intf_extra_list` contained in the dplane context. If `netlink_route_change_read_unicast_internal` is not able to process the route, we call `dplane_ctx_fini` to free the dplane context. This causes a crash because `dplane_ctx_fini` attempts to access the intf_extra_list which is not initialized. To solve this issue, we can call `dplane_ctx_route_init`to initialize the dplane route context properly, just after the dplane context allocation. (gdb) bt #0 0x0000555dd5ceae80 in dplane_intf_extra_list_pop (h=0x7fae1c007e68) at ../zebra/zebra_dplane.c:427 sonic-net#1 dplane_ctx_free_internal (ctx=0x7fae1c0074b0) at ../zebra/zebra_dplane.c:724 sonic-net#2 0x0000555dd5cebc99 in dplane_ctx_free (pctx=0x7fae2aa88c98) at ../zebra/zebra_dplane.c:869 sonic-net#3 dplane_ctx_free (pctx=0x7fae2aa88c98, pctx@entry=0x7fae2aa78c28) at ../zebra/zebra_dplane.c:855 sonic-net#4 dplane_ctx_fini (pctx=pctx@entry=0x7fae2aa88c98) at ../zebra/zebra_dplane.c:890 sonic-net#5 0x00007fae31e93f29 in fpm_read (t=) at ../zebra/dplane_fpm_nl.c:605 sonic-net#6 0x00007fae325191dd in thread_call (thread=thread@entry=0x7fae2aa98da0) at ../lib/thread.c:2006 sonic-net#7 0x00007fae324c42b8 in fpt_run (arg=0x555dd74777c0) at ../lib/frr_pthread.c:309 sonic-net#8 0x00007fae32405ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 sonic-net#9 0x00007fae32325a2f in clone () from /lib/x86_64-linux-gnu/libc.so.6 Fixes: #13754 Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Bug is reporoduced in case of switching interfaces betwean VRFs. ospf6d is enabled and configured in each VRF. 'dest' can be removed from the route node in the time when the same route node waiting processing in another sub-queue. A route node must only be in one sub-queue at a time. Details: 1. Config: interface if0 ipv6 address 2001:db8:cafe:2::2/64 ipv6 nat inside ipv6 ospf6 area 0.0.0.51 ipv6 ospf6 cost 10 vrf test2 exit ! interface if1 ipv6 address 2001:db8:cafe:4::1/64 ipv6 nat outside ipv6 ospf6 area 0.0.0.0 ipv6 ospf6 cost 10 vrf test2 exit ! router ospf6 ospf6 router-id 2.2.2.2 exit ! router ospf6 vrf test1 ospf6 router-id 2.2.2.2 exit ! router ospf6 vrf test2 ospf6 router-id 2.2.2.2 exit I just quickly switched interfaces between different VRFs (default/test1/test2). 2. Log messages: Aug 02 16:51:56 ubuntu zebra[386985]: [MFYWV-KH3MC] process_subq_early_route_add: (0:?):2001:db8:cafe:2::/64: Inserting route rn 0x56267593de90, re 0x56267595ae40 (connected) existing 0x0, same_count 0 Aug 02 16:51:56 ubuntu zebra[386985]: [Q4T2G-E2SQF] process_subq_early_route_add: dumping RE entry 0x56267595ae40 for 2001:db8:cafe:2::/64 vrf default(0) Aug 02 16:51:56 ubuntu zebra[386985]: [GCGMT-SQR82] rib_link: (0:?):2001:db8:cafe:2::/64: rn 0x56267593de90 adding dest Aug 02 16:51:56 ubuntu zebra[386985]: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: queued rn 0x56267593de90 into sub-queue Connected Routes Aug 02 16:51:56 ubuntu zebra[386985]: [QE6V0-J8BG5] rib_delnode: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595ae40, removing Aug 02 16:51:56 ubuntu zebra[386985]: [KMPGN-JBRKW] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90 is already queued in sub-queue Connected Routes Aug 02 16:51:56 ubuntu zebra[386985]: [MFYWV-KH3MC] process_subq_early_route_add: (0:254):2001:db8:cafe:2::/64: Inserting route rn 0x56267593de90, re 0x56267595abf0 (ospf6) existing 0x0, same_count 1 Aug 02 16:51:56 ubuntu zebra[386985]: [Q4T2G-E2SQF] process_subq_early_route_add: dumping RE entry 0x56267595abf0 for 2001:db8:cafe:2::/64 vrf default(0) Aug 02 16:51:56 ubuntu zebra[386985]: [KMPGN-JBRKW] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90 is already queued in sub-queue Connected Routes Aug 02 16:51:56 ubuntu zebra[386985]: [YEYFX-TDSC2] process_subq_early_route_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, removing unneeded re 0x56267595ae40 Aug 02 16:51:56 ubuntu zebra[386985]: [Y53JX-CBC5H] rib_unlink: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595ae40 Aug 02 16:51:56 ubuntu zebra[386985]: [QE6V0-J8BG5] rib_delnode: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595abf0, removing Aug 02 16:51:56 ubuntu zebra[386985]: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: queued rn 0x56267593de90 into sub-queue RIP/OSPF/ISIS/EIGRP/NHRP Routes Aug 02 16:51:56 ubuntu zebra[386985]: [NZNZ4-7P54Y] default(0:254):2001:db8:cafe:2::/64: Processing rn 0x56267593de90 Aug 02 16:51:56 ubuntu zebra[386985]: [ZJVZ4-XEGPF] default(0:254):2001:db8:cafe:2::/64: Examine re 0x56267595abf0 (ospf6) status: Removed Changed flags: None dist 110 metric 10 Aug 02 16:51:56 ubuntu zebra[386985]: [NM15X-X83N9] rib_process: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, removing re 0x56267595abf0 Aug 02 16:51:56 ubuntu zebra[386985]: [Y53JX-CBC5H] rib_unlink: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595abf0 Aug 02 16:51:56 ubuntu zebra[386985]: [KT8QQ-45WQ0] rib_gc_dest: (0:?):2001:db8:cafe:2::/64: removing dest from table Aug 02 16:51:56 ubuntu zebra[386985]: [HH6N2-PDCJS] default(0:0):2001:db8:cafe:2::/64 rn 0x56267593de90 dequeued from sub-queue Connected Routes 3. ...and then assert: (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140662163115136) at ./nptl/pthread_kill.c:44 sonic-net#1 __pthread_kill_internal (signo=6, threadid=140662163115136) at ./nptl/pthread_kill.c:78 sonic-net#2 __GI___pthread_kill (threadid=140662163115136, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 sonic-net#3 0x00007fee76753476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 sonic-net#4 0x00007fee767397f3 in __GI_abort () at ./stdlib/abort.c:79 sonic-net#5 0x00007fee76a420fd in _zlog_assert_failed () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0 sonic-net#6 0x0000562674efe0f0 in process_subq_route (qindex=7 '\a', lnode=0x562675940c60) at zebra/zebra_rib.c:2540 sonic-net#7 process_subq (qindex=META_QUEUE_NOTBGP, subq=0x562675574580) at zebra/zebra_rib.c:3055 sonic-net#8 meta_queue_process (dummy=<optimized out>, data=0x56267556d430) at zebra/zebra_rib.c:3091 sonic-net#9 0x00007fee76a386e8 in work_queue_run () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0 sonic-net#10 0x00007fee76a31c91 in thread_call () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0 sonic-net#11 0x00007fee769ee528 in frr_run () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0 sonic-net#12 0x0000562674e97ec5 in main (argc=5, argv=0x7ffd1e275958) at zebra/main.c:478 (gdb) print lnode->data $10 = (void *) 0x56267593de90 (gdb) p/x *(struct route_node *)0x56267593de90 $11 = { p = { family = 0xa, prefixlen = 0x40, u = { prefix = 0x20, prefix4 = { s_addr = 0xb80d0120 }, prefix6 = { __in6_u = { __u6_addr8 = {0x20, 0x1, 0xd, 0xb8, 0xca, 0xfe, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, __u6_addr16 = {0x120, 0xb80d, 0xfeca, 0x200, 0x0, 0x0, 0x0, 0x0}, __u6_addr32 = {0xb80d0120, 0x200feca, 0x0, 0x0} } }, ... table = 0x5626755ae010, parent = 0x5626755ae070, link = {0x0, 0x0}, lock = 0x4, nodehash = { hi = { next = 0x5626755ae0d0, hashval = 0xebe8bdbf } }, info = 0x0 3. What's happen: We removed unneeded re 0x56267595ae40 while adding re 0x56267595abf0. It was the last connected re, but rn 0x56267593de90 is still in the connected sub-queue. Then rib_delnode was called for 0x56267595abf0. (rn 0x56267593de90 is still in the connected sub-queue). rib_delnode have called rib_meta_queue_add which have checked, that rn is absent in sub-queue RIP/OSPF/ISIS/EIGRP/NHRP and have added rn in the second sub-queue. Fixes: d7ac4c4 ("zebra: Introduce early route processing on the MetaQ") Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
After the ISIS daemon is launched, the configuration of an srv6 locator in zebra triggers a crash: > sonic-net#4 0x00007f1f0ea980f3 in core_handler (signo=11, siginfo=0x7ffdb750de70, context=0x7ffdb750dd40) > at /build/make-pkg/output/_packages/cp-routing/src/lib/sigevent.c:262 > sonic-net#5 <signal handler called> > sonic-net#6 0x00005651a05783ef in isis_zebra_process_srv6_locator_add (cmd=117, zclient=0x5651a21d9bd0, length=25, vrf_id=0) > at /build/make-pkg/output/_packages/cp-routing/src/isisd/isis_zebra.c:1258 > sonic-net#7 0x00007f1f0ead5ac9 in zclient_read (thread=0x7ffdb750e750) at /build/make-pkg/output/_packages/cp-routing/src/lib/zclient.c:4246 > sonic-net#8 0x00007f1f0eab19d4 in thread_call (thread=0x7ffdb750e750) at /build/make-pkg/output/_packages/cp-routing/src/lib/thread.c:1825 > sonic-net#9 0x00007f1f0ea4862e in frr_run (master=0x5651a1f65a40) at /build/make-pkg/output/_packages/cp-routing/src/lib/libfrr.c:1155 > sonic-net#10 0x00005651a051131a in main (argc=5, argv=0x7ffdb750e998, envp=0x7ffdb750e9c8) > at /build/make-pkg/output/_packages/cp-routing/src/isisd/isis_main.c:282 > (gdb) f 6 > sonic-net#6 0x00005651a05783ef in isis_zebra_process_srv6_locator_add (cmd=117, zclient=0x5651a21d9bd0, length=25, vrf_id=0) > at /build/make-pkg/output/_packages/cp-routing/src/isisd/isis_zebra.c:1258 > (gdb) print isis > $1 = (struct isis *) 0x0 > (gdb) print isis->area_list > Cannot access memory at address 0x28 The isis pointer is NULL, because no instances have already been configured on the ISIS instance. Fix this by checking that there is any isis instance available when zebra hooks related to srv6 are received. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
`ng` was not properly freed, leading to a memory leak. The commit calls `nexthop_group_delete` to free memory associated with `ng`. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in isis_topo1.test_isis_topo1/r5.asan.zebra.24308 ================================================================= ==24308==ERROR: LeakSanitizer: detected memory leaks Direct leak of 32 byte(s) in 1 object(s) allocated from: #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105 sonic-net#2 0x7f4f47559526 in nexthop_group_new lib/nexthop_group.c:270 sonic-net#3 0x562ded6a39d4 in zebra_add_import_table_entry zebra/redistribute.c:681 sonic-net#4 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972 sonic-net#5 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993 sonic-net#6 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860 sonic-net#7 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138 sonic-net#8 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178 sonic-net#9 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228 sonic-net#10 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266 sonic-net#11 0x7f4f475dc7f2 in event_call lib/event.c:1969 sonic-net#12 0x7f4f4751f347 in frr_run lib/libfrr.c:1213 sonic-net#13 0x562ded69e818 in main zebra/main.c:486 sonic-net#14 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 152 byte(s) in 1 object(s) allocated from: #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105 sonic-net#2 0x7f4f475510ad in nexthop_new lib/nexthop.c:376 sonic-net#3 0x7f4f475539c5 in nexthop_dup lib/nexthop.c:914 sonic-net#4 0x7f4f4755b27a in copy_nexthops lib/nexthop_group.c:444 sonic-net#5 0x562ded6a3a1c in zebra_add_import_table_entry zebra/redistribute.c:682 sonic-net#6 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972 sonic-net#7 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993 sonic-net#8 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860 sonic-net#9 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138 sonic-net#10 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178 sonic-net#11 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228 sonic-net#12 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266 sonic-net#13 0x7f4f475dc7f2 in event_call lib/event.c:1969 sonic-net#14 0x7f4f4751f347 in frr_run lib/libfrr.c:1213 sonic-net#15 0x562ded69e818 in main zebra/main.c:486 sonic-net#16 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 184 byte(s) leaked in 2 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
The shallow copy of attr wasn't freed when there was no valid label for the momentand the function return therefore creating leaks. The leak below are solved by flushing the shallow copy of attr. Address Sanitizer Error detected in bgp_vpnv6_per_nexthop_label.test_bgp_vpnv6_per_nexthop_label/r1.asan.bgpd.13409 ================================================================= ==13409==ERROR: LeakSanitizer: detected memory leaks Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88c13b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x5623b89beabc in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x5623b89beabc in af_label_vpn_export_allocation_mode_magic bgpd/bgp_vty.c:9464 sonic-net#7 0x5623b89beabc in af_label_vpn_export_allocation_mode bgpd/bgp_vty_clippy.c:2809 sonic-net#8 0x7f62cca45511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f62cca459d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f62cca45e54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f62ccb6ee20 in vty_command lib/vty.c:591 sonic-net#12 0x7f62ccb6f2cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f62ccb77b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#15 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b892e86d in bgp_update bgpd/bgp_route.c:4969 sonic-net#5 0x5623b893134d in bgp_nlri_parse_ip bgpd/bgp_route.c:6213 sonic-net#6 0x5623b88e2a0e in bgp_nlri_parse bgpd/bgp_packet.c:341 sonic-net#7 0x5623b88e4f7c in bgp_update_receive bgpd/bgp_packet.c:2220 sonic-net#8 0x5623b88f0474 in bgp_process_packet bgpd/bgp_packet.c:3386 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88c13b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x5623b89bdebb in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x5623b89bdebb in af_label_vpn_export_magic bgpd/bgp_vty.c:9547 sonic-net#7 0x5623b89bdebb in af_label_vpn_export bgpd/bgp_vty_clippy.c:2868 sonic-net#8 0x7f62cca45511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f62cca459d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f62cca45e54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f62ccb6ee20 in vty_command lib/vty.c:591 sonic-net#12 0x7f62ccb6f2cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f62ccb77b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#15 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 240 byte(s) in 6 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88dc289 in evaluate_paths bgpd/bgp_nht.c:1384 sonic-net#5 0x5623b88ddb0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x5623b88de027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x5623b8a03163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 120 byte(s) in 3 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b893a406 in bgp_redistribute_add bgpd/bgp_route.c:8692 sonic-net#5 0x5623b8a02b3b in zebra_read_route bgpd/bgp_zebra.c:595 sonic-net#6 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#7 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#8 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#9 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#10 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 80 byte(s) in 2 object(s) allocated from: #0 0x7f62cd0c9d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f62ccac21c3 in qcalloc lib/memory.c:105 sonic-net#2 0x5623b8810dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88dc188 in evaluate_paths bgpd/bgp_nht.c:1348 sonic-net#5 0x5623b88ddb0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x5623b88de027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x5623b8a03163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88c13b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x5623b89beabc in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x5623b89beabc in af_label_vpn_export_allocation_mode_magic bgpd/bgp_vty.c:9464 sonic-net#7 0x5623b89beabc in af_label_vpn_export_allocation_mode bgpd/bgp_vty_clippy.c:2809 sonic-net#8 0x7f62cca45511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f62cca459d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f62cca45e54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f62ccb6ee20 in vty_command lib/vty.c:591 sonic-net#12 0x7f62ccb6f2cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f62ccb77b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#15 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b892e86d in bgp_update bgpd/bgp_route.c:4969 sonic-net#5 0x5623b893134d in bgp_nlri_parse_ip bgpd/bgp_route.c:6213 sonic-net#6 0x5623b88e2a0e in bgp_nlri_parse bgpd/bgp_packet.c:341 sonic-net#7 0x5623b88e4f7c in bgp_update_receive bgpd/bgp_packet.c:2220 sonic-net#8 0x5623b88f0474 in bgp_process_packet bgpd/bgp_packet.c:3386 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88c13b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x5623b89bdebb in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x5623b89bdebb in af_label_vpn_export_magic bgpd/bgp_vty.c:9547 sonic-net#7 0x5623b89bdebb in af_label_vpn_export bgpd/bgp_vty_clippy.c:2868 sonic-net#8 0x7f62cca45511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f62cca459d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f62cca45e54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f62ccb6ee20 in vty_command lib/vty.c:591 sonic-net#12 0x7f62ccb6f2cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f62ccb77b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#15 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 48 byte(s) in 6 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88dc289 in evaluate_paths bgpd/bgp_nht.c:1384 sonic-net#5 0x5623b88ddb0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x5623b88de027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x5623b8a03163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 24 byte(s) in 3 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b893a406 in bgp_redistribute_add bgpd/bgp_route.c:8692 sonic-net#5 0x5623b8a02b3b in zebra_read_route bgpd/bgp_zebra.c:595 sonic-net#6 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#7 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#8 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#9 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#10 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 16 byte(s) in 2 object(s) allocated from: #0 0x7f62cd0c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f62ccac1ee3 in qmalloc lib/memory.c:100 sonic-net#2 0x5623b8810eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x5623b88be8eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x5623b88dc188 in evaluate_paths bgpd/bgp_nht.c:1348 sonic-net#5 0x5623b88ddb0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x5623b88de027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x5623b8a03163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f62ccb92d8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f62ccb62b8f in event_call lib/event.c:1969 sonic-net#10 0x7f62ccaa5462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x5623b87e054b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f62cbae7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 1536 byte(s) leaked in 64 allocation(s). *********************************************************************************** Address Sanitizer Error detected in bgp_vpnv4_per_nexthop_label.test_bgp_vpnv4_per_nexthop_label/r1.asan.bgpd.10610 ================================================================= ==10610==ERROR: LeakSanitizer: detected memory leaks Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9c4686d in bgp_update bgpd/bgp_route.c:4969 sonic-net#5 0x55cdc9c4934d in bgp_nlri_parse_ip bgpd/bgp_route.c:6213 sonic-net#6 0x55cdc9bfaa0e in bgp_nlri_parse bgpd/bgp_packet.c:341 sonic-net#7 0x55cdc9bfcf7c in bgp_update_receive bgpd/bgp_packet.c:2220 sonic-net#8 0x55cdc9c08474 in bgp_process_packet bgpd/bgp_packet.c:3386 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9cd6abc in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9cd6abc in af_label_vpn_export_allocation_mode_magic bgpd/bgp_vty.c:9464 sonic-net#7 0x55cdc9cd6abc in af_label_vpn_export_allocation_mode bgpd/bgp_vty_clippy.c:2809 sonic-net#8 0x7f81fbede511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f81fbede9d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f81fbedee54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f81fc007e20 in vty_command lib/vty.c:591 sonic-net#12 0x7f81fc0082cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f81fc010b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#15 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 280 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9cd5ebb in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9cd5ebb in af_label_vpn_export_magic bgpd/bgp_vty.c:9547 sonic-net#7 0x55cdc9cd5ebb in af_label_vpn_export bgpd/bgp_vty_clippy.c:2868 sonic-net#8 0x7f81fbede511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f81fbede9d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f81fbedee54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f81fc007e20 in vty_command lib/vty.c:591 sonic-net#12 0x7f81fc0082cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f81fc010b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#15 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 240 byte(s) in 6 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bf4289 in evaluate_paths bgpd/bgp_nht.c:1384 sonic-net#5 0x55cdc9bf5b0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x55cdc9bf6027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x55cdc9d1b163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 80 byte(s) in 2 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bf4188 in evaluate_paths bgpd/bgp_nht.c:1348 sonic-net#5 0x55cdc9bf5b0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x55cdc9bf6027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x55cdc9d1b163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 80 byte(s) in 2 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9bdafd5 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9bdafd5 in vpn_leak_label_callback bgpd/bgp_mplsvpn.c:581 sonic-net#7 0x55cdc9bb2606 in lp_cbq_docallback bgpd/bgp_labelpool.c:118 sonic-net#8 0x7f81fc0164b5 in work_queue_run lib/workqueue.c:266 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x7f81fc562d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f81fbf5b1c3 in qcalloc lib/memory.c:105 sonic-net#2 0x55cdc9b28dc8 in ecommunity_dup bgpd/bgp_ecommunity.c:252 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9c52406 in bgp_redistribute_add bgpd/bgp_route.c:8692 sonic-net#5 0x55cdc9d1ab3b in zebra_read_route bgpd/bgp_zebra.c:595 sonic-net#6 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#7 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#8 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#9 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#10 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9cd6abc in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9cd6abc in af_label_vpn_export_allocation_mode_magic bgpd/bgp_vty.c:9464 sonic-net#7 0x55cdc9cd6abc in af_label_vpn_export_allocation_mode bgpd/bgp_vty_clippy.c:2809 sonic-net#8 0x7f81fbede511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f81fbede9d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f81fbedee54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f81fc007e20 in vty_command lib/vty.c:591 sonic-net#12 0x7f81fc0082cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f81fc010b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#15 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9cd5ebb in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9cd5ebb in af_label_vpn_export_magic bgpd/bgp_vty.c:9547 sonic-net#7 0x55cdc9cd5ebb in af_label_vpn_export bgpd/bgp_vty_clippy.c:2868 sonic-net#8 0x7f81fbede511 in cmd_execute_command_real lib/command.c:978 sonic-net#9 0x7f81fbede9d5 in cmd_execute_command lib/command.c:1036 sonic-net#10 0x7f81fbedee54 in cmd_execute lib/command.c:1203 sonic-net#11 0x7f81fc007e20 in vty_command lib/vty.c:591 sonic-net#12 0x7f81fc0082cb in vty_execute lib/vty.c:1354 sonic-net#13 0x7f81fc010b95 in vtysh_read lib/vty.c:2362 sonic-net#14 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#15 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#16 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#17 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 56 byte(s) in 7 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9c4686d in bgp_update bgpd/bgp_route.c:4969 sonic-net#5 0x55cdc9c4934d in bgp_nlri_parse_ip bgpd/bgp_route.c:6213 sonic-net#6 0x55cdc9bfaa0e in bgp_nlri_parse bgpd/bgp_packet.c:341 sonic-net#7 0x55cdc9bfcf7c in bgp_update_receive bgpd/bgp_packet.c:2220 sonic-net#8 0x55cdc9c08474 in bgp_process_packet bgpd/bgp_packet.c:3386 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 48 byte(s) in 6 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bf4289 in evaluate_paths bgpd/bgp_nht.c:1384 sonic-net#5 0x55cdc9bf5b0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x55cdc9bf6027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x55cdc9d1b163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 16 byte(s) in 2 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bf4188 in evaluate_paths bgpd/bgp_nht.c:1348 sonic-net#5 0x55cdc9bf5b0b in bgp_process_nexthop_update bgpd/bgp_nht.c:733 sonic-net#6 0x55cdc9bf6027 in bgp_parse_nexthop_update bgpd/bgp_nht.c:934 sonic-net#7 0x55cdc9d1b163 in bgp_read_nexthop_update bgpd/bgp_zebra.c:104 sonic-net#8 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 16 byte(s) in 2 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9bd93b3 in vpn_leak_from_vrf_update_all bgpd/bgp_mplsvpn.c:2005 sonic-net#5 0x55cdc9bdafd5 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:287 sonic-net#6 0x55cdc9bdafd5 in vpn_leak_label_callback bgpd/bgp_mplsvpn.c:581 sonic-net#7 0x55cdc9bb2606 in lp_cbq_docallback bgpd/bgp_labelpool.c:118 sonic-net#8 0x7f81fc0164b5 in work_queue_run lib/workqueue.c:266 sonic-net#9 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#10 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#11 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#12 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7f81fc562b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f81fbf5aee3 in qmalloc lib/memory.c:100 sonic-net#2 0x55cdc9b28eb8 in ecommunity_dup bgpd/bgp_ecommunity.c:256 sonic-net#3 0x55cdc9bd68eb in vpn_leak_from_vrf_update bgpd/bgp_mplsvpn.c:1628 sonic-net#4 0x55cdc9c52406 in bgp_redistribute_add bgpd/bgp_route.c:8692 sonic-net#5 0x55cdc9d1ab3b in zebra_read_route bgpd/bgp_zebra.c:595 sonic-net#6 0x7f81fc02bd8a in zclient_read lib/zclient.c:4425 sonic-net#7 0x7f81fbffbb8f in event_call lib/event.c:1969 sonic-net#8 0x7f81fbf3e462 in frr_run lib/libfrr.c:1213 sonic-net#9 0x55cdc9af854b in main bgpd/bgp_main.c:510 sonic-net#10 0x7f81faf80c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 1536 byte(s) leaked in 64 allocation(s). *********************************************************************************** Signed-off-by: ryndia <dindyalsarvesh@gmail.com> (cherry picked from commit 78b6cad)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Fix memory leaks by allocating `json_segs` conditionally on `nexthop->nh_srv6->seg6_segs`. The previous code allocated memory even when not in use or attached to the JSON tree. The ASan leak log for reference: ``` Direct leak of 3240 byte(s) in 45 object(s) allocated from: #0 0x7f6e84a35d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f6e83de9e6f in json_object_new_array (/lib/x86_64-linux-gnu/libjson-c.so.3+0x3e6f) sonic-net#2 0x564dcab5c1a6 in vty_show_ip_route zebra/zebra_vty.c:705 sonic-net#3 0x564dcab5cc71 in do_show_route_helper zebra/zebra_vty.c:955 sonic-net#4 0x564dcab5d418 in do_show_ip_route zebra/zebra_vty.c:1039 sonic-net#5 0x564dcab63ee5 in show_route_magic zebra/zebra_vty.c:1878 sonic-net#6 0x564dcab63ee5 in show_route zebra/zebra_vty_clippy.c:659 sonic-net#7 0x7f6e843b6fb1 in cmd_execute_command_real lib/command.c:978 sonic-net#8 0x7f6e843b7475 in cmd_execute_command lib/command.c:1036 sonic-net#9 0x7f6e843b78f4 in cmd_execute lib/command.c:1203 sonic-net#10 0x7f6e844dfe3b in vty_command lib/vty.c:594 sonic-net#11 0x7f6e844e02e6 in vty_execute lib/vty.c:1357 sonic-net#12 0x7f6e844e8bb7 in vtysh_read lib/vty.c:2365 sonic-net#13 0x7f6e844d3b7a in event_call lib/event.c:1965 sonic-net#14 0x7f6e844172b0 in frr_run lib/libfrr.c:1214 sonic-net#15 0x564dcaa50e81 in main zebra/main.c:488 sonic-net#16 0x7f6e837f7c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Indirect leak of 11520 byte(s) in 45 object(s) allocated from: #0 0x7f6e84a35d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f6e83de88c0 in array_list_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x28c0) Indirect leak of 1080 byte(s) in 45 object(s) allocated from: #0 0x7f6e84a35d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f6e83de8897 in array_list_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x2897) ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com> Signed-off-by: ryndia <dindyalsarvesh@gmail.com> (cherry picked from commit 531866c)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Fix a crash because a use-after-free. > ================================================================= > ==1249835==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000074210 at pc 0x7fa1b42a652c bp 0x7ffc477a2aa0 sp 0x7ffc477a2a98 > READ of size 8 at 0x604000074210 thread T0 > #0 0x7fa1b42a652b in list_delete_all_node git/frr/lib/linklist.c:299:20 > sonic-net#1 0x7fa1b42a683f in list_delete git/frr/lib/linklist.c:312:2 > sonic-net#2 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4 > sonic-net#3 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2 > sonic-net#4 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2 > sonic-net#5 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4 > sonic-net#6 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > sonic-net#7 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > sonic-net#8 0x556808 in main git/frr/zebra/main.c:488:2 > sonic-net#9 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > sonic-net#10 0x4453e9 in _start (/usr/lib/frr/zebra+0x4453e9) > > 0x604000074210 is located 0 bytes inside of 40-byte region [0x604000074210,0x604000074238) > freed by thread T0 here: > #0 0x4bf1dd in free (/usr/lib/frr/zebra+0x4bf1dd) > sonic-net#1 0x7fa1b42df0c0 in qfree git/frr/lib/memory.c:130:2 > sonic-net#2 0x7fa1b42a68ce in list_free_internal git/frr/lib/linklist.c:24:2 > sonic-net#3 0x7fa1b42a6870 in list_delete git/frr/lib/linklist.c:313:2 > sonic-net#4 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4 > sonic-net#5 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2 > sonic-net#6 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2 > sonic-net#7 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4 > sonic-net#8 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > sonic-net#9 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > sonic-net#10 0x556808 in main git/frr/zebra/main.c:488:2 > sonic-net#11 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > > previously allocated by thread T0 here: > #0 0x4bf5d2 in calloc (/usr/lib/frr/zebra+0x4bf5d2) > sonic-net#1 0x7fa1b42dee18 in qcalloc git/frr/lib/memory.c:105:27 > sonic-net#2 0x7fa1b42a3784 in list_new git/frr/lib/linklist.c:18:9 > sonic-net#3 0x6d165f in pbr_iptable_alloc_intern git/frr/zebra/zebra_pbr.c:1015:29 > sonic-net#4 0x7fa1b426ad1f in hash_get git/frr/lib/hash.c:147:13 > sonic-net#5 0x6d15f2 in zebra_pbr_add_iptable git/frr/zebra/zebra_pbr.c:1030:13 > sonic-net#6 0x5db2a3 in zread_iptable git/frr/zebra/zapi_msg.c:3759:3 > sonic-net#7 0x5e365d in zserv_handle_commands git/frr/zebra/zapi_msg.c:4039:3 > sonic-net#8 0x7e09fc in zserv_process_messages git/frr/zebra/zserv.c:520:3 > sonic-net#9 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2 > sonic-net#10 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3 > sonic-net#11 0x556808 in main git/frr/zebra/main.c:488:2 > sonic-net#12 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 Fixes: 1cc3806 ("zebra: Actually free all memory associated ctx->u.iptable.interface_name_list") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 45140bb)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Fix bgp_best_selection heap-use-after-free > ==2521540==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000032810 at pc 0x000000716f45 bp 0x7ffedc6229d0 sp 0x7ffedc6229c8 > READ of size 8 at 0x60d000032810 thread T0 > #0 0x716f44 in bgp_best_selection /home/lscalber/git/frr/bgpd/bgp_route.c:2834:5 > sonic-net#1 0x71a05e in bgp_process_main_one /home/lscalber/git/frr/bgpd/bgp_route.c:3344:2 > sonic-net#2 0x71c265 in bgp_process_wq /home/lscalber/git/frr/bgpd/bgp_route.c:3622:3 > sonic-net#3 0x7fe630a6669c in work_queue_run /home/lscalber/git/frr/lib/workqueue.c:282:10 > sonic-net#4 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2 > sonic-net#5 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3 > sonic-net#6 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2 > sonic-net#7 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > sonic-net#8 0x449629 in _start (/usr/lib/frr/bgpd+0x449629) > > 0x60d000032810 is located 48 bytes inside of 144-byte region [0x60d0000327e0,0x60d000032870) > freed by thread T0 here: > #0 0x4c341d in free (/usr/lib/frr/bgpd+0x4c341d) > sonic-net#1 0x7fe6308d7420 in qfree /home/lscalber/git/frr/lib/memory.c:130:2 > sonic-net#2 0x702632 in bgp_path_info_free_with_caller /home/lscalber/git/frr/bgpd/bgp_route.c:300:2 > sonic-net#3 0x702023 in bgp_path_info_unlock /home/lscalber/git/frr/bgpd/bgp_route.c:315:3 > sonic-net#4 0x703bc6 in bgp_path_info_reap /home/lscalber/git/frr/bgpd/bgp_route.c:461:2 > sonic-net#5 0x716e5d in bgp_best_selection /home/lscalber/git/frr/bgpd/bgp_route.c:2829:12 > sonic-net#6 0x71a05e in bgp_process_main_one /home/lscalber/git/frr/bgpd/bgp_route.c:3344:2 > sonic-net#7 0x71c265 in bgp_process_wq /home/lscalber/git/frr/bgpd/bgp_route.c:3622:3 > sonic-net#8 0x7fe630a6669c in work_queue_run /home/lscalber/git/frr/lib/workqueue.c:282:10 > sonic-net#9 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2 > sonic-net#10 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3 > sonic-net#11 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2 > sonic-net#12 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 > > previously allocated by thread T0 here: > #0 0x4c3812 in calloc (/usr/lib/frr/bgpd+0x4c3812) > sonic-net#1 0x7fe6308d7178 in qcalloc /home/lscalber/git/frr/lib/memory.c:105:27 > sonic-net#2 0x71f5b4 in info_make /home/lscalber/git/frr/bgpd/bgp_route.c:3985:8 > sonic-net#3 0x725293 in bgp_update /home/lscalber/git/frr/bgpd/bgp_route.c:4881:8 > sonic-net#4 0x73083d in bgp_nlri_parse_ip /home/lscalber/git/frr/bgpd/bgp_route.c:6230:4 > sonic-net#5 0x6ba980 in bgp_nlri_parse /home/lscalber/git/frr/bgpd/bgp_packet.c:341:10 > sonic-net#6 0x6cca2a in bgp_update_receive /home/lscalber/git/frr/bgpd/bgp_packet.c:2412:15 > sonic-net#7 0x6c6788 in bgp_process_packet /home/lscalber/git/frr/bgpd/bgp_packet.c:3887:11 > sonic-net#8 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2 > sonic-net#9 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3 > sonic-net#10 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2 > sonic-net#11 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16 Fixes: ddb5b48 ("bgpd: vpn-vrf route leaking") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 9561f96)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks. The list callback deletion functions have been set. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180 ================================================================= ==4180==ERROR: LeakSanitizer: detected memory leaks Direct leak of 544 byte(s) in 2 object(s) allocated from: #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f8d1709f238 in qcalloc lib/memory.c:105 sonic-net#2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591 sonic-net#3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712 sonic-net#4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758 sonic-net#5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849 sonic-net#6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299 sonic-net#7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704 sonic-net#8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164 sonic-net#9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459 sonic-net#10 0x7f8d1713f034 in event_call lib/event.c:1974 sonic-net#11 0x7f8d1708242b in frr_run lib/libfrr.c:1214 sonic-net#12 0x55d5db99d19d in main bgpd/bgp_main.c:510 sonic-net#13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) Direct leak of 296 byte(s) in 1 object(s) allocated from: #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x7f8d1709f238 in qcalloc lib/memory.c:105 sonic-net#2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135 sonic-net#3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144 sonic-net#4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459 sonic-net#5 0x7f8d1713f034 in event_call lib/event.c:1974 sonic-net#6 0x7f8d1708242b in frr_run lib/libfrr.c:1214 sonic-net#7 0x55d5db99d19d in main bgpd/bgp_main.c:510 sonic-net#8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com> (cherry picked from commit 8e7044b)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Fix the following heap-use-after-free > ==82961==ERROR: AddressSanitizer: heap-use-after-free on address 0x6020001e4750 at pc 0x55a8cc7f63ac bp 0x7ffd6948e340 sp 0x7ffd6948e330 > READ of size 8 at 0x6020001e4750 thread T0 > #0 0x55a8cc7f63ab in isis_route_node_cleanup isisd/isis_route.c:335 > sonic-net#1 0x7ff25ec617c1 in route_node_free lib/table.c:75 > sonic-net#2 0x7ff25ec619fc in route_table_free lib/table.c:111 > sonic-net#3 0x7ff25ec61661 in route_table_finish lib/table.c:46 > sonic-net#4 0x55a8cc800d83 in _isis_spftree_del isisd/isis_spf.c:397 > sonic-net#5 0x55a8cc800e45 in isis_spftree_clear isisd/isis_spf.c:414 > sonic-net#6 0x55a8cc80bd9a in isis_run_spf isisd/isis_spf.c:2020 > sonic-net#7 0x55a8cc80c370 in isis_run_spf_with_protection isisd/isis_spf.c:2076 > sonic-net#8 0x55a8cc80cf52 in isis_run_spf_cb isisd/isis_spf.c:2165 > sonic-net#9 0x7ff25ec7c4dc in event_call lib/event.c:1970 > sonic-net#10 0x7ff25eb64423 in frr_run lib/libfrr.c:1213 > sonic-net#11 0x55a8cc7799da in main isisd/isis_main.c:318 > sonic-net#12 0x7ff25e623d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#13 0x7ff25e623e3f in __libc_start_main_impl ../csu/libc-start.c:392 > sonic-net#14 0x55a8cc778e44 in _start (/usr/lib/frr/isisd+0x109e44) > > 0x6020001e4750 is located 0 bytes inside of 16-byte region [0x6020001e4750,0x6020001e4760) > freed by thread T0 here: > #0 0x7ff25f000537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127 > sonic-net#1 0x7ff25eb9012e in qfree lib/memory.c:130 > sonic-net#2 0x55a8cc7f6485 in isis_route_table_info_free isisd/isis_route.c:351 > sonic-net#3 0x55a8cc800cf4 in _isis_spftree_del isisd/isis_spf.c:395 > sonic-net#4 0x55a8cc800e45 in isis_spftree_clear isisd/isis_spf.c:414 > sonic-net#5 0x55a8cc80bd9a in isis_run_spf isisd/isis_spf.c:2020 > sonic-net#6 0x55a8cc80c370 in isis_run_spf_with_protection isisd/isis_spf.c:2076 > sonic-net#7 0x55a8cc80cf52 in isis_run_spf_cb isisd/isis_spf.c:2165 > sonic-net#8 0x7ff25ec7c4dc in event_call lib/event.c:1970 > sonic-net#9 0x7ff25eb64423 in frr_run lib/libfrr.c:1213 > sonic-net#10 0x55a8cc7799da in main isisd/isis_main.c:318 > sonic-net#11 0x7ff25e623d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > previously allocated by thread T0 here: > #0 0x7ff25f000a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7ff25eb8ffdc in qcalloc lib/memory.c:105 > sonic-net#2 0x55a8cc7f63eb in isis_route_table_info_alloc isisd/isis_route.c:343 > sonic-net#3 0x55a8cc80052a in _isis_spftree_init isisd/isis_spf.c:334 > sonic-net#4 0x55a8cc800e51 in isis_spftree_clear isisd/isis_spf.c:415 > sonic-net#5 0x55a8cc80bd9a in isis_run_spf isisd/isis_spf.c:2020 > sonic-net#6 0x55a8cc80c370 in isis_run_spf_with_protection isisd/isis_spf.c:2076 > sonic-net#7 0x55a8cc80cf52 in isis_run_spf_cb isisd/isis_spf.c:2165 > sonic-net#8 0x7ff25ec7c4dc in event_call lib/event.c:1970 > sonic-net#9 0x7ff25eb64423 in frr_run lib/libfrr.c:1213 > sonic-net#10 0x55a8cc7799da in main isisd/isis_main.c:318 > sonic-net#11 0x7ff25e623d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: 7153c3c ("isisd: update struct isis_route_info has multiple sr info by algorithm") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 9fa9a9d)
marcosfsch
pushed a commit
to marcosfsch/sonic-frr
that referenced
this pull request
Jan 30, 2024
Fix the following heap-buffer-overflow: > ==3901635==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020003a5940 at pc 0x56260067bb48 bp 0x7ffe8a4f3840 sp 0x7ffe8a4f3838 > READ of size 4 at 0x6020003a5940 thread T0 > #0 0x56260067bb47 in ecommunity_fill_pbr_action bgpd/bgp_ecommunity.c:1587 > sonic-net#1 0x5626007a246e in bgp_pbr_build_and_validate_entry bgpd/bgp_pbr.c:939 > sonic-net#2 0x5626007b25e6 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2933 > sonic-net#3 0x562600909d18 in bgp_zebra_announce bgpd/bgp_zebra.c:1351 > sonic-net#4 0x5626007d5efd in bgp_process_main_one bgpd/bgp_route.c:3528 > sonic-net#5 0x5626007d6b43 in bgp_process_wq bgpd/bgp_route.c:3641 > sonic-net#6 0x7f450f34c2cc in work_queue_run lib/workqueue.c:266 > sonic-net#7 0x7f450f327a27 in event_call lib/event.c:1970 > sonic-net#8 0x7f450f21a637 in frr_run lib/libfrr.c:1213 > sonic-net#9 0x56260062fc04 in main bgpd/bgp_main.c:540 > sonic-net#10 0x7f450ee2dd09 in __libc_start_main ../csu/libc-start.c:308 > sonic-net#11 0x56260062ca29 in _start (/usr/lib/frr/bgpd+0x2e3a29) > > 0x6020003a5940 is located 0 bytes to the right of 16-byte region [0x6020003a5930,0x6020003a5940) > allocated by thread T0 here: > #0 0x7f450f6aa1f8 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164 > sonic-net#1 0x7f450f244f8a in qrealloc lib/memory.c:112 > sonic-net#2 0x562600673313 in ecommunity_add_val_internal bgpd/bgp_ecommunity.c:143 > sonic-net#3 0x5626006735bc in ecommunity_uniq_sort_internal bgpd/bgp_ecommunity.c:193 > sonic-net#4 0x5626006737e3 in ecommunity_parse_internal bgpd/bgp_ecommunity.c:228 > sonic-net#5 0x562600673890 in ecommunity_parse bgpd/bgp_ecommunity.c:236 > sonic-net#6 0x562600640469 in bgp_attr_ext_communities bgpd/bgp_attr.c:2674 > sonic-net#7 0x562600646eb3 in bgp_attr_parse bgpd/bgp_attr.c:3893 > sonic-net#8 0x562600791b7e in bgp_update_receive bgpd/bgp_packet.c:2141 > sonic-net#9 0x56260079ba6b in bgp_process_packet bgpd/bgp_packet.c:3406 > sonic-net#10 0x7f450f327a27 in event_call lib/event.c:1970 > sonic-net#11 0x7f450f21a637 in frr_run lib/libfrr.c:1213 > sonic-net#12 0x56260062fc04 in main bgpd/bgp_main.c:540 > sonic-net#13 0x7f450ee2dd09 in __libc_start_main ../csu/libc-start.c:308 Fixes: dacf6ec ("bgpd: utility routine to convert flowspec actions into pbr actions") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> (cherry picked from commit 6001c76)
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
The following ASAN error can be seen. > ERROR: AddressSanitizer: attempting to call malloc_usable_size() for pointer which is not owned: 0x608000036c20 > #0 0x7f3d7a4b5425 in __interceptor_malloc_usable_size ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:198 > sonic-net#1 0x7f3d7a426a16 in __sanitizer::BufferedStackTrace::Unwind(unsigned long, unsigned long, void*, bool, unsigned int) ../../../../src/libsanitizer/sanitizer_common > /sanitizer_stacktrace.h:122 > sonic-net#2 0x7f3d7a426a16 in __asan::asan_malloc_usable_size(void const*, unsigned long, unsigned long) ../../../../src/libsanitizer/asan/asan_allocator.cpp:1074 > sonic-net#3 0x7f3d7a03f330 in mt_count_free lib/memory.c:78 > sonic-net#4 0x7f3d7a03f330 in qfree lib/memory.c:130 > sonic-net#5 0x7f3d76ccf89b in bmp_peer_status_changed bgpd/bgp_bmp.c:982 > sonic-net#6 0x560ae2aa6a94 in hook_call_peer_status_changed bgpd/bgp_fsm.c:47 > sonic-net#7 0x560ae2aa6a94 in bgp_fsm_change_status bgpd/bgp_fsm.c:1287 > sonic-net#8 0x560ae2c4f2e5 in peer_delete bgpd/bgpd.c:2777 > sonic-net#9 0x560ae2c58d24 in bgp_delete bgpd/bgpd.c:4140 > sonic-net#10 0x560ae2bbb47e in no_router_bgp bgpd/bgp_vty.c:1764 > sonic-net#11 0x7f3d79fb74ed in cmd_execute_command_real lib/command.c:1003 > sonic-net#12 0x7f3d79fb78a3 in cmd_execute_command lib/command.c:1062 > sonic-net#13 0x7f3d79fb7e03 in cmd_execute lib/command.c:1228 > sonic-net#14 0x7f3d7a107b53 in vty_command lib/vty.c:625 > sonic-net#15 0x7f3d7a109902 in vty_execute lib/vty.c:1388 > sonic-net#16 0x7f3d7a10cc32 in vtysh_read lib/vty.c:2400 > sonic-net#17 0x7f3d7a0f848b in event_call lib/event.c:2019 > sonic-net#18 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232 > sonic-net#19 0x560ae29e0037 in main bgpd/bgp_main.c:555 > sonic-net#20 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#21 0x7f3d79a29e3f in __libc_start_main_impl ../csu/libc-start.c:392 > sonic-net#22 0x560ae29e4ef4 in _start (/usr/lib/frr/bgpd+0x2eeef4) > > 0x608000036c20 is located 0 bytes inside of 81-byte region [0x608000036c20,0x608000036c71) > freed by thread T0 here: > #0 0x7f3d7a4b4537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127 > sonic-net#1 0x7f3d76ccf85f in bmp_peer_status_changed bgpd/bgp_bmp.c:981 > sonic-net#2 0x560ae2aa6a94 in hook_call_peer_status_changed bgpd/bgp_fsm.c:47 > sonic-net#3 0x560ae2aa6a94 in bgp_fsm_change_status bgpd/bgp_fsm.c:1287 > sonic-net#4 0x560ae2c4f2e5 in peer_delete bgpd/bgpd.c:2777 > sonic-net#5 0x560ae2c58d24 in bgp_delete bgpd/bgpd.c:4140 > sonic-net#6 0x560ae2bbb47e in no_router_bgp bgpd/bgp_vty.c:1764 > sonic-net#7 0x7f3d79fb74ed in cmd_execute_command_real lib/command.c:1003 > sonic-net#8 0x7f3d79fb78a3 in cmd_execute_command lib/command.c:1062 > sonic-net#9 0x7f3d79fb7e03 in cmd_execute lib/command.c:1228 > sonic-net#10 0x7f3d7a107b53 in vty_command lib/vty.c:625 > sonic-net#11 0x7f3d7a109902 in vty_execute lib/vty.c:1388 > sonic-net#12 0x7f3d7a10cc32 in vtysh_read lib/vty.c:2400 > sonic-net#13 0x7f3d7a0f848b in event_call lib/event.c:2019 > sonic-net#14 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232 > sonic-net#15 0x560ae29e0037 in main bgpd/bgp_main.c:555 > sonic-net#16 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > previously allocated by thread T0 here: > #0 0x7f3d7a4b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 > sonic-net#1 0x7f3d7a03f0e9 in qmalloc lib/memory.c:101 > sonic-net#2 0x7f3d76cd0166 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2194 > sonic-net#3 0x7f3d76cd0166 in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2236 > sonic-net#4 0x7f3d76cd29b8 in bmp_vrf_state_changed bgpd/bgp_bmp.c:3479 > sonic-net#5 0x560ae2c45b34 in hook_call_bgp_instance_state bgpd/bgpd.c:88 > sonic-net#6 0x560ae2c4d158 in bgp_instance_up bgpd/bgpd.c:3936 > sonic-net#7 0x560ae29e5ed1 in bgp_vrf_enable bgpd/bgp_main.c:299 > sonic-net#8 0x7f3d7a0ff8b1 in vrf_enable lib/vrf.c:286 > sonic-net#9 0x7f3d7a0ff8b1 in vrf_enable lib/vrf.c:275 > sonic-net#10 0x7f3d7a12ab66 in zclient_vrf_add lib/zclient.c:2561 > sonic-net#11 0x7f3d7a12eb43 in zclient_read lib/zclient.c:4624 > sonic-net#12 0x7f3d7a0f848b in event_call lib/event.c:2019 > sonic-net#13 0x7f3d7a01e627 in frr_run lib/libfrr.c:1232 > sonic-net#14 0x560ae29e0037 in main bgpd/bgp_main.c:555 > sonic-net#15 0x7f3d79a29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
The following memory leak can be observed when turning off and on the BGP vrf interface. > ==706056==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 78 byte(s) in 1 object(s) allocated from: > #0 0x7fbf5f6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 > sonic-net#1 0x7fbf5f0771f8 in qmalloc lib/memory.c:101 > sonic-net#2 0x7fbf5bdde610 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2042 > sonic-net#3 0x7fbf5bdde8aa in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2079 > sonic-net#4 0x7fbf5bdeaa1c in bmp_vrf_itf_state_changed bgpd/bgp_bmp.c:3204 > sonic-net#5 0x562740f0d83f in hook_call_bgp_vrf_status_changed bgpd/bgp_zebra.c:64 > sonic-net#6 0x562740f0ee28 in bgp_ifp_up bgpd/bgp_zebra.c:234 > sonic-net#7 0x7fbf5f01c193 in hook_call_if_up lib/if.c:57 > sonic-net#8 0x7fbf5f01d09a in if_up_via_zapi lib/if.c:203 > sonic-net#9 0x7fbf5f1d6f54 in zclient_interface_up lib/zclient.c:2671 > sonic-net#10 0x7fbf5f1e3e5a in zclient_read lib/zclient.c:4624 > sonic-net#11 0x7fbf5f18078d in event_call lib/event.c:1996 > sonic-net#12 0x7fbf5f048933 in frr_run lib/libfrr.c:1232 > sonic-net#13 0x562740c0cae1 in main bgpd/bgp_main.c:557 > sonic-net#14 0x7fbf5ea29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 78 byte(s) in 1 object(s) allocated from: > #0 0x7fbf5f6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 > sonic-net#1 0x7fbf5f0771f8 in qmalloc lib/memory.c:101 > sonic-net#2 0x7fbf5bdde610 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2042 > sonic-net#3 0x7fbf5bdde8aa in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2079 > sonic-net#4 0x7fbf5bdd4839 in bmp_send_peerup_vrf bgpd/bgp_bmp.c:627 > sonic-net#5 0x7fbf5bddb0d3 in bmp_wrfill bgpd/bgp_bmp.c:1590 > sonic-net#6 0x7fbf5f10841f in pullwr_run lib/pullwr.c:197 > sonic-net#7 0x7fbf5f18078d in event_call lib/event.c:1996 > sonic-net#8 0x7fbf5f048933 in frr_run lib/libfrr.c:1232 > sonic-net#9 0x562740c0cae1 in main bgpd/bgp_main.c:557 > sonic-net#10 0x7fbf5ea29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fix this by freeing the previous open_tx and open_rx contexts before setting up the new one. Also at deletion of peer, free the open_rx context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
The following memory leak is observed when running bgp_bmp test. > ==614841==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 81 byte(s) in 1 object(s) allocated from: > #0 0x7f0e9f2b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 > sonic-net#1 0x7f0e9ec771f8 in qmalloc lib/memory.c:101 > sonic-net#2 0x7f0e9e5a2f89 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2211 > sonic-net#3 0x7f0e9e5a31a8 in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2247 > sonic-net#4 0x7f0e9e5b0325 in bmp_bgp_attribute_updated_instance bgpd/bgp_bmp.c:3476 > sonic-net#5 0x7f0e9e5b0661 in bmp_bgp_attribute_updated bgpd/bgp_bmp.c:3526 > sonic-net#6 0x7f0e9e5b08ae in bmp_routerid_update bgpd/bgp_bmp.c:3547 > sonic-net#7 0x55cdc4bcbd88 in hook_call_bgp_routerid_update bgpd/bgpd.c:89 > sonic-net#8 0x55cdc4bccf0b in bgp_router_id_set bgpd/bgpd.c:305 > sonic-net#9 0x55cdc4bcd87d in bgp_router_id_zebra_bump bgpd/bgpd.c:393 > sonic-net#10 0x55cdc4ba87d5 in bgp_router_id_update bgpd/bgp_zebra.c:99 > sonic-net#11 0x7f0e9ede3f0b in zclient_read lib/zclient.c:4626 > sonic-net#12 0x7f0e9ed8074d in event_call lib/event.c:1996 > sonic-net#13 0x7f0e9ec48933 in frr_run lib/libfrr.c:1232 > sonic-net#14 0x55cdc48a9a27 in main bgpd/bgp_main.c:555 > sonic-net#15 0x7f0e9e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 81 byte(s) in 1 object(s) allocated from: > #0 0x7f0e9f2b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 > sonic-net#1 0x7f0e9ec771f8 in qmalloc lib/memory.c:101 > sonic-net#2 0x7f0e9e5a2ed8 in bmp_bgp_peer_vrf bgpd/bgp_bmp.c:2207 > sonic-net#3 0x7f0e9e5a31a8 in bmp_bgp_update_vrf_status bgpd/bgp_bmp.c:2247 > sonic-net#4 0x7f0e9e5b0325 in bmp_bgp_attribute_updated_instance bgpd/bgp_bmp.c:3476 > sonic-net#5 0x7f0e9e5b0661 in bmp_bgp_attribute_updated bgpd/bgp_bmp.c:3526 > sonic-net#6 0x7f0e9e5b08ae in bmp_routerid_update bgpd/bgp_bmp.c:3547 > sonic-net#7 0x55cdc4bcbd88 in hook_call_bgp_routerid_update bgpd/bgpd.c:89 > sonic-net#8 0x55cdc4bccf0b in bgp_router_id_set bgpd/bgpd.c:305 > sonic-net#9 0x55cdc4bcd87d in bgp_router_id_zebra_bump bgpd/bgpd.c:393 > sonic-net#10 0x55cdc4ba87d5 in bgp_router_id_update bgpd/bgp_zebra.c:99 > sonic-net#11 0x7f0e9ede3f0b in zclient_read lib/zclient.c:4626 > sonic-net#12 0x7f0e9ed8074d in event_call lib/event.c:1996 > sonic-net#13 0x7f0e9ec48933 in frr_run lib/libfrr.c:1232 > sonic-net#14 0x55cdc48a9a27 in main bgpd/bgp_main.c:555 > sonic-net#15 0x7f0e9e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 64 byte(s) in 1 object(s) allocated from: > #0 0x7f0e9f2b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7f0e9ec77235 in qcalloc lib/memory.c:106 > sonic-net#2 0x7f0e9e5a498d in bmp_imported_bgp_get bgpd/bgp_bmp.c:2441 > sonic-net#3 0x7f0e9e5acbed in bmp_import_vrf_magic bgpd/bgp_bmp.c:2855 > sonic-net#4 0x7f0e9e5a7f97 in bmp_import_vrf bgpd/bgp_bmp_clippy.c:147 > sonic-net#5 0x7f0e9ebb1178 in cmd_execute_command_real lib/command.c:1003 > sonic-net#6 0x7f0e9ebb1505 in cmd_execute_command lib/command.c:1062 > sonic-net#7 0x7f0e9ebb21d7 in cmd_execute lib/command.c:1228 > sonic-net#8 0x7f0e9ed90bf0 in vty_command lib/vty.c:626 > sonic-net#9 0x7f0e9ed95ad5 in vty_execute lib/vty.c:1389 > sonic-net#10 0x7f0e9ed9c01e in vtysh_read lib/vty.c:2408 > sonic-net#11 0x7f0e9ed8074d in event_call lib/event.c:1996 > sonic-net#12 0x7f0e9ec48933 in frr_run lib/libfrr.c:1232 > sonic-net#13 0x55cdc48a9a27 in main bgpd/bgp_main.c:555 > sonic-net#14 0x7f0e9e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 6 byte(s) in 1 object(s) allocated from: > #0 0x7f0e9f25b9a7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454 > sonic-net#1 0x7f0e9ec772fa in qstrdup lib/memory.c:118 > sonic-net#2 0x55cdc4b57d54 in af_rd_vpn_export_magic bgpd/bgp_vty.c:9814 > sonic-net#3 0x55cdc4b288d7 in af_rd_vpn_export bgpd/bgp_vty_clippy.c:3493 > sonic-net#4 0x7f0e9ebb1178 in cmd_execute_command_real lib/command.c:1003 > sonic-net#5 0x7f0e9ebb1505 in cmd_execute_command lib/command.c:1062 > sonic-net#6 0x7f0e9ebb21d7 in cmd_execute lib/command.c:1228 > sonic-net#7 0x7f0e9ed90bf0 in vty_command lib/vty.c:626 > sonic-net#8 0x7f0e9ed95ad5 in vty_execute lib/vty.c:1389 > sonic-net#9 0x7f0e9ed9c01e in vtysh_read lib/vty.c:2408 > sonic-net#10 0x7f0e9ed8074d in event_call lib/event.c:1996 > sonic-net#11 0x7f0e9ec48933 in frr_run lib/libfrr.c:1232 > sonic-net#12 0x55cdc48a9a27 in main bgpd/bgp_main.c:555 > sonic-net#13 0x7f0e9e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Indirect leak of 5 byte(s) in 1 object(s) allocated from: > #0 0x7f0e9f25b9a7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454 > sonic-net#1 0x7f0e9ec772fa in qstrdup lib/memory.c:118 > sonic-net#2 0x7f0e9e5a49ae in bmp_imported_bgp_get bgpd/bgp_bmp.c:2443 > sonic-net#3 0x7f0e9e5acbed in bmp_import_vrf_magic bgpd/bgp_bmp.c:2855 > sonic-net#4 0x7f0e9e5a7f97 in bmp_import_vrf bgpd/bgp_bmp_clippy.c:147 > sonic-net#5 0x7f0e9ebb1178 in cmd_execute_command_real lib/command.c:1003 > sonic-net#6 0x7f0e9ebb1505 in cmd_execute_command lib/command.c:1062 > sonic-net#7 0x7f0e9ebb21d7 in cmd_execute lib/command.c:1228 > sonic-net#8 0x7f0e9ed90bf0 in vty_command lib/vty.c:626 > sonic-net#9 0x7f0e9ed95ad5 in vty_execute lib/vty.c:1389 > sonic-net#10 0x7f0e9ed9c01e in vtysh_read lib/vty.c:2408 > sonic-net#11 0x7f0e9ed8074d in event_call lib/event.c:1996 > sonic-net#12 0x7f0e9ec48933 in frr_run lib/libfrr.c:1232 > sonic-net#13 0x55cdc48a9a27 in main bgpd/bgp_main.c:555 > sonic-net#14 0x7f0e9e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > SUMMARY: AddressSanitizer: 237 byte(s) leaked in 5 allocation(s). Fix this by freeing the missing memory block that helps building the open message to send to remote bmp collector. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
> ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f73891cb146 bp 0x7ffca86584c0 sp 0x7ffca8658490 T0) > ==837617==The signal is caused by a READ memory access. > ==837617==Hint: address points to the zero page. > #0 0x7f73891cb146 in bmp_targets_const_next bgpd/bgp_bmp.c:149 > sonic-net#1 0x7f73891cb1a5 in bmp_targets_next bgpd/bgp_bmp.c:149 > sonic-net#2 0x7f73891e875a in _bmp_vrf_state_changed_internal bgpd/bgp_bmp.c:3520 > sonic-net#3 0x7f73891e8922 in bmp_vrf_itf_state_changed bgpd/bgp_bmp.c:3566 > sonic-net#4 0x55e511af8d1b in hook_call_bgp_vrf_status_changed bgpd/bgp_zebra.c:64 > sonic-net#5 0x55e511afa304 in bgp_ifp_up bgpd/bgp_zebra.c:234 > sonic-net#6 0x7f738981c193 in hook_call_if_up lib/if.c:57 > sonic-net#7 0x7f738981d09a in if_up_via_zapi lib/if.c:203 > sonic-net#8 0x7f73899d6f54 in zclient_interface_up lib/zclient.c:2671 > sonic-net#9 0x7f73899e3e5a in zclient_read lib/zclient.c:4624 > sonic-net#10 0x7f738998078d in event_call lib/event.c:1996 > sonic-net#11 0x7f7389848933 in frr_run lib/libfrr.c:1232 > sonic-net#12 0x55e5117f7ae1 in main bgpd/bgp_main.c:557 > sonic-net#13 0x7f7389229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#14 0x7f7389229e3f in __libc_start_main_impl ../csu/libc-start.c:392 > sonic-net#15 0x55e5117f4234 in _start (/usr/lib/frr/bgpd+0x2ec234) Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
Some bgp evpn memory contexts are not freed at the end of the bgp process. > ================================================================= > ==1208677==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 96 byte(s) in 2 object(s) allocated from: > #0 0x7f93ad4b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7f93ace77233 in qcalloc lib/memory.c:106 > sonic-net#2 0x563bb68f4df1 in process_type5_route bgpd/bgp_evpn.c:5084 > sonic-net#3 0x563bb68fb663 in bgp_nlri_parse_evpn bgpd/bgp_evpn.c:6302 > sonic-net#4 0x563bb69ea2a9 in bgp_nlri_parse bgpd/bgp_packet.c:347 > sonic-net#5 0x563bb69f7716 in bgp_update_receive bgpd/bgp_packet.c:2482 > sonic-net#6 0x563bb6a04d3b in bgp_process_packet bgpd/bgp_packet.c:4091 > sonic-net#7 0x7f93acf8082d in event_call lib/event.c:1996 > sonic-net#8 0x7f93ace48931 in frr_run lib/libfrr.c:1232 > sonic-net#9 0x563bb6880ae1 in main bgpd/bgp_main.c:557 > sonic-net#10 0x7f93ac829d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Actually, the bgp evpn context may noy be used if adj rib in is unused. This may lead to memory leaks. Fix this by freeing the context in those corner cases. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
When running the bgp_evpn_rt5 setup with unified config, memory leak about a non deleted BGP instance happens. > root@ubuntu2204hwe:~/frr/tests/topotests/bgp_evpn_rt5# cat /tmp/topotests/bgp_evpn_rt5.test_bgp_evpn/r1.asan.bgpd.1164105 > > ================================================================= > ==1164105==ERROR: LeakSanitizer: detected memory leaks > > Indirect leak of 12496 byte(s) in 1 object(s) allocated from: > #0 0x7f358eeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7f358e877233 in qcalloc lib/memory.c:106 > sonic-net#2 0x55d06c95680a in bgp_create bgpd/bgpd.c:3405 > sonic-net#3 0x55d06c95a7b3 in bgp_get bgpd/bgpd.c:3805 > sonic-net#4 0x55d06c87a9b5 in bgp_get_vty bgpd/bgp_vty.c:603 > sonic-net#5 0x55d06c68dc71 in bgp_evpn_local_l3vni_add bgpd/bgp_evpn.c:7032 > sonic-net#6 0x55d06c92989b in bgp_zebra_process_local_l3vni bgpd/bgp_zebra.c:3204 > sonic-net#7 0x7f358e9e3feb in zclient_read lib/zclient.c:4626 > sonic-net#8 0x7f358e98082d in event_call lib/event.c:1996 > sonic-net#9 0x7f358e848931 in frr_run lib/libfrr.c:1232 > sonic-net#10 0x55d06c60eae1 in main bgpd/bgp_main.c:557 > sonic-net#11 0x7f358e229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Actually, a BGP VRF Instance is created in auto mode when creating the global BGP instance for the L3 VNI. And again, an other BGP VRF instance is created. Fix this by ensuring that a non existing BGP instance is not present. If it is present, and with auto mode or in hidden mode, then override the AS value. Fixes: f153b9a ("bgpd: Ignore auto created VRF BGP instances") Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Mar 11, 2025
When staticd receives a `ZAPI_SRV6_SID_RELEASED` notification from SRv6 SID Manager, it tries to unset the validity flag of `sid`. But since the `sid` variable is NULL, we get a NULL pointer dereference. ``` ================================================================= ==13815==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000060 (pc 0xc14b813d9eac bp 0xffffcb135a40 sp 0xffffcb135a40 T0) ==13815==The signal is caused by a READ memory access. ==13815==Hint: address points to the zero page. #0 0xc14b813d9eac in static_zebra_srv6_sid_notify staticd/static_zebra.c:1172 sonic-net#1 0xe44e7aa2c194 in zclient_read lib/zclient.c:4746 sonic-net#2 0xe44e7a9b69d8 in event_call lib/event.c:1984 sonic-net#3 0xe44e7a85ac28 in frr_run lib/libfrr.c:1246 sonic-net#4 0xc14b813ccf98 in main staticd/static_main.c:193 sonic-net#5 0xe44e7a4773f8 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 sonic-net#6 0xe44e7a4774c8 in __libc_start_main_impl ../csu/libc-start.c:392 sonic-net#7 0xc14b813cc92c in _start (/usr/lib/frr/staticd+0x1c92c) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV staticd/static_zebra.c:1172 in static_zebra_srv6_sid_notify ==13815==ABORTING ``` This commit fixes the problem by doing a SID lookup first. If the SID can't be found, we log an error and return. If the SID is found, we go ahead and unset the validity flag. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Fix a heap-after-free that causes zebra to crash even without address-sanitizer. To reproduce: > echo "100 my_table" | tee -a /etc/iproute2/rt_tables > ip route add blackhole default table 100 > ip route show table 100 > ip l add red type vrf table 100 > ip l del red > ip route del blackhole default table 100 Zebra manages routing tables for all existing Linux RT tables, regardless of whether they are assigned to a VRF interface. When a table is not assigned to any VRF, zebra arbitrarily assigns it to the default VRF, even though this is not strictly accurate (the code expects this behavior). When an RT table is created after a VRF, zebra correctly assigns the table to the VRF. However, if a VRF interface is assigned to an existing RT table, zebra does not update the table owner, which remains as the default VRF. As a result, existing routing entries remain under the default VRF, while new entries are correctly assigned to the VRF. The VRF mismatch is unexpected in the code and creates crashes and memory related issues. Furthermore, Linux does not automatically delete RT tables when they are unassigned from a VRF. It is incorrect to delete these tables from zebra. Instead, at VRF disabling, do not release the table but reassign it to the default VRF. At VRF enabling, change the table owner back to the appropriate VRF. > ==2866266==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000154f54 at pc 0x7fa32474b83f bp 0x7ffe94f67d90 sp 0x7ffe94f67d88 > READ of size 1 at 0x606000154f54 thread T0 > #0 0x7fa32474b83e in rn_hash_node_const_find lib/table.c:28 > sonic-net#1 0x7fa32474bab1 in rn_hash_node_find lib/table.c:28 > sonic-net#2 0x7fa32474d783 in route_node_get lib/table.c:283 > sonic-net#3 0x7fa3247328dd in srcdest_rnode_get lib/srcdest_table.c:231 > sonic-net#4 0x55b0e4fa8da4 in rib_find_rn_from_ctx zebra/zebra_rib.c:1957 > sonic-net#5 0x55b0e4fa8e31 in rib_process_result zebra/zebra_rib.c:1988 > sonic-net#6 0x55b0e4fb9d64 in rib_process_dplane_results zebra/zebra_rib.c:4894 > sonic-net#7 0x7fa32476689c in event_call lib/event.c:1996 > sonic-net#8 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232 > sonic-net#9 0x55b0e4e6c32a in main zebra/main.c:526 > sonic-net#10 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308 > sonic-net#11 0x55b0e4e2d649 in _start (/usr/lib/frr/zebra+0x1a1649) > > 0x606000154f54 is located 20 bytes inside of 56-byte region [0x606000154f40,0x606000154f78) > freed by thread T0 here: > #0 0x7fa324ca9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123 > sonic-net#1 0x7fa324668d8f in qfree lib/memory.c:130 > sonic-net#2 0x7fa32474c421 in route_table_free lib/table.c:126 > sonic-net#3 0x7fa32474bf96 in route_table_finish lib/table.c:46 > sonic-net#4 0x55b0e4fbca3a in zebra_router_free_table zebra/zebra_router.c:191 > sonic-net#5 0x55b0e4fbccea in zebra_router_release_table zebra/zebra_router.c:214 > sonic-net#6 0x55b0e4fd428e in zebra_vrf_disable zebra/zebra_vrf.c:219 > sonic-net#7 0x7fa32476fabf in vrf_disable lib/vrf.c:326 > sonic-net#8 0x7fa32476f5d4 in vrf_delete lib/vrf.c:231 > sonic-net#9 0x55b0e4e4ad36 in interface_vrf_change zebra/interface.c:1478 > sonic-net#10 0x55b0e4e4d5d2 in zebra_if_dplane_ifp_handling zebra/interface.c:1949 > sonic-net#11 0x55b0e4e4fb89 in zebra_if_dplane_result zebra/interface.c:2268 > sonic-net#12 0x55b0e4fb9f26 in rib_process_dplane_results zebra/zebra_rib.c:4954 > sonic-net#13 0x7fa32476689c in event_call lib/event.c:1996 > sonic-net#14 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232 > sonic-net#15 0x55b0e4e6c32a in main zebra/main.c:526 > sonic-net#16 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308 > > previously allocated by thread T0 here: > #0 0x7fa324caa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fa324668c4d in qcalloc lib/memory.c:105 > sonic-net#2 0x7fa32474bf33 in route_table_init_with_delegate lib/table.c:38 > sonic-net#3 0x7fa32474e73c in route_table_init lib/table.c:512 > sonic-net#4 0x55b0e4fbc353 in zebra_router_get_table zebra/zebra_router.c:137 > sonic-net#5 0x55b0e4fd4da0 in zebra_vrf_table_create zebra/zebra_vrf.c:358 > sonic-net#6 0x55b0e4fd3d30 in zebra_vrf_enable zebra/zebra_vrf.c:140 > sonic-net#7 0x7fa32476f9b2 in vrf_enable lib/vrf.c:286 > sonic-net#8 0x55b0e4e4af76 in interface_vrf_change zebra/interface.c:1533 > sonic-net#9 0x55b0e4e4d612 in zebra_if_dplane_ifp_handling zebra/interface.c:1968 > sonic-net#10 0x55b0e4e4fb89 in zebra_if_dplane_result zebra/interface.c:2268 > sonic-net#11 0x55b0e4fb9f26 in rib_process_dplane_results zebra/zebra_rib.c:4954 > sonic-net#12 0x7fa32476689c in event_call lib/event.c:1996 > sonic-net#13 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232 > sonic-net#14 0x55b0e4e6c32a in main zebra/main.c:526 > sonic-net#15 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308 Fixes: d8612e6 ("zebra: Track tables allocated by vrf and cleanup") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Issue: Not freeing the neighbor n within the same function can lead to memory leak. zebra_neigh_del_all() -> zebra_neigh_del() re lookup and free Fix: not accessing n after its freed. Directly free the neighbor entry (n) when its interface index matches ifp->ifindex. This fixes: ERROR: AddressSanitizer: heap-use-after-free on address 0x6070001052e8 at pc 0x7f6bf7d09ddb bp 0x7ffd3366a000 sp 0x7ffd33669ff0 READ of size 8 at 0x6070001052e8 thread T0 #0 0x7f6bf7d09dda in _rb_next lib/openbsd-tree.c:455 sonic-net#1 0x55f95a307261 in zebra_neigh_rb_head_RB_NEXT zebra/zebra_neigh.h:34 sonic-net#2 0x55f95a3082e9 in zebra_neigh_del_all zebra/zebra_neigh.c:162 sonic-net#3 0x55f95a121ee7 in zebra_interface_down_update zebra/redistribute.c:571 sonic-net#4 0x55f95a0f819d in if_down zebra/interface.c:1017 sonic-net#5 0x55f95a0fe168 in zebra_if_dplane_ifp_handling zebra/interface.c:2102 sonic-net#6 0x55f95a0ff10c in zebra_if_dplane_result zebra/interface.c:2241 sonic-net#7 0x55f95a27ce9c in rib_process_dplane_results zebra/zebra_rib.c:5015 sonic-net#8 0x7f6bf7da3ad9 in event_call lib/event.c:1984 sonic-net#9 0x7f6bf7c62141 in frr_run lib/libfrr.c:1246 sonic-net#10 0x55f95a11ca7f in main zebra/main.c:543 sonic-net#11 0x7f6bf7029d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 sonic-net#12 0x7f6bf7029e3f in __libc_start_main_impl ../csu/libc-start.c:392 sonic-net#13 0x55f95a0dd0b4 in _start (/usr/lib/frr/zebra+0x1a80b4) Ticket: #18047 Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
> ==713776==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 120 byte(s) in 1 object(s) allocated from: > #0 0x7fdfcbeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fdfcb86f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x55ce707739b6 in isis_tlvs_find_alloc_asla isisd/isis_tlvs.c:8500 > sonic-net#3 0x55ce7072fae0 in isis_link_params_update_asla isisd/isis_te.c:191 > sonic-net#4 0x55ce70733881 in isis_link_params_update isisd/isis_te.c:499 > sonic-net#5 0x55ce70693f2a in isis_circuit_up isisd/isis_circuit.c:776 > sonic-net#6 0x55ce7069a120 in isis_csm_state_change isisd/isis_csm.c:135 > sonic-net#7 0x55ce7068dd80 in isis_circuit_enable isisd/isis_circuit.c:79 > sonic-net#8 0x55ce70699346 in isis_ifp_create isisd/isis_circuit.c:1618 > sonic-net#9 0x7fdfcb81f47f in hook_call_if_real lib/if.c:55 > sonic-net#10 0x7fdfcb82056e in if_new_via_zapi lib/if.c:188 > sonic-net#11 0x7fdfcb9d17da in zclient_interface_add lib/zclient.c:2706 > sonic-net#12 0x7fdfcb9df842 in zclient_read lib/zclient.c:4843 > sonic-net#13 0x7fdfcb97798e in event_call lib/event.c:2011 > sonic-net#14 0x7fdfcb842ff1 in frr_run lib/libfrr.c:1216 > sonic-net#15 0x55ce7067cbf2 in main isisd/isis_main.c:360 > sonic-net#16 0x7fdfcb229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Indirect leak of 8 byte(s) in 1 object(s) allocated from: > #0 0x7fdfcbeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fdfcb86f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x7fdfcb79a7b7 in admin_group_init lib/admin_group.c:186 > sonic-net#3 0x55ce707739ca in isis_tlvs_find_alloc_asla isisd/isis_tlvs.c:8501 > sonic-net#4 0x55ce7072fae0 in isis_link_params_update_asla isisd/isis_te.c:191 > sonic-net#5 0x55ce70733881 in isis_link_params_update isisd/isis_te.c:499 > sonic-net#6 0x55ce70693f2a in isis_circuit_up isisd/isis_circuit.c:776 > sonic-net#7 0x55ce7069a120 in isis_csm_state_change isisd/isis_csm.c:135 > sonic-net#8 0x55ce7068dd80 in isis_circuit_enable isisd/isis_circuit.c:79 > sonic-net#9 0x55ce70699346 in isis_ifp_create isisd/isis_circuit.c:1618 > sonic-net#10 0x7fdfcb81f47f in hook_call_if_real lib/if.c:55 > sonic-net#11 0x7fdfcb82056e in if_new_via_zapi lib/if.c:188 > sonic-net#12 0x7fdfcb9d17da in zclient_interface_add lib/zclient.c:2706 > sonic-net#13 0x7fdfcb9df842 in zclient_read lib/zclient.c:4843 > sonic-net#14 0x7fdfcb97798e in event_call lib/event.c:2011 > sonic-net#15 0x7fdfcb842ff1 in frr_run lib/libfrr.c:1216 > sonic-net#16 0x55ce7067cbf2 in main isisd/isis_main.c:360 > sonic-net#17 0x7fdfcb229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 PR: 95719 Fixes: 5749ac8 ("isisd: add ASLA support") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
We are obviously doing deleting on wrong object. > Direct leak of 40 byte(s) in 1 object(s) allocated from: > #0 0x7fcf718b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fcf7126f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x7fcf7124401a in list_new lib/linklist.c:49 > sonic-net#3 0x55771621d86d in pbr_iptable_alloc_intern zebra/zebra_pbr.c:1015 > sonic-net#4 0x7fcf71217d79 in hash_get lib/hash.c:147 > sonic-net#5 0x55771621dad3 in zebra_pbr_add_iptable zebra/zebra_pbr.c:1030 > sonic-net#6 0x55771614d00c in zread_iptable zebra/zapi_msg.c:4131 > sonic-net#7 0x55771614e586 in zserv_handle_commands zebra/zapi_msg.c:4424 > sonic-net#8 0x5577162dae2c in zserv_process_messages zebra/zserv.c:521 > sonic-net#9 0x7fcf7137798e in event_call lib/event.c:2011 > sonic-net#10 0x7fcf71242ff1 in frr_run lib/libfrr.c:1216 > sonic-net#11 0x5577160e4d6d in main zebra/main.c:540 > sonic-net#12 0x7fcf70c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Indirect leak of 24 byte(s) in 1 object(s) allocated from: > #0 0x7fcf718b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fcf7126f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x7fcf71244129 in listnode_new lib/linklist.c:71 > sonic-net#3 0x7fcf71244238 in listnode_add lib/linklist.c:92 > sonic-net#4 0x55771621d938 in pbr_iptable_alloc_intern zebra/zebra_pbr.c:1019 > sonic-net#5 0x7fcf71217d79 in hash_get lib/hash.c:147 > sonic-net#6 0x55771621dad3 in zebra_pbr_add_iptable zebra/zebra_pbr.c:1030 > sonic-net#7 0x55771614d00c in zread_iptable zebra/zapi_msg.c:4131 > sonic-net#8 0x55771614e586 in zserv_handle_commands zebra/zapi_msg.c:4424 > sonic-net#9 0x5577162dae2c in zserv_process_messages zebra/zserv.c:521 > sonic-net#10 0x7fcf7137798e in event_call lib/event.c:2011 > sonic-net#11 0x7fcf71242ff1 in frr_run lib/libfrr.c:1216 > sonic-net#12 0x5577160e4d6d in main zebra/main.c:540 > sonic-net#13 0x7fcf70c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: f80ec7e ("zebra: handle iptable list of interfaces") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
> ==238132==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 160 byte(s) in 1 object(s) allocated from: > #0 0x7fd79f0b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fd79ea6f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x5586b26995f9 in bgp_pbr_match_entry_alloc_intern bgpd/bgp_pbr.c:1155 > sonic-net#3 0x7fd79ea17d79 in hash_get lib/hash.c:147 > sonic-net#4 0x5586b26a551d in bgp_pbr_policyroute_add_to_zebra_unit bgpd/bgp_pbr.c:2522 > sonic-net#5 0x5586b26a6436 in bgp_pbr_policyroute_add_to_zebra bgpd/bgp_pbr.c:2672 > sonic-net#6 0x5586b26a8089 in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2876 > sonic-net#7 0x5586b26a8912 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2939 > sonic-net#8 0x5586b2829472 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#9 0x5586b282ab4b in bgp_zebra_announce_table bgpd/bgp_zebra.c:1766 > sonic-net#10 0x5586b2824b99 in bgp_zebra_tm_connect bgpd/bgp_zebra.c:1091 > sonic-net#11 0x7fd79eb7798e in event_call lib/event.c:2011 > sonic-net#12 0x7fd79ea42ff1 in frr_run lib/libfrr.c:1216 > sonic-net#13 0x5586b2503a15 in main bgpd/bgp_main.c:545 > sonic-net#14 0x7fd79e429d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: d114b0d ("bgpd: inject policy route entry from bgp into zebra pbr entries.") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
> Direct leak of 1144 byte(s) in 13 object(s) allocated from: > #0 0x7f3eedeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7f3eed86f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x55b32d236faf in bgp_pbr_match_alloc_intern bgpd/bgp_pbr.c:1074 > sonic-net#3 0x7f3eed817d79 in hash_get lib/hash.c:147 > sonic-net#4 0x55b32d242d9a in bgp_pbr_policyroute_add_to_zebra_unit bgpd/bgp_pbr.c:2486 > sonic-net#5 0x55b32d244436 in bgp_pbr_policyroute_add_to_zebra bgpd/bgp_pbr.c:2672 > sonic-net#6 0x55b32d245a05 in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2843 > sonic-net#7 0x55b32d246912 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2939 > sonic-net#8 0x55b32d3c7472 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#9 0x55b32d26e5e7 in bgp_process_main_one bgpd/bgp_route.c:3691 > sonic-net#10 0x55b32d26f77d in process_subq_other_route bgpd/bgp_route.c:3856 > sonic-net#11 0x55b32d2701ff in process_subq bgpd/bgp_route.c:3955 > sonic-net#12 0x55b32d27029f in meta_queue_process bgpd/bgp_route.c:3980 > sonic-net#13 0x7f3eed99fdd8 in work_queue_run lib/workqueue.c:282 > sonic-net#14 0x7f3eed97798e in event_call lib/event.c:2011 > sonic-net#15 0x7f3eed842ff1 in frr_run lib/libfrr.c:1216 > sonic-net#16 0x55b32d0a1a15 in main bgpd/bgp_main.c:545 > sonic-net#17 0x7f3eed229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: d114b0d ("bgpd: inject policy route entry from bgp into zebra pbr entries.") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Note that bgp_pbr_policyroute_add_from_zebra() and bgp_pbr_policyroute_remove_from_zebra() are only called from bgp_pbr_handle_entry(). > ==966967==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 40 byte(s) in 1 object(s) allocated from: > #0 0x7fd447ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fd44746f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x7fd44744401a in list_new lib/linklist.c:49 > sonic-net#3 0x560f8c094490 in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2818 > sonic-net#4 0x560f8c095993 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2941 > sonic-net#5 0x560f8c2164f3 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#6 0x560f8c0bd668 in bgp_process_main_one bgpd/bgp_route.c:3691 > sonic-net#7 0x560f8c0be7fe in process_subq_other_route bgpd/bgp_route.c:3856 > sonic-net#8 0x560f8c0bf280 in process_subq bgpd/bgp_route.c:3955 > sonic-net#9 0x560f8c0bf320 in meta_queue_process bgpd/bgp_route.c:3980 > sonic-net#10 0x7fd44759fdfc in work_queue_run lib/workqueue.c:282 > sonic-net#11 0x7fd4475779b2 in event_call lib/event.c:2011 > sonic-net#12 0x7fd447442ff1 in frr_run lib/libfrr.c:1216 > sonic-net#13 0x560f8bef0a15 in main bgpd/bgp_main.c:545 > sonic-net#14 0x7fd446e29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 40 byte(s) in 1 object(s) allocated from: > #0 0x7fd447ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fd44746f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x7fd44744401a in list_new lib/linklist.c:49 > sonic-net#3 0x560f8c09439d in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2812 > sonic-net#4 0x560f8c095993 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2941 > sonic-net#5 0x560f8c2164f3 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#6 0x560f8c0bd668 in bgp_process_main_one bgpd/bgp_route.c:3691 > sonic-net#7 0x560f8c0be7fe in process_subq_other_route bgpd/bgp_route.c:3856 > sonic-net#8 0x560f8c0bf280 in process_subq bgpd/bgp_route.c:3955 > sonic-net#9 0x560f8c0bf320 in meta_queue_process bgpd/bgp_route.c:3980 > sonic-net#10 0x7fd44759fdfc in work_queue_run lib/workqueue.c:282 > sonic-net#11 0x7fd4475779b2 in event_call lib/event.c:2011 > sonic-net#12 0x7fd447442ff1 in frr_run lib/libfrr.c:1216 > sonic-net#13 0x560f8bef0a15 in main bgpd/bgp_main.c:545 > sonic-net#14 0x7fd446e29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 4 byte(s) in 1 object(s) allocated from: > #0 0x7fd447ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fd44746f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x560f8c080cec in bgp_pbr_extract_enumerate_unary bgpd/bgp_pbr.c:362 > sonic-net#3 0x560f8c080f7e in bgp_pbr_extract_enumerate bgpd/bgp_pbr.c:400 > sonic-net#4 0x560f8c094530 in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2819 > sonic-net#5 0x560f8c095993 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2941 > sonic-net#6 0x560f8c2164f3 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#7 0x560f8c0bd668 in bgp_process_main_one bgpd/bgp_route.c:3691 > sonic-net#8 0x560f8c0be7fe in process_subq_other_route bgpd/bgp_route.c:3856 > sonic-net#9 0x560f8c0bf280 in process_subq bgpd/bgp_route.c:3955 > sonic-net#10 0x560f8c0bf320 in meta_queue_process bgpd/bgp_route.c:3980 > sonic-net#11 0x7fd44759fdfc in work_queue_run lib/workqueue.c:282 > sonic-net#12 0x7fd4475779b2 in event_call lib/event.c:2011 > sonic-net#13 0x7fd447442ff1 in frr_run lib/libfrr.c:1216 > sonic-net#14 0x560f8bef0a15 in main bgpd/bgp_main.c:545 > sonic-net#15 0x7fd446e29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > Direct leak of 4 byte(s) in 1 object(s) allocated from: > #0 0x7fd447ab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fd44746f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x560f8c080cec in bgp_pbr_extract_enumerate_unary bgpd/bgp_pbr.c:362 > sonic-net#3 0x560f8c080f7e in bgp_pbr_extract_enumerate bgpd/bgp_pbr.c:400 > sonic-net#4 0x560f8c09443d in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2813 > sonic-net#5 0x560f8c095993 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2941 > sonic-net#6 0x560f8c2164f3 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > sonic-net#7 0x560f8c0bd668 in bgp_process_main_one bgpd/bgp_route.c:3691 > sonic-net#8 0x560f8c0be7fe in process_subq_other_route bgpd/bgp_route.c:3856 > sonic-net#9 0x560f8c0bf280 in process_subq bgpd/bgp_route.c:3955 > sonic-net#10 0x560f8c0bf320 in meta_queue_process bgpd/bgp_route.c:3980 > sonic-net#11 0x7fd44759fdfc in work_queue_run lib/workqueue.c:282 > sonic-net#12 0x7fd4475779b2 in event_call lib/event.c:2011 > sonic-net#13 0x7fd447442ff1 in frr_run lib/libfrr.c:1216 > sonic-net#14 0x560f8bef0a15 in main bgpd/bgp_main.c:545 > sonic-net#15 0x7fd446e29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Seen with isis_srv6_topo1 topotest. > ==178793==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 56 byte(s) in 1 object(s) allocated from: > #0 0x7f3f63cb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7f3f6366f8dd in qcalloc lib/memory.c:105 > sonic-net#2 0x561b810c62b7 in isis_srv6_sid_alloc isisd/isis_srv6.c:243 > sonic-net#3 0x561b8111f944 in isis_zebra_srv6_sid_notify isisd/isis_zebra.c:1534 > sonic-net#4 0x7f3f637df9d7 in zclient_read lib/zclient.c:4845 > sonic-net#5 0x7f3f637779b2 in event_call lib/event.c:2011 > sonic-net#6 0x7f3f63642ff1 in frr_run lib/libfrr.c:1216 > sonic-net#7 0x561b81018bf2 in main isisd/isis_main.c:360 > sonic-net#8 0x7f3f63029d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: 0af0f46 ("isisd: Receive SRv6 SIDs notifications from zebra") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
A heap use after free when enabling bmp mirror on a non connected BMP target. > Apr 22 14:06:49 vRR-DUT systemd[1]: Started bfdd. > Apr 22 14:06:51 vRR-DUT bgpd[1522]: [VTCF0-ZHP6C] bmp: missing TX OPEN message for peer Static announcement > Apr 22 14:06:51 vRR-DUT bgpd[1522]: [K3RM9-4A4HY] bmp: missing RX OPEN message for peer Static announcement > Apr 22 14:06:52 vRR-DUT bgpd[1522]: ================================================================= > Apr 22 14:06:52 vRR-DUT bgpd[1522]: ==1522==ERROR: AddressSanitizer: heap-use-after-free on address 0x60f0000321d0 at pc 0x7fe7f11c548e bp 0x7fff49f80d40 sp 0x7fff49f80d30 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: READ of size 8 at 0x60f0000321d0 thread T0 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: #0 0x7fe7f11c548d in typesafe_list_add /build/make-pkg/output/_packages/cp-routing/src/lib/typesafe.h:161 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#1 0x7fe7f11c9347 in bmp_mirrorq_add_tail /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_bmp.c:116 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#2 0x7fe7f11d030f in bmp_mirror_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_bmp.c:867 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#3 0x55c756de3e20 in hook_call_bgp_packet_dump /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:55 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#4 0x55c756dfd5ea in bgp_process_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:3699 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#5 0x7fe7f5375237 in event_call (/lib/x86_64-linux-gnu/libfrr.so.0+0x375237) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#6 0x7fe7f5242ecf in frr_run (/lib/x86_64-linux-gnu/libfrr.so.0+0x242ecf) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#7 0x55c756c71804 in main /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_main.c:545 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#8 0x7fe7f4c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#9 0x7fe7f4c29e3f in __libc_start_main_impl ../csu/libc-start.c:392 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#10 0x55c756c6e384 in _start (/usr/bin/bgpd+0x272384) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x60f0000321d0 is located 0 bytes inside of 162-byte region [0x60f0000321d0,0x60f000032272) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: freed by thread T0 here: > Apr 22 14:06:52 vRR-DUT bgpd[1522]: #0 0x7fe7f58b4537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#1 0x7fe7f526f918 in qfree (/lib/x86_64-linux-gnu/libfrr.so.0+0x26f918) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#2 0x7fe7f11d057b in bmp_mirror_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_bmp.c:875 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#3 0x55c756de3e20 in hook_call_bgp_packet_dump /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:55 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#4 0x55c756dfd5ea in bgp_process_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:3699 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#5 0x7fe7f5375237 in event_call (/lib/x86_64-linux-gnu/libfrr.so.0+0x375237) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#6 0x7fe7f5242ecf in frr_run (/lib/x86_64-linux-gnu/libfrr.so.0+0x242ecf) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#7 0x55c756c71804 in main /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_main.c:545 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#8 0x7fe7f4c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: previously allocated by thread T0 here: > Apr 22 14:06:52 vRR-DUT bgpd[1522]: #0 0x7fe7f58b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#1 0x7fe7f526f7c6 in qcalloc (/lib/x86_64-linux-gnu/libfrr.so.0+0x26f7c6) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#2 0x7fe7f11cfd38 in bmp_mirror_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_bmp.c:835 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#3 0x55c756de3e20 in hook_call_bgp_packet_dump /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:55 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#4 0x55c756dfd5ea in bgp_process_packet /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:3699 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#5 0x7fe7f5375237 in event_call (/lib/x86_64-linux-gnu/libfrr.so.0+0x375237) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#6 0x7fe7f5242ecf in frr_run (/lib/x86_64-linux-gnu/libfrr.so.0+0x242ecf) > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#7 0x55c756c71804 in main /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_main.c:545 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: sonic-net#8 0x7fe7f4c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: SUMMARY: AddressSanitizer: heap-use-after-free /build/make-pkg/output/_packages/cp-routing/src/lib/typesafe.h:161 in typesafe_list_add > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Shadow bytes around the buggy address: > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe3e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe3f0: 00 00 00 00 00 00 fa fa fa fa fa fa fa fa 00 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe410: 00 00 00 00 fa fa fa fa fa fa fa fa 00 00 00 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: =>0x0c1e7fffe430: 00 fa fa fa fa fa fa fa fa fa[fd]fd fd fd fd fd > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe440: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe450: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe460: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe470: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: 0x0c1e7fffe480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Shadow byte legend (one shadow byte represents 8 application bytes): > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Addressable: 00 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Partially addressable: 01 02 03 04 05 06 07 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Heap left redzone: fa > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Freed heap region: fd > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Stack left redzone: f1 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Stack mid redzone: f2 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Stack right redzone: f3 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Stack after return: f5 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Stack use after scope: f8 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Global redzone: f9 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Global init order: f6 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Poisoned by user: f7 > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Container overflow: fc > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Array cookie: ac > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Intra object redzone: bb > Apr 22 14:06:52 vRR-DUT bgpd[1522]: ASan internal: fe > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Left alloca redzone: ca > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Right alloca redzone: cb > Apr 22 14:06:52 vRR-DUT bgpd[1522]: Shadow gap: cc > Apr 22 14:06:52 vRR-DUT bgpd[1522]: ==1522==ABORTING > Apr 22 14:06:52 vRR-DUT yams[449]: CONFIG: [{'name': 'ttyS0'}] > Apr 22 14:06:52 vRR-DUT zebra[652]: [GE156-FS0MJ][EC 100663299] stream_read_try: read failed on fd 50: Connection reset by peer > Apr 22 14:06:52 vRR-DUT systemd[1]: bgpd.service: Main process exited, code=exited, status=1/FAILURE > Apr 22 14:06:52 vRR-DUT zebra[652]: [GE156-FS0MJ][EC 100663299] stream_read_try: read failed on fd 39: Connection reset by peer > Apr 22 14:06:52 vRR-DUT systemd[1]: bgpd.service: Failed with result 'exit-code'. > Apr 22 14:06:52 vRR-DUT zebra[652]: [N5M5Y-J5BPG][EC 4043309121] Client 'bgp' (session id 0) encountered an error and is shutting down. > Apr 22 14:06:52 vRR-DUT systemd[1]: bgpd.service: Consumed 2.361s CPU time. > Apr 22 14:06:52 vRR-DUT zebra[652]: [N5M5Y-J5BPG][EC 4043309121] Client 'bgp' (session id 1) encountered an error and is shutting down. > Apr 22 14:06:52 vRR-DUT zebra[652]: [JPSA8-5KYEA] client 39 disconnected 0 bgp routes removed from the rib > Apr 22 14:06:52 vRR-DUT zebra[652]: [S929C-NZR3N] client 39 disconnected 0 bgp nhgs removed from the rib > Apr 22 14:06:52 vRR-DUT zebra[652]: [KQB7H-NPVW9] /build/make-pkg/output/_packages/cp-routing/src/zebra/zebra_ptm.c:1285 failed to find process pid registration > Apr 22 14:06:52 vRR-DUT zebra[652]: [JPSA8-5KYEA] client 50 disconnected 0 bgp routes removed from the rib > Apr 22 14:06:52 vRR-DUT zebra[652]: [S929C-NZR3N] client 50 disconnected 0 bgp nhgs removed from the rib > Do not enqueue item in the mirror queue if no reference count has been found in the connection list. Fixes: b1ebe54 ("bgpd: bmp, handle imported bgp instances in bmp_mirror") Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Seen with bfd_vrf_topo1, and bgp_evpn_rt5 on Ubuntu 22.04 hwe. Do not call ns_delete() from zebra_vrf_delete(), which calls zebra_ns_delete(). - If a netns is removed from the system, vrf_delete()->zebra_vrf_delete() is called before calling ns_delete() (see zebra_ns_notify.c). - If zebra is terminating, zebra_ns_final_shutdown() will call zebra_vrf_delete(). > ==616172==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000ae3a4 at pc 0x556cdc178d8f bp 0x7ffe4f41ace0 sp 0x7ffe4f41acd0 > READ of size 4 at 0x6160000ae3a4 thread T0 > #0 0x556cdc178d8e in ctx_info_from_zns zebra/zebra_dplane.c:3394 > sonic-net#1 0x556cdc178f55 in dplane_ctx_ns_init zebra/zebra_dplane.c:3410 > sonic-net#2 0x556cdc17b829 in dplane_ctx_nexthop_init zebra/zebra_dplane.c:3759 > sonic-net#3 0x556cdc18095f in dplane_nexthop_update_internal zebra/zebra_dplane.c:4566 > sonic-net#4 0x556cdc1813f1 in dplane_nexthop_delete zebra/zebra_dplane.c:4793 > sonic-net#5 0x556cdc229234 in zebra_nhg_uninstall_kernel zebra/zebra_nhg.c:3484 > sonic-net#6 0x556cdc21f8fe in zebra_nhg_decrement_ref zebra/zebra_nhg.c:1804 > sonic-net#7 0x556cdc24b05a in route_entry_update_nhe zebra/zebra_rib.c:456 > sonic-net#8 0x556cdc255083 in rib_re_nhg_free zebra/zebra_rib.c:2633 > sonic-net#9 0x556cdc25e3bb in rib_unlink zebra/zebra_rib.c:4049 > sonic-net#10 0x556cdc24c9b0 in zebra_rtable_node_cleanup zebra/zebra_rib.c:903 > sonic-net#11 0x7fb25c173144 in route_node_free lib/table.c:75 > sonic-net#12 0x7fb25c17337f in route_table_free lib/table.c:111 > sonic-net#13 0x7fb25c172fe4 in route_table_finish lib/table.c:46 > sonic-net#14 0x556cdc266f62 in zebra_router_free_table zebra/zebra_router.c:191 > sonic-net#15 0x556cdc2673ef in zebra_router_terminate zebra/zebra_router.c:243 > sonic-net#16 0x556cdc10638b in zebra_finalize zebra/main.c:240 > sonic-net#17 0x7fb25c18e012 in event_call lib/event.c:2019 > sonic-net#18 0x7fb25c04afc6 in frr_run lib/libfrr.c:1247 > sonic-net#19 0x556cdc106deb in main zebra/main.c:543 > sonic-net#20 0x7fb25ba29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#21 0x7fb25ba29e3f in __libc_start_main_impl ../csu/libc-start.c:392 > sonic-net#22 0x556cdc0c7ed4 in _start (/usr/lib/frr/zebra+0x192ed4) > > 0x6160000ae3a4 is located 36 bytes inside of 592-byte region [0x6160000ae380,0x6160000ae5d0) > freed by thread T0 here: > #0 0x7fb25c6b4537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127 > sonic-net#1 0x7fb25c0790e3 in qfree lib/memory.c:131 > sonic-net#2 0x556cdc22d9c9 in zebra_ns_delete zebra/zebra_ns.c:261 > sonic-net#3 0x7fb25c0ac400 in ns_delete lib/netns_linux.c:319 > sonic-net#4 0x556cdc28026a in zebra_vrf_delete zebra/zebra_vrf.c:343 > sonic-net#5 0x7fb25c197443 in vrf_delete lib/vrf.c:282 > sonic-net#6 0x7fb25c1987e8 in vrf_terminate_single lib/vrf.c:601 > sonic-net#7 0x7fb25c197a7a in vrf_iterate lib/vrf.c:394 > sonic-net#8 0x7fb25c198834 in vrf_terminate lib/vrf.c:609 > sonic-net#9 0x556cdc106345 in zebra_finalize zebra/main.c:223 > sonic-net#10 0x7fb25c18e012 in event_call lib/event.c:2019 > sonic-net#11 0x7fb25c04afc6 in frr_run lib/libfrr.c:1247 > sonic-net#12 0x556cdc106deb in main zebra/main.c:543 > sonic-net#13 0x7fb25ba29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > previously allocated by thread T0 here: > #0 0x7fb25c6b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > sonic-net#1 0x7fb25c078f91 in qcalloc lib/memory.c:106 > sonic-net#2 0x556cdc22d6a1 in zebra_ns_new zebra/zebra_ns.c:231 > sonic-net#3 0x556cdc22e30b in zebra_ns_init zebra/zebra_ns.c:429 > sonic-net#4 0x556cdc106cec in main zebra/main.c:480 > sonic-net#5 0x7fb25ba29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > SUMMARY: AddressSanitizer: heap-use-after-free zebra/zebra_dplane.c:3394 in ctx_info_from_zns Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
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 > sonic-net#1 __pthread_kill_internal (signo=11, threadid=130889386464320) at ./nptl/pthread_kill.c:78 > sonic-net#2 __GI___pthread_kill (threadid=130889386464320, signo=signo@entry=11) at ./nptl/pthread_kill.c:89 > sonic-net#3 0x0000770b0f042476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26 > sonic-net#4 0x0000770b0f507846 in core_handler (signo=11, siginfo=0x7ffd4f7ec9f0, context=0x7ffd4f7ec8c0) > at /build/make-pkg/output/_packages/cp-routing/src/lib/sigevent.c:262 > sonic-net#5 <signal handler called> > sonic-net#6 __memmove_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:339 > sonic-net#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 > sonic-net#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 > sonic-net#9 0x00005f75d5434652 in nhrp_peer_forward (p=0x5f75f2605f30, pp=0x7ffd4f7ed8c0) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_peer.c:1050 > sonic-net#10 0x00005f75d54356cb in nhrp_peer_recv (p=0x5f75f2605f30, zb=0x5f75f2627da0) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_peer.c:1341 > sonic-net#11 0x00005f75d5430d8e in nhrp_packet_recvraw (t=0x7ffd4f7ede80) > at /build/make-pkg/output/_packages/cp-routing/src/nhrpd/nhrp_packet.c:332 > sonic-net#12 0x0000770b0f521188 in thread_call (thread=0x7ffd4f7ede80) > at /build/make-pkg/output/_packages/cp-routing/src/lib/thread.c:1825 > sonic-net#13 0x0000770b0f4b7737 in frr_run (master=0x5f75f2440570) > at /build/make-pkg/output/_packages/cp-routing/src/lib/libfrr.c:1155 > sonic-net#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>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
issue detected by Address Sanitizer Error : Address Sanitizer Error detected in /tmp_topotests/bgp_listen_l3vrf.test_bgp_listen_l3vrf/r1.asan.bgpd.6703 ================================================================= ==6703==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7f34c28b83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 sonic-net#1 0x7f34c241b45a in qcalloc lib/memory.c:111 sonic-net#2 0x7f34c247b1da in prefix_new lib/prefix.c:1192 sonic-net#3 0x55e0992e2041 in peer_group_listen_range_add bgpd/bgpd.c:3258 sonic-net#4 0x55e099282694 in bgp_listen_range bgpd/bgp_vty.c:4848 sonic-net#5 0x7f34c2397bc0 in cmd_execute_command_real lib/command.c:1011 sonic-net#6 0x7f34c2397edf in cmd_execute_command lib/command.c:1070 sonic-net#7 0x7f34c239840b in cmd_execute lib/command.c:1236 sonic-net#8 0x7f34c24e204e in vty_command lib/vty.c:626 sonic-net#9 0x7f34c24e259b in vty_execute lib/vty.c:1389 sonic-net#10 0x7f34c24e5f97 in vtysh_read lib/vty.c:2408 sonic-net#11 0x7f34c24d2958 in event_call lib/event.c:2005 sonic-net#12 0x7f34c23fc4e0 in frr_run lib/libfrr.c:1247 sonic-net#13 0x55e0990949ff in main bgpd/bgp_main.c:565 sonic-net#14 0x7f34c1e2c249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 SUMMARY: AddressSanitizer: 56 byte(s) leaked in 1 allocation(s). *********************************************************************************** Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
Memory leak happens when modifying srv6 configuration. Some sid notifications events will flush a valid srv6 context. > Direct leak of 736 byte(s) in 2 object(s) allocated from: > #0 0x7c112c0fd340 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 > sonic-net#1 0x7c112bc3595e in qcalloc lib/memory.c:111 > sonic-net#2 0x7c112bc4d37e in srv6_locator_alloc lib/srv6.c:227 > sonic-net#3 0x5f9fa87e7acf in bgp_zebra_srv6_sid_notify bgpd/bgp_zebra.c:3662 > sonic-net#4 0x7c112bd32d12 in zclient_read lib/zclient.c:4804 > sonic-net#5 0x7c112bcfaa90 in event_call lib/event.c:2005 > sonic-net#6 0x7c112bc118a7 in frr_run lib/libfrr.c:1252 > sonic-net#7 0x5f9fa85674b4 in main bgpd/bgp_main.c:565 > sonic-net#8 0x7c112b42a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#9 0x7c112b42a28a in __libc_start_main_impl ../csu/libc-start.c:360 > sonic-net#10 0x5f9fa856cbd4 in _start (/usr/lib/frr/bgpd+0x2d5bd4) (BuildId: 16288c5292cf235ab5251a93b7dbae5874c3f4bc) > > Indirect leak of 80 byte(s) in 2 object(s) allocated from: > #0 0x7c112c0fd340 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 > sonic-net#1 0x7c112bc3595e in qcalloc lib/memory.c:111 > sonic-net#2 0x7c112bc4d396 in srv6_locator_alloc lib/srv6.c:229 > sonic-net#3 0x5f9fa87e7acf in bgp_zebra_srv6_sid_notify bgpd/bgp_zebra.c:3662 > sonic-net#4 0x7c112bd32d12 in zclient_read lib/zclient.c:4804 > sonic-net#5 0x7c112bcfaa90 in event_call lib/event.c:2005 > sonic-net#6 0x7c112bc118a7 in frr_run lib/libfrr.c:1252 > sonic-net#7 0x5f9fa85674b4 in main bgpd/bgp_main.c:565 > sonic-net#8 0x7c112b42a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > sonic-net#9 0x7c112b42a28a in __libc_start_main_impl ../csu/libc-start.c:360 > sonic-net#10 0x5f9fa856cbd4 in _start (/usr/lib/frr/bgpd+0x2d5bd4) (BuildId: 16288c5292cf235ab5251a93b7dbae5874c3f4bc) Fixes: 7a2e64e ("bgpd: Receive SRv6 SIDs notification from zebra") Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
eddieruan-alibaba
pushed a commit
to eddieruan-alibaba/sonic-frr
that referenced
this pull request
Aug 19, 2025
When SRv6 locator is modified for configuration, a memory leak is observed. > ==26714==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 1104 byte(s) in 3 object(s) allocated from: > #0 0x7fb232cb83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 > sonic-net#1 0x7fb232822b79 in qcalloc lib/memory.c:111 > sonic-net#2 0x7fb23283a8b6 in srv6_locator_alloc lib/srv6.c:227 > sonic-net#3 0x56347cdd4b57 in bgp_zebra_srv6_sid_notify bgpd/bgp_zebra.c:3661 > sonic-net#4 0x7fb23290d03e in zclient_read lib/zclient.c:4804 > sonic-net#5 0x7fb2328da6a0 in event_call lib/event.c:2005 > sonic-net#6 0x7fb232800791 in frr_run lib/libfrr.c:1252 > sonic-net#7 0x56347cb929ff in main bgpd/bgp_main.c:565 > sonic-net#8 0x7fb23222c249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
Make FRR 5.0 buildable with SONiC debian8 dev environment.
- How I did it
Add sonic.debian8 target with proper settings for SONiC
- How to verify it
Build with sonic-buildimage (PR TBD), and load the image. FRR starts fine, and also FPM worked as expected towards SONiC :
$ vtysh
Hello, this is FRRouting (version 5.0.1).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic# show running-config
Building configuration...
Current configuration:
!
frr version 5.0.1
frr defaults traditional
hostname sonic
log syslog informational
log facility local4
!
router bgp 65100
bgp router-id 10.1.0.1
bgp log-neighbor-changes
no bgp default ipv4-unicast
bgp bestpath as-path multipath-relax
neighbor 10.0.0.1 remote-as 65200
neighbor 10.0.0.1 description ARISTA01T2
neighbor 10.0.0.3 remote-as 65200
neighbor 10.0.0.3 description ARISTA02T2
neighbor 10.0.0.5 remote-as 65200
neighbor 10.0.0.5 description ARISTA03T2
neighbor 10.0.0.7 remote-as 65200
....
sonic# configure terminal
sonic(config)# ip route 10.10.10.0/24 10.0.0.17
redis-cli:
127.0.0.1:6379> hgetall ROUTE_TABLE:10.10.10.0/24
More tests will be done at sonic-buildimage PR.
- Description for the changelog