As privately reported by Aaron Conole, and by Jeffrey Walton [0] there's currently a number of undefined behavior instances in the OVS code base. Running the OVS (and OVN) tests with UBSan [1] enabled uncovers these.
This series fixes the issues reported by UBSan and, through the last patch, enables UBSan tests in GitHub Actions CI. Note: depending on the order of reviews, if Adrian's "Fix undefined behavior in loop macros" series [2] (or a follow up) is accepted first, then patch 6/7 ("util: Avoid UB when iterating collections.") can be skipped. Adrian's series seems to be the more correct way of fixing the issue. OVN CI run with UBSan enabled: https://github.com/dceara/ovn/runs/5336641092 [0] https://mail.openvswitch.org/pipermail/ovs-dev/2022-January/390894.html [1] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html [2] https://patchwork.ozlabs.org/project/openvswitch/list/?series=286494&state=* Changes in v4: - Rebased, dropping patches that were already applied. - Addressed Ilya's comments. - Added acks from Paolo from v3 as nothing major changed in this revision. - Rephrased the commit message for "util: Avoid UB when iterating collections." Changes in v3: - Added acks to the patches acked by Aaron. - Addressed Aaron's comments. - Split previous patch 07/11 "ofp-actions: ofp-errors: Use aligned structures when decoding ofp actions." into three separate patches addressing independent issues. - Reordered patches such that the ones that might need follow up are towards the end of the series. - Added a new patch, patch 13/14, fixing a typo in the CFLAGS_ASAN variables in the script used for building OVS in CI. This typo was originally copy/pasted in the CFLAGS_UBSAN flags in v1 and v2 of this series. Changes in v2: - Patch 3/11: - Remove cache line size aligment markers instead, as suggested by Ilya. Dumitru Ceara (7): treewide: Fix invalid bit shift operations. treewide: Avoid offsetting NULL pointers. ofp-actions: Ensure aligned accesses when setting masked fields. ofp-errors: Ensure parsed OFPT_ERROR messages are properly aligned. ofp-actions: Use aligned structures when decoding ofp actions. util: Avoid UB when iterating collections. 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 | 19 ++++++-- include/openvswitch/util.h | 5 ++ lib/dpif-netlink.c | 2 - lib/dynamic-string.c | 8 +++ lib/meta-flow.c | 10 ++++ lib/nx-match.c | 7 +++ lib/ofp-actions.c | 79 ++++++++++++++++++++++++++-------- lib/ofp-errors.c | 2 + lib/ofpbuf.c | 43 +++++++++++++++++++ lib/ovsdb-data.c | 37 +++++++++------- lib/ovsdb-data.h | 4 ++ lib/sset.c | 4 +- lib/tnl-ports.c | 2 - ofproto/ofproto-dpif-xlate.c | 16 +++++-- ofproto/ofproto.c | 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 | 3 + tests/test-util.c | 13 +++--- 26 files changed, 258 insertions(+), 61 deletions(-) _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev