From patchwork Mon Aug 19 16:18:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1973892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4Wnd866KxJz1yXZ for ; Tue, 20 Aug 2024 02:19:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EEABB607DE; Mon, 19 Aug 2024 16:19:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id joZW2pDGu8cZ; Mon, 19 Aug 2024 16:18:58 +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 smtp3.osuosl.org 90E74607A3 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 90E74607A3; Mon, 19 Aug 2024 16:18:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5F90AC000E; Mon, 19 Aug 2024 16:18:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E2065C000D for ; Mon, 19 Aug 2024 16:18:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BC651607A3 for ; Mon, 19 Aug 2024 16:18:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 68uCQqe24O2Y for ; Mon, 19 Aug 2024 16:18:55 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=217.70.183.198; helo=relay6-d.mail.gandi.net; envelope-from=numans@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 22BB2606ED Authentication-Results: smtp3.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 22BB2606ED Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by smtp3.osuosl.org (Postfix) with ESMTPS id 22BB2606ED for ; Mon, 19 Aug 2024 16:18:54 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 878D4C0007; Mon, 19 Aug 2024 16:18:51 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Mon, 19 Aug 2024 12:18:48 -0400 Message-ID: <20240819161848.1416381-1-numans@ovn.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn] northd: Fix potential crash when creating chassisredirect port. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique Commit 8d13579bf5b3 creates a chassisredirect port for a logical switch port (of type 'router') in certain scenarios and 'op->nbsp' can be NULL. The following crash is reported by Sanitizer. ==84927==ERROR: AddressSanitizer: SEGV on unknown address ==84927==The signal is caused by a READ memory access. ==84927==Hint: address points to the zero page. #0 0x57ab3854f04a in hmap_first_with_hash ovn/ovs/./include/openvswitch/hmap.h:360:38 #1 0x57ab3854fedf in smap_find__ ovn/ovs/lib/smap.c:421:5 #2 0x57ab3854f7b8 in smap_get_node ovn/ovs/lib/smap.c:217:12 #3 0x57ab3854f74f in smap_get_def ovn/ovs/lib/smap.c:208:30 #4 0x57ab3854f726 in smap_get ovn/ovs/lib/smap.c:200:12 #5 0x57ab3854f862 in smap_get_int ovn/ovs/lib/smap.c:240:25 #6 0x57ab383222eb in ovn_port_assign_requested_tnl_id ovn/northd/northd.c:4372:27 #7 0x57ab383072fa in build_ports ovn/northd/northd.c:4454:9 #8 0x57ab38301457 in ovnnb_db_run ovn/northd/northd.c:18023:5 #9 0x57ab3841d99e in en_northd_run ovn/northd/en-northd.c:137:5 #10 0x57ab384599b2 in engine_recompute ovn/lib/inc-proc-eng.c:411:5 #11 0x57ab38459d6e in engine_run_node ovn/lib/inc-proc-eng.c:473:9 #12 0x57ab38459ec3 in engine_run ovn/lib/inc-proc-eng.c:524:9 #13 0x57ab38430c5d in inc_proc_northd_run ovn/northd/inc-proc-northd.c:420:5 #14 0x57ab3841bb2f in main ovn/northd/ovn-northd.c:970:32 This patch fixes this issue. It also corrects some typo introduced by the commit - changes the reference from "chassisresident" to "chassisredirect". Fixes: 8d13579bf5b3 ("Add support for centralize routing for distributed gw ports.") Reported-by: Felix Huettner Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2024-August/416264.html CC: Han Zhou Signed-off-by: Numan Siddique Acked-by: Han Zhou --- northd/northd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 7ceed63ddb..73367b9104 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -1126,7 +1126,7 @@ is_l3dgw_port(const struct ovn_port *op) /* This function returns true if 'op' is a chassis resident * derived port. False otherwise. * There are 2 ways to check if 'op' is chassis resident port. - * 1. op->sb->type is "chassisresident" + * 1. op->sb->type is "chassisredirect" * 2. op->primary_port is not NULL. If op->primary_port is set, * it means 'op' is derived from the ovn_port op->primary_port. * @@ -2136,7 +2136,7 @@ create_cr_port(struct ovn_port *op, struct hmap *ports, struct ovn_port *crp = ovn_port_find(ports, redirect_name); if (crp && crp->sb && crp->sb->datapath == op->od->sb) { - ovn_port_set_nb(crp, NULL, op->nbrp); + ovn_port_set_nb(crp, op->nbsp, op->nbrp); ovs_list_remove(&crp->list); ovs_list_push_back(both_dbs, &crp->list); } else { @@ -2466,7 +2466,7 @@ join_logical_ports(const struct sbrec_port_binding_table *sbrec_pb_table, } - /* Create chassisresident port for the distributed gateway port's (DGP) + /* Create chassisredirect port for the distributed gateway port's (DGP) * peer if * - DGP's router has only one DGP and * - Its peer is a logical switch port and @@ -12622,7 +12622,7 @@ build_lrouter_port_nat_arp_nd_flow(struct ovn_port *op, if (op->peer && op->peer->cr_port) { /* We don't add the below flows if the router port's peer has - * a chassisresident port. That's because routing is centralized on + * a chassisredirect port. That's because routing is centralized on * the gateway chassis for the router port networks/subnets. */ return; @@ -16349,7 +16349,7 @@ lrouter_check_nat_entry(const struct ovn_datapath *od, *distributed = false; /* NAT cannnot be distributed if the DGP's peer - * has a chassisresident port (as the routing is centralized + * has a chassisredirect port (as the routing is centralized * on the gateway chassis for the DGP's networks/subnets.) */ struct ovn_port *l3dgw_port = *nat_l3dgw_port;