Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
```
==58960==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040000707a8 at pc 0x55c24bbcd023 bp 0x7ffdb042d050 sp 0x7ffdb042d040
READ of size 8 at 0x6040000707a8 thread T0
    #0 0x55c24bbcd022 in aspath_key_make bgpd/bgp_aspath.c:2070
    #1 0x55c24b8f1140 in attrhash_key_make bgpd/bgp_attr.c:777
    #2 0x7f52322e66c9 in hash_release lib/hash.c:220
    #3 0x55c24b8f6017 in bgp_attr_unintern bgpd/bgp_attr.c:1271
    #4 0x55c24ba0acaa in bgp_path_info_free_with_caller bgpd/bgp_route.c:283
    #5 0x55c24ba0a7de in bgp_path_info_unlock bgpd/bgp_route.c:309
    #6 0x55c24ba0af6d in bgp_path_info_reap bgpd/bgp_route.c:426
    #7 0x55c24ba17b9a in bgp_process_main_one bgpd/bgp_route.c:3333
    #8 0x55c24ba18a1d in bgp_process_wq bgpd/bgp_route.c:3425
    #9 0x7f52323c2cd5 in work_queue_run lib/workqueue.c:282
    #10 0x7f52323aab92 in thread_call lib/thread.c:2006
    #11 0x7f5232300dc7 in frr_run lib/libfrr.c:1198
    #12 0x55c24b8ea792 in main bgpd/bgp_main.c:520
    #13 0x7f5231c3a082 in __libc_start_main ../csu/libc-start.c:308
    #14 0x55c24b8ef0bd in _start (/usr/lib/frr/bgpd+0x2c90bd)

0x6040000707a8 is located 24 bytes inside of 40-byte region [0x604000070790,0x6040000707b8)
freed by thread T0 here:
    #0 0x7f52326e740f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:122
    #1 0x55c24bbcc36f in aspath_unintern bgpd/bgp_aspath.c:345
    #2 0x55c24b8f56f2 in bgp_attr_unintern_sub bgpd/bgp_attr.c:1204
    #3 0x55c24b8f6049 in bgp_attr_unintern bgpd/bgp_attr.c:1277
    #4 0x55c24bbc9c1a in bgp_adj_in_remove bgpd/bgp_advertise.c:208
    #5 0x55c24ba0b0d4 in bgp_clear_route_table bgpd/bgp_route.c:5553
    #6 0x55c24ba1ba57 in bgp_clear_route bgpd/bgp_route.c:5612
    #7 0x55c24ba1bedf in bgp_clear_route_all bgpd/bgp_route.c:5634
    #8 0x55c24b99c762 in bgp_fsm_change_status bgpd/bgp_fsm.c:1288
    #9 0x55c24b9a163d in bgp_event_update bgpd/bgp_fsm.c:2639
    #10 0x55c24b9a176b in bgp_event bgpd/bgp_fsm.c:2591
    #11 0x7f52323aab92 in thread_call lib/thread.c:2006
    #12 0x7f5232300dc7 in frr_run lib/libfrr.c:1198
    #13 0x55c24b8ea792 in main bgpd/bgp_main.c:520
    #14 0x7f5231c3a082 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7f52326e7808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f523231e209 in qmalloc lib/memory.c:111
    #2 0x55c24bbcb889 in aspath_hash_alloc bgpd/bgp_aspath.c:728
    #3 0x7f52322e5f07 in hash_get lib/hash.c:162
    #4 0x55c24bbcd63b in aspath_parse bgpd/bgp_aspath.c:862
    #5 0x55c24b8fd48c in bgp_attr_aspath bgpd/bgp_attr.c:1613
    #6 0x55c24b8fd48c in bgp_attr_parse bgpd/bgp_attr.c:3656
    #7 0x55c24b9e2f22 in bgp_update_receive bgpd/bgp_packet.c:1952
    #8 0x55c24b9e9a3f in bgp_process_packet bgpd/bgp_packet.c:2940
    #9 0x7f52323aab92 in thread_call lib/thread.c:2006
    #10 0x7f5232300dc7 in frr_run lib/libfrr.c:1198
    #11 0x55c24b8ea792 in main bgpd/bgp_main.c:520
    #12 0x7f5231c3a082 in __libc_start_main ../csu/libc-start.c:308
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
  • Loading branch information
ton31337 committed Feb 8, 2023
1 parent e7765b8 commit 2c5c011
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 0 deletions.
Empty file.
36 changes: 36 additions & 0 deletions tests/topotests/bgp_crash_test/r1/bgpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
router bgp 65001
no bgp ebgp-requires-policy
neighbor 192.168.1.2 remote-as external
neighbor 192.168.1.2 timers 1 3
neighbor 192.168.1.2 timers connect 1
neighbor 192.168.2.2 remote-as external
neighbor 192.168.2.2 timers 1 3
neighbor 192.168.2.2 timers connect 1
address-family ipv4
network 154.47.112.0/22
network 154.47.116.0/22
network 192.168.2.0/24
network 192.168.3.0/24
network 192.168.4.0/24
neighbor 192.168.1.2 default-originate
neighbor 192.168.1.2 soft-reconfiguration inbound
neighbor 192.168.1.2 route-map RM-BGP-PASS-ALL in
neighbor 192.168.1.2 route-map RM-BGP-PASS-ALL out
neighbor 192.168.2.2 soft-reconfiguration inbound
neighbor 192.168.2.2 route-map RM-BGP-DEFAULT-ROUTE-IN in
neighbor 192.168.2.2 route-map RM-BGP-INTERNET-OUT out
exit-address-family
!
ip prefix-list PFX-DEFAULT-V4 seq 5 permit 0.0.0.0/0
ip prefix-list PFX-BGP-INTERNET-OUT seq 15 permit 154.47.112.0/21 le 22
!
route-map TEST permit 10
match ip address prefix-list PFX-DEFAULT-V4
!
route-map RM-BGP-INTERNET-OUT permit 10
match ip address prefix-list PFX-BGP-INTERNET-OUT
!
route-map RM-BGP-DEFAULT-ROUTE-IN permit 10
match ip address prefix-list PFX-DEFAULT-V4
!
route-map RM-BGP-PASS-ALL permit 10
10 changes: 10 additions & 0 deletions tests/topotests/bgp_crash_test/r1/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!
interface lo
ip address 172.16.255.1/32
!
interface r1-eth0
ip address 192.168.1.1/24
!
interface r1-eth1
ip address 192.168.2.1/24
!
12 changes: 12 additions & 0 deletions tests/topotests/bgp_crash_test/r2/bgpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
router bgp 65002
no bgp ebgp-requires-policy
neighbor 192.168.1.1 remote-as external
neighbor 192.168.1.1 timers 1 3
neighbor 192.168.1.1 timers connect 1
address-family ipv4 unicast
network 192.168.2.0/24
neighbor 192.168.1.1 route-map RM-BGP-PASS-ALL in
neighbor 192.168.1.1 route-map RM-BGP-PASS-ALL out
exit-address-family
!
route-map RM-BGP-PASS-ALL permit 10
4 changes: 4 additions & 0 deletions tests/topotests/bgp_crash_test/r2/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!
interface r2-eth0
ip address 192.168.1.2/24
!
14 changes: 14 additions & 0 deletions tests/topotests/bgp_crash_test/r3/bgpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
router bgp 65002
no bgp ebgp-requires-policy
neighbor 192.168.2.1 remote-as external
neighbor 192.168.2.1 timers 1 3
neighbor 192.168.2.1 timers connect 1
address-family ipv4 unicast
network 0.0.0.0/0
network 192.168.4.0/24
neighbor 192.168.2.1 route-map RM-BGP-PASS-ALL in
neighbor 192.168.2.1 route-map RM-BGP-PASS-ALL out
exit-address-family
!
route-map RM-BGP-PASS-ALL permit 10
!
5 changes: 5 additions & 0 deletions tests/topotests/bgp_crash_test/r3/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!
interface r3-eth0
ip address 192.168.2.2/24
!
ip route 0.0.0.0/0 Null0
85 changes: 85 additions & 0 deletions tests/topotests/bgp_crash_test/test_bgp_crash_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python

#
# Copyright (c) 2022 by
# Donatas Abraitis <donatas@opensourcerouting.org>
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose with or without fee is hereby granted, provided
# that the above copyright notice and this permission notice appear
# in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
#

"""
"""

import os
import sys
import json
import pytest
import functools

CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))

# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.common_config import step

pytestmark = [pytest.mark.bgpd]


def build_topo(tgen):
for routern in range(1, 4):
tgen.add_router("r{}".format(routern))

switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["r1"])
switch.add_link(tgen.gears["r2"])

switch = tgen.add_switch("s2")
switch.add_link(tgen.gears["r1"])
switch.add_link(tgen.gears["r3"])


def setup_module(mod):
tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()

router_list = tgen.routers()

for i, (rname, router) in enumerate(router_list.items(), 1):
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config(
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
)

tgen.start_router()


def teardown_module(mod):
tgen = get_topogen()
tgen.stop_topology()

def test_bgp_convergence():
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))

0 comments on commit 2c5c011

Please sign in to comment.