mbox series

[ovs-dev,00/11] Fix UndefinedBehaviorSanitizer reported issues and enable it in CI.

Message ID 20211217131623.30994.63519.stgit@dceara.remote.csb
Headers show
Series Fix UndefinedBehaviorSanitizer reported issues and enable it in CI. | expand

Message

Dumitru Ceara Dec. 17, 2021, 1:16 p.m. UTC
As privately reported by Aaron Conole, there's currently a number of
undefined behavior instances in the OVS code base.  Running the OVS
(and OVN) tests with UBSan [0] enabled uncovers these.

This series fixes the issues reported by UBSan and, throught the last
patch, enables UBSan tests in GitHub Actions CI.

[0] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Dumitru Ceara (11):
      util: Avoid false positive UB when iterating collections.
      treewide: Don't pass NULL to library functions that expect non-NULL.
      dpif-netdev: Fix misaligned access.
      stopwatch: Fix buffer underflow when computing percentiles.
      treewide: Fix invalid bit shift operations.
      ovsdb-idlc: Avoid accessing member within NULL idl index cursors.
      ofp-actions: ofp-errors: Use aligned structures when decoding ofp actions.
      bfd: lldp: stp: Fix misaligned packet field access.
      dp-packet: Ensure packet base is always non-NULL.
      treewide: Avoid offsetting NULL pointers.
      ci: Add UB Sanitizer.

 .ci/linux-build.sh                   |    6 ++++
 .github/workflows/build-and-test.yml |    5 +++
 configure.ac                         |    1 +
 include/openvswitch/ofp-actions.h    |    5 +++
 include/openvswitch/ofpbuf.h         |   17 ++++++++---
 include/openvswitch/util.h           |    5 +++
 lib/bfd.c                            |   51 ++++++++++++++++++--------------
 lib/dpif-netdev.c                    |   14 +++++----
 lib/dpif-netlink.c                   |    2 +
 lib/dynamic-string.c                 |   10 +++++-
 lib/lldp/lldp.c                      |    4 ++-
 lib/meta-flow.c                      |   10 ++++++
 lib/netdev-dummy.c                   |    6 ++--
 lib/nx-match.c                       |    7 ++++
 lib/ofp-actions.c                    |   54 +++++++++++++++++++++++-----------
 lib/ofp-errors.c                     |    2 +
 lib/ofpbuf.c                         |    8 +++++
 lib/ovsdb-data.c                     |   41 ++++++++++++++++----------
 lib/ovsdb-data.h                     |    4 +++
 lib/sset.c                           |    4 ++-
 lib/stopwatch.c                      |    4 +--
 lib/stp.c                            |   16 +++++-----
 lib/tnl-ports.c                      |    2 +
 ofproto/bond.c                       |    3 +-
 ofproto/ofproto-dpif-rid.c           |    6 +++-
 ofproto/ofproto-dpif-trace.c         |    4 +--
 ofproto/ofproto-dpif-xlate.c         |   20 ++++++++-----
 ofproto/ofproto-dpif.c               |    6 ++--
 ofproto/ofproto.c                    |    2 +
 ovsdb/monitor.c                      |    4 +++
 ovsdb/ovsdb-idlc.in                  |    2 +
 tests/atlocal.in                     |   16 ++++++++++
 tests/automake.mk                    |    1 +
 tests/daemon.at                      |    8 +++++
 tests/ovs-macros.at                  |    5 +++
 tests/ovsdb-server.at                |   16 ++++++++++
 tests/test-hash.c                    |    2 +
 tests/test-util.c                    |   13 ++++----
 utilities/ovs-ofctl.c                |    6 +---
 39 files changed, 273 insertions(+), 119 deletions(-)