From patchwork Mon Mar 11 14:48:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1910492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XdiIThNW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ttfly1WVQz1yWn for ; Tue, 12 Mar 2024 01:48:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 54D43405DB; Mon, 11 Mar 2024 14:48:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JhqQfh_aPsY1; Mon, 11 Mar 2024 14:48:25 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C671140624 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XdiIThNW Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id C671140624; Mon, 11 Mar 2024 14:48:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D0CB5C0072; Mon, 11 Mar 2024 14:48:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 84FCFC0037 for ; Mon, 11 Mar 2024 14:48:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7967040650 for ; Mon, 11 Mar 2024 14:48:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rus6TPD_-ZfZ for ; Mon, 11 Mar 2024 14:48:19 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 421794064F Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 421794064F Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XdiIThNW Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 421794064F for ; Mon, 11 Mar 2024 14:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710168497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LN9zUKaej2PGUQGfin3lVedhVzjphP1M+DtuhQsWoHU=; b=XdiIThNWx8hZwaMS1DaU13/8PIPm+r0LHrmq2YBoWH5gfDu3+y14m1yFYBVYAR9zx+nkbH OEf/zc80BzBvSbWxIrPwa/4g5SnWmZnqcqtCe/tyJSdkOgshKP2p3jGvJksvJBE+E84elw Ye79ZgmVAlfzHi01n3iivnLFBL3l9QA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-248-aTt_KCcOMzqC5yXh9CJZ1Q-1; Mon, 11 Mar 2024 10:48:15 -0400 X-MC-Unique: aTt_KCcOMzqC5yXh9CJZ1Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BE978007B5 for ; Mon, 11 Mar 2024 14:48:15 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.45.224.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0638C017A2; Mon, 11 Mar 2024 14:48:14 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Mon, 11 Mar 2024 15:48:13 +0100 Message-ID: <20240311144813.1060574-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] northd: Fix NULL pointer deref within build_bfd_table. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The cb_bt pointer was pointing to different struct and might have been NULL at this point. Make sure we are using the correct pointer in the strcmp() and sbrec_bfd_set_chassis_name() call. At the same time make sure we are actually running all tests that do require the BFD beacon, as it was skipped in all CI stages. The OpenBFDD project is not available as rpm, so we need to compile it from source. Fixes: 4885e337f929 ("rbac: Only allow relevant chassis to update BFD.") Signed-off-by: Ales Musil Acked-by: Mark Michelson --- northd/northd.c | 5 ++-- utilities/automake.mk | 1 + utilities/containers/fedora/Dockerfile | 18 ++++++++++++ utilities/containers/openbfdd.patch | 39 ++++++++++++++++++++++++++ utilities/containers/ubuntu/Dockerfile | 18 ++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 utilities/containers/openbfdd.patch diff --git a/northd/northd.c b/northd/northd.c index 4b39137e7..1839b7d8b 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -9804,8 +9804,9 @@ build_bfd_table(struct ovsdb_idl_txn *ovnsb_txn, } build_bfd_update_sb_conf(nb_bt, bfd_e->sb_bt); if (op && op->sb && op->sb->chassis && - strcmp(op->sb->chassis->name, sb_bt->chassis_name)) { - sbrec_bfd_set_chassis_name(sb_bt, op->sb->chassis->name); + strcmp(op->sb->chassis->name, bfd_e->sb_bt->chassis_name)) { + sbrec_bfd_set_chassis_name(bfd_e->sb_bt, + op->sb->chassis->name); } hmap_remove(&sb_only, &bfd_e->hmap_node); diff --git a/utilities/automake.mk b/utilities/automake.mk index c44563c26..ebb74ec34 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -38,6 +38,7 @@ EXTRA_DIST += \ utilities/ovndb-servers.ocf \ utilities/checkpatch.py \ utilities/containers/Makefile \ + utilities/containers/openbfdd.patch \ utilities/containers/py-requirements.txt \ utilities/containers/fedora/Dockerfile \ utilities/containers/ubuntu/Dockerfile \ diff --git a/utilities/containers/fedora/Dockerfile b/utilities/containers/fedora/Dockerfile index 4058d7f5b..bf3c293fc 100755 --- a/utilities/containers/fedora/Dockerfile +++ b/utilities/containers/fedora/Dockerfile @@ -52,6 +52,24 @@ RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \ && \ make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install +# Compile OpenBFDD from source +WORKDIR /workspace/OpenBFDD + +COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch + +RUN git clone https://github.com/dyninc/OpenBFDD.git \ + /workspace/OpenBFDD \ + && \ + git apply /tmp/openbfdd.patch \ + && \ + ./autogen.sh \ + && \ + ./configure --enable-silent-rules \ + && \ + make \ + && \ + make install + WORKDIR /workspace COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt diff --git a/utilities/containers/openbfdd.patch b/utilities/containers/openbfdd.patch new file mode 100644 index 000000000..96e8095d9 --- /dev/null +++ b/utilities/containers/openbfdd.patch @@ -0,0 +1,39 @@ +diff --git a/Logger.cpp b/Logger.cpp +index f375b20..e72afba 100755 +--- a/Logger.cpp ++++ b/Logger.cpp +@@ -11,6 +11,8 @@ + #include + #include + #include ++#include ++#include + + const size_t Logger::MaxMessageLen; + +diff --git a/SchedulerBase.cpp b/SchedulerBase.cpp +index 3eab298..c1dffc4 100755 +--- a/SchedulerBase.cpp ++++ b/SchedulerBase.cpp +@@ -11,6 +11,8 @@ + #include + #include + #include ++#include ++#include + + using namespace std; + +diff --git a/utils.cpp b/utils.cpp +index 79c7b68..f846459 100755 +--- a/utils.cpp ++++ b/utils.cpp +@@ -13,6 +13,8 @@ + #include + #include + #include ++#include ++#include + + using namespace std; + diff --git a/utilities/containers/ubuntu/Dockerfile b/utilities/containers/ubuntu/Dockerfile index 5d5bedbd9..1371b3f70 100755 --- a/utilities/containers/ubuntu/Dockerfile +++ b/utilities/containers/ubuntu/Dockerfile @@ -51,6 +51,24 @@ RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \ && \ make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install +# Compile OpenBFDD from source +WORKDIR /workspace/OpenBFDD + +COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch + +RUN git clone https://github.com/dyninc/OpenBFDD.git \ + /workspace/OpenBFDD \ + && \ + git apply /tmp/openbfdd.patch \ + && \ + ./autogen.sh \ + && \ + ./configure --enable-silent-rules \ + && \ + make \ + && \ + make install + WORKDIR /workspace COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt