Skip to content

bgpd: A use-after-free bug due to race conditions in 2 threads. #11698

Closed
@spwpun

Description


Describe the bug

  • Did you check if this is a duplicate issue?
  • Did you test it on the latest FRRouting/frr master branch?

To Reproduce

  1. git clone the frr git version with commit: a9b4458
  2. Compile it with -fsanitize=address flags.
  3. Run bgpd with a simple bgpd.conf as follow: /path/to/bgpd -f /path/to/bgpd.conf
! -*- bgp -*-
!
! BGPd sample configuratin file
!
!

hostname bgpd-S1
password en
enable password en

interface lo
ip address 127.0.0.1/32

router bgp 1
 bgp router-id 172.17.0.3
 address-family ipv4 unicast
   network 172.17.0.0/24
 exit-address-family
 no bgp ebgp-requires-policy
 no bgp network import-check
 neighbor 172.17.0.1 remote-as 2
 neighbor 172.17.0.1 ebgp-multihop
 neighbor 172.17.0.1 next-hop-self
 neighbor 172.17.0.1 timers 5 5
 neighbor 172.17.0.1 extended-optional-parameters


log file /tmp/bgpd.log

!debug bgp as4
!debug bgp events
!debug bgp filters
!debug bgp fsm
debug bgp keepalives
debug bgp updates
debug bgp neighbor-events

!
log stdout
  1. Write a loop to sequencely send the packets below until it crash:
bgp_open = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00#\x01\x04\x00\x02\x00\x05\xac\x11\x00\x01\xff\xff\x00\x03\x00\x01\x00'
bgp_keepalive = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04'
bgp_notification = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x15\x04xv'

1658832888676-9bf5e7f1-cf0a-4f12-a7d4-3e5b8a605776
Because of the race condition, this might not be always cause the bgpd crash.
Expected behavior

The bgpd daemon program won't crash.
Screenshots

The ASAN outputs:
1658832889200-80fa1c84-6221-4dfe-a018-81615ed683c5
1658832889742-7a6e3765-7895-400f-ba58-97ecaf848313
1658832890273-24f0db12-1057-4e85-bd03-8c70b9a5316d

Versions

  • OS Version: Ubuntu 20.04
  • Kernel: Linux 1738de574178 5.15.0-41-generic #44~20.04.1-Ubuntu
  • FRR Version: git version with commit: a9b4458.

Additional context

Metadata

Assignees

Labels

bgptriageNeeds further investigation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions