]> git.puffer.fish Git - mirror/frr.git/commit
bgpd: fix multiple bugs with cluster_list attrs 6157/head 6158/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Sun, 5 Apr 2020 21:11:25 +0000 (17:11 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 6 Apr 2020 00:55:02 +0000 (20:55 -0400)
commit628565c73d5289e8004abddb6c36b4384083f0f3
tree63d8099217bbe219d537db9b1939a3527c81e28c
parent70ecc066e7d8a213a0c636fabd889614afc7ec18
bgpd: fix multiple bugs with cluster_list attrs

Multiple different issues causing mostly UAFs but maybe other more
subtle things.

- Cluster lists were the only attributes whose pointers were not being
  NULL'd when freed, resulting in heap UAF
- When performing an insert into the cluster hash, our temporary struct
  used for hash_get() was inconsistent with our hash keying and
  comparison functions. In the case of a zero length cluster list, the
  ->length field is 0 and the ->list field is NULL. When performing an
  insert, we set the ->list field regardless of whether the length is 0.
  This resulted in the two cluster lists hashing equal but not comparing
  equal. Later, when removing one of them from the hash before freeing
  it, because the key matched and the comparison succeeded (because it
  was set to NULL *after* the search but *before* inserting into the
  hash) we would sometimes release the duplicated copy of the struct,
  and then free the one that remained in the hash table. Later accesses
  constitute UAF. This is fixed by making sure the fields used for the
  existence check match what is actually inserted into the hash when
  that check fails.

This patch also makes cluster_unintern static, because it should be.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_attr.c
bgpd/bgp_attr.h