From patchwork Mon Jan 24 14:17:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=BRqrtfDZ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBs65GBfz9t4b for ; Tue, 25 Jan 2022 01:17:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D2B0B41586; Mon, 24 Jan 2022 14:17:43 +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 Ft7U44U0i3Z1; Mon, 24 Jan 2022 14:17:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id A4A1041548; Mon, 24 Jan 2022 14:17:41 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 73936C0039; Mon, 24 Jan 2022 14:17:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8FC0CC0072 for ; Mon, 24 Jan 2022 14:17:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7EC8083E59 for ; Mon, 24 Jan 2022 14:17:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mCYNKdUJtoEb for ; Mon, 24 Jan 2022 14:17:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id B974C82A53 for ; Mon, 24 Jan 2022 14:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033856; 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: in-reply-to:in-reply-to:references:references; bh=rapy8VyrPphMeTBAvlLBtntNEhoPzPmt6uXMP+QbFlY=; b=BRqrtfDZ5qAoPUNdqqYPlgOAQneAzhIcDGFNKtMcwGYkSVtsPqvQ0ooG2gUxVeqUqEaFwl MR1txfDaJnJFGIcRTUC1s6G0iofIaFZBkiyyNf0ggM3kxf3qEWh58ppd3hkyjDyEGt0wJl cv2AgauiRjHWjG5yk8T9S0B2iywDtMY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-FsLdQtc7OFaSZiITGKYQiA-1; Mon, 24 Jan 2022 09:17:33 -0500 X-MC-Unique: FsLdQtc7OFaSZiITGKYQiA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64552190D342; Mon, 24 Jan 2022 14:17:32 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB417BB66; Mon, 24 Jan 2022 14:17:30 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:17:28 +0100 Message-Id: <20220124141723.11777.9071.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 01/14] treewide: Don't pass NULL to library functions that expect non-NULL. 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" It's actually undefined behavior to pass NULL to standard library functions that manipulate arrays (e.g., qsort, memcpy, memcmp), even if the passed number of items is 0. UB Sanitizer reports: ovsdb/monitor.c:408:9: runtime error: null pointer passed as argument 1, which is declared to never be null #0 0x406ae1 in ovsdb_monitor_columns_sort ovsdb/monitor.c:408 #1 0x406ae1 in ovsdb_monitor_add ovsdb/monitor.c:1683 [...] lib/ovsdb-data.c:1970:5: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x4071c8 in ovsdb_datum_push_unsafe lib/ovsdb-data.c:1970 #1 0x471cd0 in ovsdb_datum_apply_diff_in_place lib/ovsdb-data.c:2345 [...] ofproto/ofproto-dpif-rid.c:159:17: runtime error: null pointer passed as argument 1, which is declared to never be null #0 0x4df5d8 in frozen_state_equal ofproto/ofproto-dpif-rid.c:159 #1 0x4dfd27 in recirc_find_equal ofproto/ofproto-dpif-rid.c:179 [...] Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- v3: Added Aaron's ack. --- lib/dpif-netdev.c | 4 +++- lib/ofp-actions.c | 2 +- lib/ofpbuf.c | 4 ++++ lib/ovsdb-data.c | 4 ++++ ofproto/ofproto-dpif-rid.c | 6 ++++-- ovsdb/monitor.c | 4 ++++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index e28e0b5543f6..45435fdec9e5 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -5099,8 +5099,10 @@ dp_netdev_actions_create(const struct nlattr *actions, size_t size) struct dp_netdev_actions *netdev_actions; netdev_actions = xmalloc(sizeof *netdev_actions + size); - memcpy(netdev_actions->actions, actions, size); netdev_actions->size = size; + if (size) { + memcpy(netdev_actions->actions, actions, size); + } return netdev_actions; } diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 68a846a24bad..006837c2e1f5 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -9157,7 +9157,7 @@ bool ofpacts_equal(const struct ofpact *a, size_t a_len, const struct ofpact *b, size_t b_len) { - return a_len == b_len && !memcmp(a, b, a_len); + return a_len == b_len && (!a_len || !memcmp(a, b, a_len)); } /* Returns true if the 'a_len' bytes of actions in 'a' and the 'b_len' bytes of diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 4edb3c114ae6..271105bdea17 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -384,6 +384,10 @@ ofpbuf_put_zeros(struct ofpbuf *b, size_t size) void * ofpbuf_put(struct ofpbuf *b, const void *p, size_t size) { + if (!size) { + return ofpbuf_tail(b); + } + void *dst = ofpbuf_put_uninit(b, size); memcpy(dst, p, size); return dst; diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index 2832e94ea04a..6b1c20ff85a0 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1967,6 +1967,10 @@ ovsdb_datum_push_unsafe(struct ovsdb_datum *dst, unsigned int start_idx, unsigned int n, const struct ovsdb_type *type) { + if (n == 0) { + return; + } + memcpy(&dst->keys[dst->n], &src->keys[start_idx], n * sizeof src->keys[0]); if (type->value.type != OVSDB_TYPE_VOID) { memcpy(&dst->values[dst->n], &src->values[start_idx], diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c index 29aafc2c0b40..f01468025c03 100644 --- a/ofproto/ofproto-dpif-rid.c +++ b/ofproto/ofproto-dpif-rid.c @@ -156,7 +156,7 @@ frozen_state_equal(const struct frozen_state *a, const struct frozen_state *b) && uuid_equals(&a->ofproto_uuid, &b->ofproto_uuid) && !memcmp(&a->metadata, &b->metadata, sizeof a->metadata) && a->stack_size == b->stack_size - && !memcmp(a->stack, b->stack, a->stack_size) + && (!a->stack_size || !memcmp(a->stack, b->stack, a->stack_size)) && a->mirrors == b->mirrors && a->conntracked == b->conntracked && a->was_mpls == b->was_mpls @@ -164,7 +164,9 @@ frozen_state_equal(const struct frozen_state *a, const struct frozen_state *b) b->ofpacts, b->ofpacts_len) && ofpacts_equal(a->action_set, a->action_set_len, b->action_set, b->action_set_len) - && !memcmp(a->userdata, b->userdata, a->userdata_len) + && a->userdata_len == b->userdata_len + && (!a->userdata_len + || !memcmp(a->userdata, b->userdata, a->userdata_len)) && uuid_equals(&a->xport_uuid, &b->xport_uuid)); } diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c index ab814cf20e26..0f222cc99284 100644 --- a/ovsdb/monitor.c +++ b/ovsdb/monitor.c @@ -405,6 +405,10 @@ ovsdb_monitor_columns_sort(struct ovsdb_monitor *dbmon) SHASH_FOR_EACH (node, &dbmon->tables) { struct ovsdb_monitor_table *mt = node->data; + if (mt->n_columns == 0) { + continue; + } + qsort(mt->columns, mt->n_columns, sizeof *mt->columns, compare_ovsdb_monitor_column); for (i = 0; i < mt->n_columns; i++) { From patchwork Mon Jan 24 14:17:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=XiqvhaNt; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBsQ2wYqz9t4b for ; Tue, 25 Jan 2022 01:18:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B011B408D5; Mon, 24 Jan 2022 14:18:00 +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 H3V__k04aujf; Mon, 24 Jan 2022 14:17:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 93A42408E2; Mon, 24 Jan 2022 14:17:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5577BC0039; Mon, 24 Jan 2022 14:17:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1CC72C002F for ; Mon, 24 Jan 2022 14:17:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3B3FE60E78 for ; Mon, 24 Jan 2022 14:17:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NnQGOS6xRxEV for ; Mon, 24 Jan 2022 14:17:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4EB6F60E81 for ; Mon, 24 Jan 2022 14:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033869; 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: in-reply-to:in-reply-to:references:references; bh=llYDVEaUcseqY0HFR9w+pH+ETtLVfYx4+fyPa8Wz7hU=; b=XiqvhaNtrlVMOE0WqSyx9WpRVJaoMvKXBAKMoj7T/peFRr1bc8uF+Ba/9pf3aFNACXscsJ UqiaONS9oPdfx3WF+QjBjvMZGaS4hoZFxlWoXRtdQBhid7O0hPwsPoVASd2Vp1rGFrFL7i LWTVCn9MsxPEYxY8BK/DNzRY0cHQHlI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-ZY0_j7yaM3KveESXo84zEA-1; Mon, 24 Jan 2022 09:17:46 -0500 X-MC-Unique: ZY0_j7yaM3KveESXo84zEA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11250100C660; Mon, 24 Jan 2022 14:17:45 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D4157E121; Mon, 24 Jan 2022 14:17:43 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:17:40 +0100 Message-Id: <20220124141737.11777.23391.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 02/14] dpif-netdev: Fix misaligned access. 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" Remove the forced cache-line size alignment markers from struct dp_netdev_pmd_thread and struct dp_netdev as discussed at [0]. They don't seem to add any benefit and cause 64 byte alignment requirements. UB Sanitizer report: lib/dpif-netdev.c:6758:13: runtime error: member access within misaligned address 0x7f7f24d25010 for type 'struct dp_netdev_pmd_thread', which requires 64 byte alignment 0x7f7f24d25010: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ #0 0x5fbfde in dp_netdev_configure_pmd lib/dpif-netdev.c:6758 #1 0x5fbde9 in dp_netdev_set_nonpmd lib/dpif-netdev.c:6715 #2 0x5d6fdd in create_dp_netdev lib/dpif-netdev.c:1769 #3 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807 #4 0x61c83f in do_open lib/dpif.c:347 [...] lib/dpif-netdev.c:1724:6: runtime error: member access within misaligned address 0x000002005eb0 for type 'struct dp_netdev', which requires 64 byte alignment 0x000002005eb0: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ #0 0x5d6660 in create_dp_netdev lib/dpif-netdev.c:1724 #1 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807 #2 0x61c846 in do_open lib/dpif.c:347 #3 0x61ca9c in dpif_create lib/dpif.c:402 #4 0x61cac9 in dpif_create_and_open lib/dpif.c:415 #5 0x48f235 in open_dpif_backer ofproto/ofproto-dpif.c:776 [...] [0] https://mail.openvswitch.org/pipermail/ovs-dev/2021-December/390256.html Suggested-by: Ilya Maximets Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- lib/dpif-netdev-private-thread.h | 2 +- lib/dpif-netdev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h index 020047ea68d4..4472b199d5c8 100644 --- a/lib/dpif-netdev-private-thread.h +++ b/lib/dpif-netdev-private-thread.h @@ -83,7 +83,7 @@ struct dp_netdev_pmd_thread { * instance for cpu core NON_PMD_CORE_ID can be accessed by multiple * threads, and thusly need to be protected by 'non_pmd_mutex'. Every * other instance will only be accessed by its own pmd thread. */ - OVS_ALIGNED_VAR(CACHE_LINE_SIZE) struct dfc_cache flow_cache; + struct dfc_cache flow_cache; /* Flow-Table and classifiers * diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 45435fdec9e5..0e8e8d28d478 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -273,7 +273,7 @@ struct dp_netdev { struct cmap meters OVS_GUARDED; /* Probability of EMC insertions is a factor of 'emc_insert_min'.*/ - OVS_ALIGNED_VAR(CACHE_LINE_SIZE) atomic_uint32_t emc_insert_min; + atomic_uint32_t emc_insert_min; /* Enable collection of PMD performance metrics. */ atomic_bool pmd_perf_metrics; /* Enable the SMC cache from ovsdb config */ From patchwork Mon Jan 24 14:17:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Skb7xdOZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBsq306zz9t4b for ; Tue, 25 Jan 2022 01:18:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 484F984B77; Mon, 24 Jan 2022 14:18:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id peLvmnp4VEr5; Mon, 24 Jan 2022 14:18:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id C150F84B79; Mon, 24 Jan 2022 14:18:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 930CDC0039; Mon, 24 Jan 2022 14:18:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3E7B2C002F for ; Mon, 24 Jan 2022 14:18:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8ADA440469 for ; Mon, 24 Jan 2022 14:18:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 l_PPEBvfriyf for ; Mon, 24 Jan 2022 14:18:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id E326B40504 for ; Mon, 24 Jan 2022 14:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033882; 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: in-reply-to:in-reply-to:references:references; bh=cT8TgBS7H8MTaqN7rvdFyzs36svFZuGH1+7t7uU//Bo=; b=Skb7xdOZYYSJKoA+lp3vSsk0m5nQY0eP0np+K1MCEjLpJRjzK3S1zy6vQw45j7Gz2qaodb BuoNqmJnhmCXK99/ykXjnoMqml4kYUGM6LxSXBmVZGSHAly8zKtj5/MxrylXQEpg4TfsrT 7zw61lqFbOUf9ngKtBw2kZyopH3+1iw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-IPepm5lLNh6brnsDnjRTsw-1; Mon, 24 Jan 2022 09:17:58 -0500 X-MC-Unique: IPepm5lLNh6brnsDnjRTsw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5DF7100C66B; Mon, 24 Jan 2022 14:17:57 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DFC77B6F4; Mon, 24 Jan 2022 14:17:56 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:17:53 +0100 Message-Id: <20220124141750.11777.67888.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 03/14] stopwatch: Fix buffer underflow when computing percentiles. 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" UB Sanitizer report: lib/stopwatch.c:119:22: runtime error: index 18446744073709551615 out of bounds for type 'long long unsigned int [50]' #0 0x698358 in calc_percentile lib/stopwatch.c:119 #1 0x69ada1 in add_sample lib/stopwatch.c:231 #2 0x69c086 in stopwatch_end_sample_protected lib/stopwatch.c:386 #3 0x69c522 in stopwatch_thread lib/stopwatch.c:441 #4 0x684bae in ovsthread_wrapper lib/ovs-thread.c:383 #5 0x7f042838b298 in start_thread (/lib64/libpthread.so.0+0x9298) #6 0x7f04277f2352 in clone (/lib64/libc.so.6+0x100352) Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- v3: Added Aaron's ack. --- lib/stopwatch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/stopwatch.c b/lib/stopwatch.c index f5602163bc16..1c71df1a127e 100644 --- a/lib/stopwatch.c +++ b/lib/stopwatch.c @@ -114,7 +114,6 @@ static void calc_percentile(unsigned long long n_samples, struct percentile *pctl, unsigned long long new_sample) { - if (n_samples < P_SQUARE_MIN) { pctl->samples[n_samples - 1] = new_sample; } @@ -228,13 +227,12 @@ add_sample(struct stopwatch *sw, unsigned long long new_sample) sw->min = new_sample; } - calc_percentile(sw->n_samples, &sw->pctl, new_sample); - if (sw->n_samples++ == 0) { sw->short_term.average = sw->long_term.average = new_sample; return; } + calc_percentile(sw->n_samples, &sw->pctl, new_sample); calc_average(&sw->short_term, new_sample); calc_average(&sw->long_term, new_sample); } From patchwork Mon Jan 24 14:18:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=hpGh4ZCp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBvV0PHvz9t5m for ; Tue, 25 Jan 2022 01:19:49 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B53B640919; Mon, 24 Jan 2022 14:19:47 +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 uwiWEoM3cnV5; Mon, 24 Jan 2022 14:19:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 52ECB408CA; Mon, 24 Jan 2022 14:19:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 25979C0072; Mon, 24 Jan 2022 14:19:45 +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 4E518C0072 for ; Mon, 24 Jan 2022 14:19:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9CF7660E8D for ; Mon, 24 Jan 2022 14:19:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id huzjSRN63LMT for ; Mon, 24 Jan 2022 14:19:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id D2E1B600C9 for ; Mon, 24 Jan 2022 14:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033969; 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: in-reply-to:in-reply-to:references:references; bh=1Spko/u7+X9SWgHZdg3HFN7jv9UjZ1yc6rXc8e1qeAE=; b=hpGh4ZCpEoT4VKjcf+svWhKIxplNtym3/KetDyUIG/rBCrfbdwCj9ahhkkUavbsMxfmXR+ 2FApZyGqB49Pd1Nztkz02aPufsHKBHSbJB41FEUpqy+F8FREu/UaHaF9C2epyUUBay9/8Q lrKgRFwl3kGvbKYtApSth5IJvHwGYZA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-130-LhXNDQQcPVG5zw0NmzFAmg-1; Mon, 24 Jan 2022 09:18:13 -0500 X-MC-Unique: LhXNDQQcPVG5zw0NmzFAmg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC26D1923B92; Mon, 24 Jan 2022 14:18:11 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF12E7B6F1; Mon, 24 Jan 2022 14:18:10 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:18:07 +0100 Message-Id: <20220124141803.11777.57730.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 04/14] treewide: Fix invalid bit shift operations. 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" UB Sanitizer reports: tests/test-hash.c:59:40: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int' #0 0x44c3c9 in get_range128 tests/test-hash.c:59 #1 0x44cb2e in check_hash_bytes128 tests/test-hash.c:178 #2 0x44d14d in test_hash_main tests/test-hash.c:282 [...] ofproto/ofproto-dpif-xlate.c:5607:45: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int' #0 0x53fe9f in xlate_sample_action ofproto/ofproto-dpif-xlate.c:5607 #1 0x54d625 in do_xlate_actions ofproto/ofproto-dpif-xlate.c:7160 #2 0x553b76 in xlate_actions ofproto/ofproto-dpif-xlate.c:7806 #3 0x4fcb49 in upcall_xlate ofproto/ofproto-dpif-upcall.c:1237 #4 0x4fe02f in process_upcall ofproto/ofproto-dpif-upcall.c:1456 #5 0x4fda99 in upcall_cb ofproto/ofproto-dpif-upcall.c:1358 [...] tests/test-util.c:89:23: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' #0 0x476415 in test_ctz tests/test-util.c:89 [...] lib/dpif-netlink.c:396:33: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' #0 0x571b9f in dpif_netlink_open lib/dpif-netlink.c:396 Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- v3: Added Aaron's ack. --- lib/dpif-netlink.c | 2 +- ofproto/ofproto-dpif-xlate.c | 3 ++- tests/test-hash.c | 2 +- tests/test-util.c | 13 ++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 71e35ccddaae..06e1e8ca0283 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -85,7 +85,7 @@ enum { MAX_PORTS = USHRT_MAX }; #define EPOLLEXCLUSIVE (1u << 28) #endif -#define OVS_DP_F_UNSUPPORTED (1 << 31); +#define OVS_DP_F_UNSUPPORTED (1u << 31); /* This PID is not used by the kernel datapath when using dispatch per CPU, * but it is required to be set (not zero). */ diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 6fb59e1702ec..d2b26f8ee27d 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5618,7 +5618,8 @@ xlate_sample_action(struct xlate_ctx *ctx, /* Scale the probability from 16-bit to 32-bit while representing * the same percentage. */ - uint32_t probability = (os->probability << 16) | os->probability; + uint32_t probability = + ((uint32_t) os->probability << 16) | os->probability; /* If ofp_port in flow sample action is equel to ofp_port, * this sample action is a input port action. */ diff --git a/tests/test-hash.c b/tests/test-hash.c index 5d3f8ea43f65..7c33922e3f02 100644 --- a/tests/test-hash.c +++ b/tests/test-hash.c @@ -174,7 +174,7 @@ check_hash_bytes128(void (*hash)(const void *, size_t, uint32_t, ovs_u128 *), set_bit128(&in2, j, n_bits); hash(&in2, sizeof(ovs_u128), 0, &out2); - for (ofs = 0; ofs < 128 - min_unique; ofs++) { + for (ofs = 1; ofs < 128 - min_unique; ofs++) { uint64_t bits1 = get_range128(&out1, ofs, unique_mask); uint64_t bits2 = get_range128(&out2, ofs, unique_mask); diff --git a/tests/test-util.c b/tests/test-util.c index f0fd0421086b..7d899fbbfd92 100644 --- a/tests/test-util.c +++ b/tests/test-util.c @@ -43,17 +43,16 @@ check_log_2_floor(uint32_t x, int n) static void test_log_2_floor(struct ovs_cmdl_context *ctx OVS_UNUSED) { - int n; - - for (n = 0; n < 32; n++) { + for (uint32_t n = 0; n < 32; n++) { /* Check minimum x such that f(x) == n. */ - check_log_2_floor(1 << n, n); + check_log_2_floor(UINT32_C(1) << n, n); /* Check maximum x such that f(x) == n. */ - check_log_2_floor((1 << n) | ((1 << n) - 1), n); + check_log_2_floor((UINT32_C(1) << n) | ((UINT32_C(1) << n) - 1), n); /* Check a random value in the middle. */ - check_log_2_floor((random_uint32() & ((1 << n) - 1)) | (1 << n), n); + check_log_2_floor((random_uint32() & ((UINT32_C(1) << n) - 1)) + | (UINT32_C(1) << n), n); } /* log_2_floor(0) is undefined, so don't check it. */ @@ -86,7 +85,7 @@ test_ctz(struct ovs_cmdl_context *ctx OVS_UNUSED) for (n = 0; n < 32; n++) { /* Check minimum x such that f(x) == n. */ - check_ctz32(1 << n, n); + check_ctz32(UINT32_C(1) << n, n); /* Check maximum x such that f(x) == n. */ check_ctz32(UINT32_MAX << n, n); From patchwork Mon Jan 24 14:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=d4Pv4c2h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBtX6rYLz9t4b for ; Tue, 25 Jan 2022 01:19:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6A6A960E76; Mon, 24 Jan 2022 14:18:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iC2uCuTAlB-I; Mon, 24 Jan 2022 14:18:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id ADE7360AAA; Mon, 24 Jan 2022 14:18:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8D31EC0072; Mon, 24 Jan 2022 14:18:56 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6BD11C002F for ; Mon, 24 Jan 2022 14:18:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 75A3D402C1 for ; Mon, 24 Jan 2022 14:18:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 CBOJQbDrasEP for ; Mon, 24 Jan 2022 14:18:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id D1D8F40295 for ; Mon, 24 Jan 2022 14:18:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033910; 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: in-reply-to:in-reply-to:references:references; bh=CTl28Ik88MbLC5scKbI2xM+IPebsR6bCC8y9l7R9sdc=; b=d4Pv4c2hd8YCumxnplwFtI1AnGm3Ytx/ethegGB7jFP0OMk7dMX/ZCtJkE69UYSUdNHMx9 xTUHw2HH3pL9vSik8h8fD9CQTWyDEAYYsJNr9vOr5sVekhZx6iLdMqKZaRATCqsgzH+hhX raL8MvUkwEFwHxFpvA0TYjGleU3xxh0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-bWtWUvHmMO2MCF7yE4K1eQ-1; Mon, 24 Jan 2022 09:18:25 -0500 X-MC-Unique: bWtWUvHmMO2MCF7yE4K1eQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CCDF5109D; Mon, 24 Jan 2022 14:18:24 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9833523760; Mon, 24 Jan 2022 14:18:22 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:18:19 +0100 Message-Id: <20220124141817.11777.10339.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 05/14] ovsdb-idlc: Avoid accessing member within NULL idl index cursors. 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" Reported by UndefinedBehaviorSanitizer: tests/idltest.c:3602:12: runtime error: member access within null pointer of type 'const struct idltest_simple' #0 0x4295af in idltest_simple_cursor_first_ge tests/idltest.c:3602 #1 0x41c81b in test_idl_compound_index_single_column tests/test-ovsdb.c:3128 #2 0x41e035 in do_idl_compound_index tests/test-ovsdb.c:3277 #3 0x4cf640 in ovs_cmdl_run_command__ lib/command-line.c:247 #4 0x4cf79f in ovs_cmdl_run_command lib/command-line.c:278 #5 0x4072f7 in main tests/test-ovsdb.c:79 #6 0x7fa858675b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) #7 0x4060ed in _start (/root/ovs/tests/test-ovsdb+0x4060ed) Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- v3: Added Aaron's ack. --- ovsdb/ovsdb-idlc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 5a02c8f936a0..10a70ae26f96 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -1292,7 +1292,7 @@ struct ovsdb_idl_cursor struct ovsdb_idl_index *index, const struct %(s)s *target) { ovs_assert(index->table->class_ == &%(p)stable_%(tl)s); - return ovsdb_idl_cursor_first_ge(index, &target->header_); + return ovsdb_idl_cursor_first_ge(index, target ? &target->header_ : NULL); } struct %(s)s * From patchwork Mon Jan 24 14:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=XBq/6uX/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBtd3F9Xz9t4b for ; Tue, 25 Jan 2022 01:19:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D86C940905; Mon, 24 Jan 2022 14:19:02 +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 SmNxPsMwFkXO; Mon, 24 Jan 2022 14:19:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6B528408CA; Mon, 24 Jan 2022 14:19:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3F982C0072; Mon, 24 Jan 2022 14:19:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 13A4EC0072 for ; Mon, 24 Jan 2022 14:18:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7F12281406 for ; Mon, 24 Jan 2022 14:18:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A6j7y3_kKQ1L for ; Mon, 24 Jan 2022 14:18:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 94565813EA for ; Mon, 24 Jan 2022 14:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033923; 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: in-reply-to:in-reply-to:references:references; bh=7EMwgO6uV3sqWw3L9RN3KNreJkClHyBSV86kmADhfdo=; b=XBq/6uX/j7+2FJKKm2BwMecn4i9oXSgOo5BI8pn9BD6q+vM+2Rdlw+8638G8PQHbHrVvpX Wr1/zTxlrOwiGA8HRPmYVOLIyNyDYBHJxypU2A4pJYA2Dr7LTI4eNaHLA5dYvGqrU58e7Y ybRgFGuBMIz5KYlxJ4bIjAD5TM9/IEE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-twea1v9_MU2pD-mIGfHGxQ-1; Mon, 24 Jan 2022 09:18:41 -0500 X-MC-Unique: twea1v9_MU2pD-mIGfHGxQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E613C84DA5A; Mon, 24 Jan 2022 14:18:40 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FAE21F41D; Mon, 24 Jan 2022 14:18:39 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:18:36 +0100 Message-Id: <20220124141829.11777.33273.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 06/14] bfd: lldp: stp: Fix misaligned packet field access. 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" UB Sanitizer reports: lib/bfd.c:748:16: runtime error: member access within misaligned address 0x000001f0d6ea for type 'struct msg', which requires 4 byte alignment 0x000001f0d6ea: note: pointer points here 00 20 00 00 20 40 03 18 93 f9 0a 6e 00 00 00 00 00 0f 42 40 00 0f 42 40 00 00 00 00 cc 00 00 00 ^ #0 0x59008e in bfd_process_packet lib/bfd.c:748 #1 0x52a240 in process_special ofproto/ofproto-dpif-xlate.c:3370 #2 0x553452 in xlate_actions ofproto/ofproto-dpif-xlate.c:7766 #3 0x4fc9e6 in upcall_xlate ofproto/ofproto-dpif-upcall.c:1237 #4 0x4fdecc in process_upcall ofproto/ofproto-dpif-upcall.c:1456 #5 0x4fd936 in upcall_cb ofproto/ofproto-dpif-upcall.c:1358 [...] lib/stp.c:754:15: runtime error: member access within misaligned address 0x000002c4ea61 for type 'const struct stp_bpdu_header', which requires 2 byte alignment 0x000002c4ea61: note: pointer points here 26 42 42 03 00 00 00 00 00 80 00 aa 66 aa 66 00 01 00 00 00 00 80 00 aa 66 aa 66 00 01 80 02 00 ^ #0 0x8a2bce in stp_received_bpdu lib/stp.c:754 #1 0x51e603 in stp_process_packet ofproto/ofproto-dpif-xlate.c:1788 #2 0x52a96d in process_special ofproto/ofproto-dpif-xlate.c:3394 #3 0x5534df in xlate_actions ofproto/ofproto-dpif-xlate.c:7766 #4 0x4fcb49 in upcall_xlate ofproto/ofproto-dpif-upcall.c:1237 [...] lib/lldp/lldp.c:149:10: runtime error: load of misaligned address 0x7ffcc0ae72bd for type 'ovs_be16', which requires 2 byte alignment 0x7ffcc0ae72bd: note: pointer points here 8e e7 84 ad 04 00 05 46 61 73 74 45 74 68 65 72 6e 65 74 20 31 2f 35 e0 91 07 c9 3e 7f 00 00 80 ^ #0 0x718d63 in lldp_tlv_end lib/lldp/lldp.c:149 #1 0x7191de in lldp_send lib/lldp/lldp.c:184 #2 0x484d6c in test_aa_send tests/test-aa.c:238 [...] Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara --- v3: Added Aaron's ack. --- lib/bfd.c | 51 ++++++++++++++++++++++++++++----------------------- lib/lldp/lldp.c | 4 +++- lib/stp.c | 16 ++++++++-------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/lib/bfd.c b/lib/bfd.c index 3c965699ace3..9698576d071b 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -131,16 +131,17 @@ enum diag { * | Required Min Echo RX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct msg { - uint8_t vers_diag; /* Version and diagnostic. */ - uint8_t flags; /* 2bit State field followed by flags. */ - uint8_t mult; /* Fault detection multiplier. */ - uint8_t length; /* Length of this BFD message. */ - ovs_be32 my_disc; /* My discriminator. */ - ovs_be32 your_disc; /* Your discriminator. */ - ovs_be32 min_tx; /* Desired minimum tx interval. */ - ovs_be32 min_rx; /* Required minimum rx interval. */ - ovs_be32 min_rx_echo; /* Required minimum echo rx interval. */ + uint8_t vers_diag; /* Version and diagnostic. */ + uint8_t flags; /* 2bit State field followed by flags. */ + uint8_t mult; /* Fault detection multiplier. */ + uint8_t length; /* Length of this BFD message. */ + ovs_16aligned_be32 my_disc; /* My discriminator. */ + ovs_16aligned_be32 your_disc; /* Your discriminator. */ + ovs_16aligned_be32 min_tx; /* Desired minimum tx interval. */ + ovs_16aligned_be32 min_rx; /* Required minimum rx interval. */ + ovs_16aligned_be32 min_rx_echo; /* Required minimum echo rx interval. */ }; + BUILD_ASSERT_DECL(BFD_PACKET_LEN == sizeof(struct msg)); #define DIAG_MASK 0x1f @@ -634,9 +635,9 @@ bfd_put_packet(struct bfd *bfd, struct dp_packet *p, msg->mult = bfd->mult; msg->length = BFD_PACKET_LEN; - msg->my_disc = htonl(bfd->disc); - msg->your_disc = htonl(bfd->rmt_disc); - msg->min_rx_echo = htonl(0); + put_16aligned_be32(&msg->my_disc, htonl(bfd->disc)); + put_16aligned_be32(&msg->your_disc, htonl(bfd->rmt_disc)); + put_16aligned_be32(&msg->min_rx_echo, htonl(0)); if (bfd_in_poll(bfd)) { min_tx = bfd->poll_min_tx; @@ -646,8 +647,8 @@ bfd_put_packet(struct bfd *bfd, struct dp_packet *p, min_rx = bfd->min_rx; } - msg->min_tx = htonl(min_tx * 1000); - msg->min_rx = htonl(min_rx * 1000); + put_16aligned_be32(&msg->min_tx, htonl(min_tx * 1000)); + put_16aligned_be32(&msg->min_rx, htonl(min_rx * 1000)); bfd->flags &= ~FLAG_FINAL; *oam = bfd->oam; @@ -781,12 +782,12 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow, goto out; } - if (!msg->my_disc) { + if (!get_16aligned_be32(&msg->my_disc)) { log_msg(VLL_WARN, msg, "NULL my_disc", bfd); goto out; } - pkt_your_disc = ntohl(msg->your_disc); + pkt_your_disc = ntohl(get_16aligned_be32(&msg->your_disc)); if (pkt_your_disc) { /* Technically, we should use the your discriminator field to figure * out which 'struct bfd' this packet is destined towards. That way a @@ -806,7 +807,7 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow, bfd_status_changed(bfd); } - bfd->rmt_disc = ntohl(msg->my_disc); + bfd->rmt_disc = ntohl(get_16aligned_be32(&msg->my_disc)); bfd->rmt_state = rmt_state; bfd->rmt_flags = flags; bfd->rmt_diag = msg->vers_diag & DIAG_MASK; @@ -834,7 +835,7 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow, bfd->rmt_mult = msg->mult; } - rmt_min_rx = MAX(ntohl(msg->min_rx) / 1000, 1); + rmt_min_rx = MAX(ntohl(get_16aligned_be32(&msg->min_rx)) / 1000, 1); if (bfd->rmt_min_rx != rmt_min_rx) { bfd->rmt_min_rx = rmt_min_rx; if (bfd->next_tx) { @@ -843,7 +844,7 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow, log_msg(VLL_INFO, msg, "New remote min_rx", bfd); } - bfd->rmt_min_tx = MAX(ntohl(msg->min_tx) / 1000, 1); + bfd->rmt_min_tx = MAX(ntohl(get_16aligned_be32(&msg->min_tx)) / 1000, 1); bfd->detect_time = bfd_rx_interval(bfd) * bfd->rmt_mult + time_msec(); if (bfd->state == STATE_ADMIN_DOWN) { @@ -1105,10 +1106,14 @@ log_msg(enum vlog_level level, const struct msg *p, const char *message, bfd_diag_str(p->vers_diag & DIAG_MASK), bfd_state_str(p->flags & STATE_MASK), p->mult, p->length, bfd_flag_str(p->flags & FLAGS_MASK), - ntohl(p->my_disc), ntohl(p->your_disc), - ntohl(p->min_tx), ntohl(p->min_tx) / 1000, - ntohl(p->min_rx), ntohl(p->min_rx) / 1000, - ntohl(p->min_rx_echo), ntohl(p->min_rx_echo) / 1000); + ntohl(get_16aligned_be32(&p->my_disc)), + ntohl(get_16aligned_be32(&p->your_disc)), + ntohl(get_16aligned_be32(&p->min_tx)), + ntohl(get_16aligned_be32(&p->min_tx)) / 1000, + ntohl(get_16aligned_be32(&p->min_rx)), + ntohl(get_16aligned_be32(&p->min_rx)) / 1000, + ntohl(get_16aligned_be32(&p->min_rx_echo)), + ntohl(get_16aligned_be32(&p->min_rx_echo)) / 1000); bfd_put_details(&ds, bfd); VLOG(level, "%s", ds_cstr(&ds)); ds_destroy(&ds); diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c index 18afbab9a7fe..dfeb2a800244 100644 --- a/lib/lldp/lldp.c +++ b/lib/lldp/lldp.c @@ -146,7 +146,9 @@ static void lldp_tlv_end(struct dp_packet *p, unsigned int start) { ovs_be16 *tlv = dp_packet_at_assert(p, start, 2); - *tlv |= htons((dp_packet_size(p) - (start + 2)) & 0x1ff); + put_unaligned_be16(tlv, + get_unaligned_be16(tlv) + | htons((dp_packet_size(p) - (start + 2)) & 0x1ff)); } int diff --git a/lib/stp.c b/lib/stp.c index 809b405a5298..a869b5f390ce 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -737,7 +737,7 @@ void stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size) { struct stp *stp = p->stp; - const struct stp_bpdu_header *header; + struct stp_bpdu_header header; ovs_mutex_lock(&mutex); if (p->state == STP_DISABLED) { @@ -750,19 +750,19 @@ stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size) goto out; } - header = bpdu; - if (header->protocol_id != htons(STP_PROTOCOL_ID)) { + memcpy(&header, bpdu, sizeof header); + if (header.protocol_id != htons(STP_PROTOCOL_ID)) { VLOG_WARN("%s: received BPDU with unexpected protocol ID %"PRIu16, - stp->name, ntohs(header->protocol_id)); + stp->name, ntohs(header.protocol_id)); p->error_count++; goto out; } - if (header->protocol_version != STP_PROTOCOL_VERSION) { + if (header.protocol_version != STP_PROTOCOL_VERSION) { VLOG_DBG("%s: received BPDU with unexpected protocol version %"PRIu8, - stp->name, header->protocol_version); + stp->name, header.protocol_version); } - switch (header->bpdu_type) { + switch (header.bpdu_type) { case STP_TYPE_CONFIG: if (bpdu_size < sizeof(struct stp_config_bpdu)) { VLOG_WARN("%s: received config BPDU with invalid size %"PRIuSIZE, @@ -785,7 +785,7 @@ stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size) default: VLOG_WARN("%s: received BPDU of unexpected type %"PRIu8, - stp->name, header->bpdu_type); + stp->name, header.bpdu_type); p->error_count++; goto out; } From patchwork Mon Jan 24 14:18:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=gRBXgKnv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBtn36z5z9t4b for ; Tue, 25 Jan 2022 01:19:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 37E7C84B4F; Mon, 24 Jan 2022 14:19:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e9ywVjvAg7Dv; Mon, 24 Jan 2022 14:19:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7621A84B4B; Mon, 24 Jan 2022 14:19:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 57EAFC0072; Mon, 24 Jan 2022 14:19:09 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2E96EC007A for ; Mon, 24 Jan 2022 14:19:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6D62F40289 for ; Mon, 24 Jan 2022 14:19:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 ydjWlaTSTeJa for ; Mon, 24 Jan 2022 14:18:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id BA8BD401D4 for ; Mon, 24 Jan 2022 14:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033938; 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: in-reply-to:in-reply-to:references:references; bh=Sh7zQEnJVQJKNl4LRcjrNaKa+SUWcSXORLUhNWY7kb4=; b=gRBXgKnvXRwBGMVHvDI1o64zlsr+mTmSbTutOIhJfztNOihEOeJOOrg0AAsfR8qchgSla0 B7tlM0Irj2pPHKrkilgxZuoYJMSyVKiZLRU0wwMydf+ylWQwp300NgcjswobKEaGcXeMuO qh+Kgbm8wMaHIXZxyCXcXmvNpjgD6oQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-dxJDw6hHPMaMD3oxY1C9gQ-1; Mon, 24 Jan 2022 09:18:55 -0500 X-MC-Unique: dxJDw6hHPMaMD3oxY1C9gQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8915118A0F38; Mon, 24 Jan 2022 14:18:54 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D21884A0A; Mon, 24 Jan 2022 14:18:53 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:18:50 +0100 Message-Id: <20220124141846.11777.65633.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 07/14] dp-packet: Ensure packet base is always non-NULL. 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" UB Sanitizer report: lib/dp-packet.h:297:39: runtime error: applying zero offset to null pointer #0 0x7946f5 in dp_packet_tail /root/ovs/./lib/dp-packet.h:297:39 #1 0x794331 in dp_packet_tailroom /root/ovs/./lib/dp-packet.h:325:49 #2 0x7942a0 in dp_packet_prealloc_tailroom /root/ovs/lib/dp-packet.c:297:16 #3 0xc347cf in eth_compose /root/ovs/lib/packets.c:1061:5 [...] Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- v3: Implement Aaron's suggestion instead and fix dp_packet_prealloc_tailroom(). --- lib/dp-packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index 72f6d09ac7f3..35c72542a2ad 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -294,7 +294,7 @@ dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom) void dp_packet_prealloc_tailroom(struct dp_packet *b, size_t size) { - if (size > dp_packet_tailroom(b)) { + if ((size && !dp_packet_base(b)) || (size > dp_packet_tailroom(b))) { dp_packet_resize(b, dp_packet_headroom(b), MAX(size, 64)); } } From patchwork Mon Jan 24 14:19:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=T+kCljc8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBvf3Jv2z9t5m for ; Tue, 25 Jan 2022 01:19:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 93BE260EA0; Mon, 24 Jan 2022 14:19:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cqX6tNAX1l3D; Mon, 24 Jan 2022 14:19:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4AB2560E8A; Mon, 24 Jan 2022 14:19:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F16F9C0039; Mon, 24 Jan 2022 14:19:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 03ABFC0039 for ; Mon, 24 Jan 2022 14:19:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 423D640946 for ; Mon, 24 Jan 2022 14:19:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 JfmMnxHLFOcZ for ; Mon, 24 Jan 2022 14:19:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1A304416FD for ; Mon, 24 Jan 2022 14:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033955; 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: in-reply-to:in-reply-to:references:references; bh=7Br4Wkkb0tuq4SzBeKKkGk/HN6uWqH10bqCR1idm5hI=; b=T+kCljc8SoBpAdSwOf2ClbQMIwrFPFhtUplw+DpW7jV/qHnMBHtiyTZPABTVVfyGveA+J7 V7/VzkvnJSmaPtL1LCZzT9iXDJqxWUz4fEc8QewlhMeSXjdMhUe0HYvBckoNL9wNVjPm6o Ihmuz45dy43Z85wuXnC5SJlD1yz4GDY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-BA1YWxC6PjWxa9IpJ0xmgg-1; Mon, 24 Jan 2022 09:19:11 -0500 X-MC-Unique: BA1YWxC6PjWxa9IpJ0xmgg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D78D08144E3; Mon, 24 Jan 2022 14:19:10 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C1297B6ED; Mon, 24 Jan 2022 14:19:09 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:19:06 +0100 Message-Id: <20220124141859.11777.68499.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 08/14] treewide: Avoid offsetting NULL pointers. 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" This is undefined behavior and was reported by UB Sanitizer: lib/meta-flow.c:3445:16: runtime error: member access within null pointer of type 'struct vl_mf_field' #0 0x6aad0f in mf_get_vl_mff lib/meta-flow.c:3445 #1 0x6d96d7 in mf_from_oxm_header lib/nx-match.c:260 #2 0x6d9e2e in nx_pull_header__ lib/nx-match.c:341 #3 0x6daafa in nx_pull_header lib/nx-match.c:488 #4 0x6abcb6 in mf_vl_mff_nx_pull_header lib/meta-flow.c:3605 #5 0x73b9be in decode_NXAST_RAW_REG_MOVE lib/ofp-actions.c:2652 #6 0x764ccd in ofpact_decode lib/ofp-actions.inc2:4681 [...] lib/sset.c:315:12: runtime error: applying zero offset to null pointer #0 0xcc2e6a in sset_at_position /root/ovs/lib/sset.c:315:12 #1 0x5734b3 in port_dump_next /root/ovs/ofproto/ofproto-dpif.c:4083:20 [...] lib/ovsdb-data.c:2194:56: runtime error: applying zero offset to null pointer #0 0x5e9530 in ovsdb_datum_added_removed /root/ovs/lib/ovsdb-data.c:2194:56 #1 0x4d6258 in update_row_ref_count /root/ovs/ovsdb/transaction.c:335:17 #2 0x4c360b in for_each_txn_row /root/ovs/ovsdb/transaction.c:1572:33 [...] lib/ofpbuf.c:440:30: runtime error: applying zero offset to null pointer #0 0x75066d in ofpbuf_push_uninit lib/ofpbuf.c:440 #1 0x46ac8a in ovnacts_parse lib/actions.c:4190 #2 0x46ad91 in ovnacts_parse_string lib/actions.c:4208 #3 0x4106d1 in test_parse_actions tests/test-ovn.c:1324 [...] lib/ofp-actions.c:3205:22: runtime error: applying non-zero offset 2 to null pointer #0 0x6e1641 in set_field_split_str /root/ovs/lib/ofp-actions.c:3205:22 [...] lib/tnl-ports.c:74:12: runtime error: applying zero offset to null pointer #0 0xceffe7 in tnl_port_cast /root/ovs/lib/tnl-ports.c:74:12 #1 0xcf14c3 in map_insert /root/ovs/lib/tnl-ports.c:116:13 [...] ofproto/ofproto.c:8905:16: runtime error: applying zero offset to null pointer #0 0x556795 in eviction_group_hash_rule /root/ovs/ofproto/ofproto.c:8905:16 #1 0x503f8d in eviction_group_add_rule /root/ovs/ofproto/ofproto.c:9022:42 [...] Also, it's valid to have an empty ofpact list and we should be able to try to iterate through it. UB Sanitizer report: include/openvswitch/ofp-actions.h:222:12: runtime error: applying zero offset to null pointer #0 0x665d69 in ofpact_end /root/ovs/./include/openvswitch/ofp-actions.h:222:12 #1 0x66b2cf in ofpacts_put_openflow_actions /root/ovs/lib/ofp-actions.c:8861:5 #2 0x6ffdd1 in ofputil_encode_flow_mod /root/ovs/lib/ofp-flow.c:447:9 [...] Signed-off-by: Dumitru Ceara --- include/openvswitch/ofp-actions.h | 4 +++- include/openvswitch/ofpbuf.h | 17 ++++++++++++----- lib/dynamic-string.c | 10 ++++++++-- lib/meta-flow.c | 4 +++- lib/ofp-actions.c | 8 ++++---- lib/ofpbuf.c | 4 ++++ lib/ovsdb-data.c | 37 +++++++++++++++++++++---------------- lib/ovsdb-data.h | 4 ++++ lib/sset.c | 4 +++- lib/tnl-ports.c | 2 +- ofproto/ofproto.c | 2 +- 11 files changed, 64 insertions(+), 32 deletions(-) diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index 41bcb55d2056..b7231c7bb334 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -218,7 +218,9 @@ struct ofpact *ofpact_next_flattened(const struct ofpact *); static inline struct ofpact * ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len) { - return ALIGNED_CAST(struct ofpact *, (uint8_t *) ofpacts + ofpacts_len); + return ofpacts + ? ALIGNED_CAST(struct ofpact *, (uint8_t *) ofpacts + ofpacts_len) + : NULL; } static inline bool diff --git a/include/openvswitch/ofpbuf.h b/include/openvswitch/ofpbuf.h index 1136ba04c84e..a9ff8a56e81c 100644 --- a/include/openvswitch/ofpbuf.h +++ b/include/openvswitch/ofpbuf.h @@ -179,7 +179,9 @@ static inline void ofpbuf_delete(struct ofpbuf *b) static inline void *ofpbuf_at(const struct ofpbuf *b, size_t offset, size_t size) { - return offset + size <= b->size ? (char *) b->data + offset : NULL; + return offset + size <= b->size && b->data + ? (char *) b->data + offset + : NULL; } /* Returns a pointer to byte 'offset' in 'b', which must contain at least @@ -188,20 +190,20 @@ static inline void *ofpbuf_at_assert(const struct ofpbuf *b, size_t offset, size_t size) { ovs_assert(offset + size <= b->size); - return ((char *) b->data) + offset; + return b->data ? (char *) b->data + offset : NULL; } /* Returns a pointer to byte following the last byte of data in use in 'b'. */ static inline void *ofpbuf_tail(const struct ofpbuf *b) { - return (char *) b->data + b->size; + return b->data ? (char *) b->data + b->size : NULL; } /* Returns a pointer to byte following the last byte allocated for use (but * not necessarily in use) in 'b'. */ static inline void *ofpbuf_end(const struct ofpbuf *b) { - return (char *) b->base + b->allocated; + return b->base ? (char *) b->base + b->allocated : NULL; } /* Returns the number of bytes of headroom in 'b', that is, the number of bytes @@ -249,6 +251,11 @@ static inline void *ofpbuf_pull(struct ofpbuf *b, size_t size) { ovs_assert(b->size >= size); void *data = b->data; + + if (!size) { + return data; + } + b->data = (char*)b->data + size; b->size = b->size - size; return data; @@ -270,7 +277,7 @@ static inline struct ofpbuf *ofpbuf_from_list(const struct ovs_list *list) static inline bool ofpbuf_equal(const struct ofpbuf *a, const struct ofpbuf *b) { return a->size == b->size && - memcmp(a->data, b->data, a->size) == 0; + (a->size == 0 || memcmp(a->data, b->data, a->size) == 0); } static inline bool ofpbuf_oversized(const struct ofpbuf *ofpacts) diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index fd0127ed1740..9b9a8f50e562 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -152,7 +152,10 @@ ds_put_format_valist(struct ds *ds, const char *format, va_list args_) va_copy(args, args_); available = ds->string ? ds->allocated - ds->length + 1 : 0; - needed = vsnprintf(&ds->string[ds->length], available, format, args); + needed = vsnprintf(ds->string + ? &ds->string[ds->length] + : NULL, + available, format, args); va_end(args); if (needed < available) { @@ -162,7 +165,10 @@ ds_put_format_valist(struct ds *ds, const char *format, va_list args_) va_copy(args, args_); available = ds->allocated - ds->length + 1; - needed = vsnprintf(&ds->string[ds->length], available, format, args); + needed = vsnprintf(ds->string + ? &ds->string[ds->length] + : NULL, + available, format, args); va_end(args); ovs_assert(needed < available); diff --git a/lib/meta-flow.c b/lib/meta-flow.c index e03cd8d0c5cd..c576ae6202a4 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -3442,7 +3442,9 @@ mf_get_vl_mff(const struct mf_field *mff, const struct vl_mff_map *vl_mff_map) { if (mff && mff->variable_len && vl_mff_map) { - return &mf_get_vl_mff__(mff->id, vl_mff_map)->mf; + struct vl_mf_field *vl_mff = mf_get_vl_mff__(mff->id, vl_mff_map); + + return vl_mff ? &vl_mff->mf : NULL; } return NULL; diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 006837c2e1f5..b24b46d2196b 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -3202,14 +3202,14 @@ set_field_split_str(char *arg, char **key, char **value, char **delim) *value = arg; value_end = strstr(arg, "->"); + if (!value_end) { + return xasprintf("%s: missing `->'", arg); + } + *key = value_end + strlen("->"); if (delim) { *delim = value_end; } - - if (!value_end) { - return xasprintf("%s: missing `->'", arg); - } if (strlen(value_end) <= strlen("->")) { return xasprintf("%s: missing field name following `->'", arg); } diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 271105bdea17..0330681b2518 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -436,6 +436,10 @@ ofpbuf_reserve(struct ofpbuf *b, size_t size) void * ofpbuf_push_uninit(struct ofpbuf *b, size_t size) { + if (!size) { + return b->data; + } + ofpbuf_prealloc_headroom(b, size); b->data = (char*)b->data - size; b->size += size; diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index 6b1c20ff85a0..306b8d0d946a 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1957,6 +1957,19 @@ ovsdb_datum_add_unsafe(struct ovsdb_datum *datum, } } +void +ovsdb_datum_add_unsafe_index(struct ovsdb_datum *dst, + const struct ovsdb_datum *src, + size_t idx, + const struct ovsdb_type *type) +{ + const union ovsdb_atom *key = &src->keys[idx]; + const union ovsdb_atom *value = type->value.type != OVSDB_TYPE_VOID + ? &src->values[idx] + : NULL; + ovsdb_datum_add_unsafe(dst, key, value, type, NULL); +} + /* Adds 'n' atoms starting from index 'start_idx' from 'src' to the end of * 'dst'. 'dst' should have enough memory allocated to hold the additional * 'n' atoms. Atoms are not cloned, i.e. 'dst' will reference the same data. @@ -2165,12 +2178,10 @@ ovsdb_datum_added_removed(struct ovsdb_datum *added, int c = ovsdb_atom_compare_3way(&old->keys[oi], &new->keys[ni], type->key.type); if (c < 0) { - ovsdb_datum_add_unsafe(removed, &old->keys[oi], &old->values[oi], - type, NULL); + ovsdb_datum_add_unsafe_index(removed, old, oi, type); oi++; } else if (c > 0) { - ovsdb_datum_add_unsafe(added, &new->keys[ni], &new->values[ni], - type, NULL); + ovsdb_datum_add_unsafe_index(added, new, ni, type); ni++; } else { if (type->value.type != OVSDB_TYPE_VOID && @@ -2186,13 +2197,11 @@ ovsdb_datum_added_removed(struct ovsdb_datum *added, } for (; oi < old->n; oi++) { - ovsdb_datum_add_unsafe(removed, &old->keys[oi], &old->values[oi], - type, NULL); + ovsdb_datum_add_unsafe_index(removed, old, oi, type); } for (; ni < new->n; ni++) { - ovsdb_datum_add_unsafe(added, &new->keys[ni], &new->values[ni], - type, NULL); + ovsdb_datum_add_unsafe_index(added, new, ni, type); } } @@ -2228,12 +2237,10 @@ ovsdb_datum_diff(struct ovsdb_datum *diff, int c = ovsdb_atom_compare_3way(&old->keys[oi], &new->keys[ni], type->key.type); if (c < 0) { - ovsdb_datum_add_unsafe(diff, &old->keys[oi], &old->values[oi], - type, NULL); + ovsdb_datum_add_unsafe_index(diff, old, oi, type); oi++; } else if (c > 0) { - ovsdb_datum_add_unsafe(diff, &new->keys[ni], &new->values[ni], - type, NULL); + ovsdb_datum_add_unsafe_index(diff, new, ni, type); ni++; } else { if (type->value.type != OVSDB_TYPE_VOID && @@ -2247,13 +2254,11 @@ ovsdb_datum_diff(struct ovsdb_datum *diff, } for (; oi < old->n; oi++) { - ovsdb_datum_add_unsafe(diff, &old->keys[oi], &old->values[oi], - type, NULL); + ovsdb_datum_add_unsafe_index(diff, old, oi, type); } for (; ni < new->n; ni++) { - ovsdb_datum_add_unsafe(diff, &new->keys[ni], &new->values[ni], - type, NULL); + ovsdb_datum_add_unsafe_index(diff, new, ni, type); } } diff --git a/lib/ovsdb-data.h b/lib/ovsdb-data.h index 47115a7b85b7..31c7c27e6b93 100644 --- a/lib/ovsdb-data.h +++ b/lib/ovsdb-data.h @@ -280,6 +280,10 @@ void ovsdb_datum_add_unsafe(struct ovsdb_datum *, const union ovsdb_atom *value, const struct ovsdb_type *, const union ovsdb_atom *range_end_atom); +void ovsdb_datum_add_unsafe_index(struct ovsdb_datum *dst, + const struct ovsdb_datum *src, + size_t idx, + const struct ovsdb_type *type); /* Transactions with named-uuid row names. */ struct json *ovsdb_datum_to_json_with_row_names(const struct ovsdb_datum *, diff --git a/lib/sset.c b/lib/sset.c index b2e3f43ec91b..b18b948fa4e7 100644 --- a/lib/sset.c +++ b/lib/sset.c @@ -312,7 +312,9 @@ sset_at_position(const struct sset *set, struct sset_position *pos) struct hmap_node *hmap_node; hmap_node = hmap_at_position(&set->map, &pos->pos); - return SSET_NODE_FROM_HMAP_NODE(hmap_node); + return hmap_node + ? SSET_NODE_FROM_HMAP_NODE(hmap_node) + : NULL; } /* Replaces 'a' by the intersection of 'a' and 'b'. That is, removes from 'a' diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c index 58269d3b1631..dd3320ccbb96 100644 --- a/lib/tnl-ports.c +++ b/lib/tnl-ports.c @@ -71,7 +71,7 @@ tnl_port_cast(const struct cls_rule *cr) { BUILD_ASSERT_DECL(offsetof(struct tnl_port_in, cr) == 0); - return CONTAINER_OF(cr, struct tnl_port_in, cr); + return cr ? CONTAINER_OF(cr, struct tnl_port_in, cr) : NULL; } static void diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 56aeac720935..c3ffbbb13b5b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -8902,7 +8902,7 @@ eviction_group_hash_rule(struct rule *rule) hash = table->eviction_group_id_basis; miniflow_expand(rule->cr.match.flow, &flow); for (sf = table->eviction_fields; - sf < &table->eviction_fields[table->n_eviction_fields]; + sf && sf < &table->eviction_fields[table->n_eviction_fields]; sf++) { if (mf_are_prereqs_ok(sf->field, &flow, NULL)) { From patchwork Mon Jan 24 14:19:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=ICx2h+MZ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBw34QFnz9tT8 for ; Tue, 25 Jan 2022 01:20:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6B5EC41719; Mon, 24 Jan 2022 14:20:17 +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 W6L5DQpGzhEh; Mon, 24 Jan 2022 14:20:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 81C1C403B8; Mon, 24 Jan 2022 14:20:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 37A1EC0072; Mon, 24 Jan 2022 14:20:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 75016C002F for ; Mon, 24 Jan 2022 14:20:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6A5A5415CE for ; Mon, 24 Jan 2022 14:19:31 +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 Vi2U2ha8ykEY for ; Mon, 24 Jan 2022 14:19:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id AD51341515 for ; Mon, 24 Jan 2022 14:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033969; 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: in-reply-to:in-reply-to:references:references; bh=+UvvXUp3Ge+oRfbg/DKynX7N5umb2dZmSlTvBegb/i8=; b=ICx2h+MZdnEgV6yKnOCWBuvzSaymJIqSwWEZ5LR71Lyb0YVPG19HQub5K4hb+3Xv/72Yr7 wURJ+QZema+DZNRrl2njAP3elTPRgeS/wQZj+zDeeb0IP8erqrv+QdtOONzz7DqG9B1+a/ OFsEpEAAaUUSZdjwZXNdCKWrkkL9Cjo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-BrZaFt8BOpeMCKvaO2TrLw-1; Mon, 24 Jan 2022 09:19:26 -0500 X-MC-Unique: BrZaFt8BOpeMCKvaO2TrLw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B53511091DA4; Mon, 24 Jan 2022 14:19:25 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F0C0798A8; Mon, 24 Jan 2022 14:19:24 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:19:21 +0100 Message-Id: <20220124141916.11777.50034.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 09/14] ofp-actions: Ensure aligned accesses when setting masked fields. 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" For example is parsing the OVN "eth.dst[40] = 1;" action, which triggered the following warning from UndefinedBehaviorSanitizer: lib/meta-flow.c:3210:9: runtime error: member access within misaligned address 0x000000de4e36 for type 'const union mf_value', which requires 8 byte alignment 0x000000de4e36: note: pointer points here 00 00 00 00 01 00 00 00 00 00 00 00 00 00 70 4e de 00 00 00 00 00 10 51 de 00 00 00 00 00 c0 4f ^ #0 0x5818bc in mf_format lib/meta-flow.c:3210 #1 0x5b6047 in format_SET_FIELD lib/ofp-actions.c:3342 #2 0x5d68ab in ofpact_format lib/ofp-actions.c:9213 #3 0x5d6ee0 in ofpacts_format lib/ofp-actions.c:9237 #4 0x410922 in test_parse_actions tests/test-ovn.c:1360 Signed-off-by: Dumitru Ceara --- v3: Split out from old patch 07/11. --- include/openvswitch/util.h | 3 +++ lib/meta-flow.c | 6 ++++++ lib/nx-match.c | 7 +++++++ ofproto/ofproto-dpif-xlate.c | 13 +++++++++---- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h index 228b185c3a5f..f45dc505164c 100644 --- a/include/openvswitch/util.h +++ b/include/openvswitch/util.h @@ -285,6 +285,9 @@ is_pow2(uintmax_t x) * segfault, so it is important to be aware of correct alignment. */ #define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR)) +#define IS_PTR_ALIGNED(OBJ) \ + (!(OBJ) || (uintptr_t) (OBJ) % __alignof__(OVS_TYPEOF(OBJ)) == 0) + #ifdef __cplusplus } #endif diff --git a/lib/meta-flow.c b/lib/meta-flow.c index c576ae6202a4..2e64fed5f8f2 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -3172,6 +3172,8 @@ mf_format(const struct mf_field *mf, const struct ofputil_port_map *port_map, struct ds *s) { + union mf_value aligned_mask; + if (mask) { if (is_all_zeros(mask, mf->n_bytes)) { ds_put_cstr(s, "ANY"); @@ -3207,6 +3209,10 @@ mf_format(const struct mf_field *mf, break; case MFS_ETHERNET: + if (!IS_PTR_ALIGNED(mask)) { + memcpy(&aligned_mask.mac, mask, sizeof aligned_mask.mac); + mask = &aligned_mask; + } eth_format_masked(value->mac, mask ? &mask->mac : NULL, s); break; diff --git a/lib/nx-match.c b/lib/nx-match.c index 440f5f7630c9..6e87deffc0d0 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -31,6 +31,7 @@ #include "openvswitch/ofp-match.h" #include "openvswitch/ofp-port.h" #include "openvswitch/ofpbuf.h" +#include "openvswitch/util.h" #include "openvswitch/vlog.h" #include "packets.h" #include "openvswitch/shash.h" @@ -1491,9 +1492,15 @@ nx_put_entry(struct ofpbuf *b, const struct mf_field *mff, enum ofp_version version, const union mf_value *value, const union mf_value *mask) { + union mf_value aligned_mask; bool masked; int len, offset; + if (!IS_PTR_ALIGNED(mask)) { + memcpy(&aligned_mask, mask, mff->n_bytes); + mask = &aligned_mask; + } + len = mf_field_len(mff, value, mask, &masked); offset = mff->n_bytes - len; diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index d2b26f8ee27d..c5f339c86eac 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -7119,10 +7119,15 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, /* Set the field only if the packet actually has it. */ if (mf_are_prereqs_ok(mf, flow, wc)) { - mf_mask_field_masked(mf, ofpact_set_field_mask(set_field), wc); - mf_set_flow_value_masked(mf, set_field->value, - ofpact_set_field_mask(set_field), - flow); + union mf_value *mask = ofpact_set_field_mask(set_field); + union mf_value aligned_mask; + + if (!IS_PTR_ALIGNED(mask)) { + memcpy(&aligned_mask, mask, mf->n_bytes); + mask = &aligned_mask; + } + mf_mask_field_masked(mf, mask, wc); + mf_set_flow_value_masked(mf, set_field->value, mask, flow); } else { xlate_report(ctx, OFT_WARN, "unmet prerequisites for %s, set_field ignored", From patchwork Mon Jan 24 14:19:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=SKlmPN7m; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBwB3vkLz9tT8 for ; Tue, 25 Jan 2022 01:20:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D624141757; Mon, 24 Jan 2022 14:20:24 +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 AzbkCpfiSTkG; Mon, 24 Jan 2022 14:20:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 20AE54174D; Mon, 24 Jan 2022 14:20:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EA129C0039; Mon, 24 Jan 2022 14:20:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18011C0072 for ; Mon, 24 Jan 2022 14:20:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9542D41710 for ; Mon, 24 Jan 2022 14:19:47 +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 OIzZawaDZ0hD for ; Mon, 24 Jan 2022 14:19:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id ED3054171C for ; Mon, 24 Jan 2022 14:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643033986; 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: in-reply-to:in-reply-to:references:references; bh=yap7n6wWBkgSQ0H3J+SMQK8DRadsT5s+fbhuXY2l2hI=; b=SKlmPN7moUav0h/xivb93c1yD51zk+IcPQJ4vnEaT2C9hbdFmzpr4xa4E2zxLovWM/4XO/ hf4Z6bevQPzG0a3kjXni1LwPxD0Tly+xlJ1fxNQ5MX5CttgBlTuIlyBQAmyksdbsewY4rU 2h8oPLDA+qbZyX0H3+C7cvdjsvoW5KY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-s3z_r1iSP9-zc5Og1WUHBw-1; Mon, 24 Jan 2022 09:19:42 -0500 X-MC-Unique: s3z_r1iSP9-zc5Og1WUHBw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE23581424B; Mon, 24 Jan 2022 14:19:41 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 516947BB45; Mon, 24 Jan 2022 14:19:40 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:19:37 +0100 Message-Id: <20220124141930.11777.76283.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 10/14] ofp-errors: Ensure parsed OFPT_ERROR messages are properly aligned. 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" Trim the ofpbuf to ensure proper alignment. UB Sanitizer report: lib/ofp-print.c:1218:24: runtime error: member access within misaligned address 0x0000019229d2 for type 'const struct ofp_header', which requires 4 byte alignment 0x0000019229d2: note: pointer points here 00 00 5a 5a 05 22 00 3e 00 00 00 09 00 00 00 00 00 00 00 03 05 0d 00 2e 00 00 00 09 ff ff ff ff ^ #0 0x7d45cc in ofp_to_string lib/ofp-print.c:1218 #1 0x774fa8 in ofperr_msg_format lib/ofp-errors.c:253 #2 0x7d2617 in ofp_print_error_msg lib/ofp-print.c:435 #3 0x7d3eb7 in ofp_to_string__ lib/ofp-print.c:998 #4 0x7d47fb in ofp_to_string lib/ofp-print.c:1244 #5 0x8dcc4b in do_send lib/vconn.c:688 #6 0x8dca64 in vconn_send lib/vconn.c:671 Signed-off-by: Dumitru Ceara --- v3: Split out from old patch 07/11. --- lib/ofp-errors.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ofp-errors.c b/lib/ofp-errors.c index 35191abf16dd..eb099d355270 100644 --- a/lib/ofp-errors.c +++ b/lib/ofp-errors.c @@ -20,6 +20,7 @@ #include "openflow/openflow.h" #include "openflow/nicira-ext.h" #include "openvswitch/dynamic-string.h" +#include "openvswitch/ofp-actions.h" #include "openvswitch/ofp-errors.h" #include "openvswitch/ofp-msgs.h" #include "openvswitch/ofp-print.h" @@ -346,6 +347,7 @@ ofperr_decode_msg(const struct ofp_header *oh, struct ofpbuf *payload) if (error && payload) { ofpbuf_init(payload, b.size); ofpbuf_push(payload, b.data, b.size); + ofpbuf_trim(payload); } return error; } From patchwork Mon Jan 24 14:19:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Leiy2Mab; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBwy29F3z9t5m for ; Tue, 25 Jan 2022 01:21:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EAEE060EA4; Mon, 24 Jan 2022 14:21:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R-_gONFocXYD; Mon, 24 Jan 2022 14:21:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 02F5F60E85; Mon, 24 Jan 2022 14:21:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C2D8DC0039; Mon, 24 Jan 2022 14:21:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 492A5C0039 for ; Mon, 24 Jan 2022 14:21:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 68E8B41735 for ; Mon, 24 Jan 2022 14:20:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=redhat.com 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 sFpaCk0NCOzR for ; Mon, 24 Jan 2022 14:20:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 80E484172F for ; Mon, 24 Jan 2022 14:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643034007; 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: in-reply-to:in-reply-to:references:references; bh=F/0+79l2lC07ftWT1GCfKZgg3AqKsqVuCLMaEdd7UeI=; b=Leiy2MabUanUx1/1F0vWXT1PVLwjvFR+axMg48oacW6632XyoRl9b7fYKyR86impsLqhoG j4iU5xSlcQ2OEMP2EE2aihTzBRx/azpAqdxeaRRHihs+d9/szMFxT36KUns4zANRsecO4T UXDdP/I3y7HcR/5wL3hhj7vNpq+/dJE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-75OQKAT1PV64sI6OCeh6pg-1; Mon, 24 Jan 2022 09:20:03 -0500 X-MC-Unique: 75OQKAT1PV64sI6OCeh6pg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C395086A8AA; Mon, 24 Jan 2022 14:20:02 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70F89798A8; Mon, 24 Jan 2022 14:20:01 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:19:58 +0100 Message-Id: <20220124141946.11777.65639.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 11/14] ofp-actions: Use aligned structures when decoding ofp actions. 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" Some openflow actions can be misaligned, e.g., actions whithin OF 1.0 replies to statistics reply messages which have a header of 12 bytes and no additional padding. Also, buggy controllers might incorrectly encode actions. When decoding multiple actions in ofpacts_decode(), make sure that when advancing to the next action it will be properly aligned (multiple of OFPACT_ALIGNTO). Detected by UB Sanitizer when running one of the fuzz tests: lib/ofp-actions.c:5347:12: runtime error: member access within misaligned address 0x0000016ba274 for type 'const struct nx_action_learn', which requires 8 byte alignment 0x0000016ba274: note: pointer points here 20 20 20 20 ff ff 00 38 00 00 23 20 00 10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 00 03 20 00 ^ #0 0x52cece in decode_LEARN_common lib/ofp-actions.c:5347 #1 0x52dcf6 in decode_NXAST_RAW_LEARN lib/ofp-actions.c:5463 #2 0x548604 in ofpact_decode lib/ofp-actions.inc2:4723 #3 0x53ee43 in ofpacts_decode lib/ofp-actions.c:7781 #4 0x53efc1 in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7820 #5 0x5409e1 in ofpacts_pull_openflow_instructions lib/ofp-actions.c:8396 #6 0x5608a8 in ofputil_decode_flow_stats_reply lib/ofp-flow.c:1100 Signed-off-by: Dumitru Ceara --- v3: Split out from old patch 07/11. --- include/openvswitch/ofp-actions.h | 1 + include/openvswitch/ofpbuf.h | 2 + lib/ofp-actions.c | 71 +++++++++++++++++++++++++++++-------- lib/ofpbuf.c | 39 ++++++++++++++++++++ 4 files changed, 98 insertions(+), 15 deletions(-) diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index b7231c7bb334..0991a0177411 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -203,6 +203,7 @@ BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4); /* Alignment. */ #define OFPACT_ALIGNTO 8 #define OFPACT_ALIGN(SIZE) ROUND_UP(SIZE, OFPACT_ALIGNTO) +#define OFPACT_IS_ALIGNED(ADDR) ((uintptr_t) (ADDR) % OFPACT_ALIGNTO == 0) #define OFPACT_PADDED_MEMBERS(MEMBERS) PADDED_MEMBERS(OFPACT_ALIGNTO, MEMBERS) /* Returns the ofpact following 'ofpact'. */ diff --git a/include/openvswitch/ofpbuf.h b/include/openvswitch/ofpbuf.h index a9ff8a56e81c..d1ff7334896d 100644 --- a/include/openvswitch/ofpbuf.h +++ b/include/openvswitch/ofpbuf.h @@ -111,6 +111,7 @@ void ofpbuf_use_ds(struct ofpbuf *, const struct ds *); void ofpbuf_use_stack(struct ofpbuf *, void *, size_t); void ofpbuf_use_stub(struct ofpbuf *, void *, size_t); void ofpbuf_use_const(struct ofpbuf *, const void *, size_t); +void ofpbuf_use_data(struct ofpbuf *, const void *, size_t); void ofpbuf_init(struct ofpbuf *, size_t); void ofpbuf_uninit(struct ofpbuf *); @@ -149,6 +150,7 @@ static inline size_t ofpbuf_msgsize(const struct ofpbuf *); void ofpbuf_prealloc_headroom(struct ofpbuf *, size_t); void ofpbuf_prealloc_tailroom(struct ofpbuf *, size_t); void ofpbuf_trim(struct ofpbuf *); +void ofpbuf_align(struct ofpbuf *); void ofpbuf_padto(struct ofpbuf *, size_t); void ofpbuf_shift(struct ofpbuf *, int); diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index b24b46d2196b..b95c280eb92e 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -7759,45 +7759,86 @@ check_GOTO_TABLE(const struct ofpact_goto_table *a, static void log_bad_action(const struct ofp_action_header *actions, size_t actions_len, - const struct ofp_action_header *bad_action, enum ofperr error) + size_t action_offset, enum ofperr error) { if (!VLOG_DROP_WARN(&rl)) { struct ds s; ds_init(&s); ds_put_hex_dump(&s, actions, actions_len, 0, false); - VLOG_WARN("bad action at offset %#"PRIxPTR" (%s):\n%s", - (char *)bad_action - (char *)actions, + VLOG_WARN("bad action at offset %"PRIuSIZE" (%s):\n%s", action_offset, ofperr_get_name(error), ds_cstr(&s)); ds_destroy(&s); } } static enum ofperr -ofpacts_decode(const void *actions, size_t actions_len, - enum ofp_version ofp_version, - const struct vl_mff_map *vl_mff_map, - uint64_t *ofpacts_tlv_bitmap, struct ofpbuf *ofpacts) +ofpacts_decode_aligned(struct ofpbuf *openflow, enum ofp_version ofp_version, + const struct vl_mff_map *vl_mff_map, + uint64_t *ofpacts_tlv_bitmap, struct ofpbuf *ofpacts, + size_t *bad_action_offset) { - struct ofpbuf openflow = ofpbuf_const_initializer(actions, actions_len); - while (openflow.size) { - const struct ofp_action_header *action = openflow.data; + size_t decoded_len = 0; + enum ofperr error = 0; + + ovs_assert(OFPACT_IS_ALIGNED(openflow->data)); + while (openflow->size) { + /* Ensure the next action data is properly aligned before decoding it. + * Some times it's valid to have to decode actions that are not + * properly aligned (e.g., when processing OF 1.0 statistics reply + * messages which have a header of 12 bytes - struct ofp10_stats_msg). + * In other cases the encoder might be buggy. + */ + if (!OFPACT_IS_ALIGNED(openflow->data)) { + ofpbuf_align(openflow); + } + + const struct ofp_action_header *action = openflow->data; enum ofp_raw_action_type raw; - enum ofperr error; uint64_t arg; - error = ofpact_pull_raw(&openflow, ofp_version, &raw, &arg); + error = ofpact_pull_raw(openflow, ofp_version, &raw, &arg); if (!error) { error = ofpact_decode(action, raw, ofp_version, arg, vl_mff_map, ofpacts_tlv_bitmap, ofpacts); } if (error) { - log_bad_action(actions, actions_len, action, error); - return error; + *bad_action_offset = decoded_len; + goto done; } + decoded_len += openflow->size; } - return 0; + +done: + return error; +} + +static enum ofperr +ofpacts_decode(const void *actions, size_t actions_len, + enum ofp_version ofp_version, + const struct vl_mff_map *vl_mff_map, + uint64_t *ofpacts_tlv_bitmap, struct ofpbuf *ofpacts) +{ + size_t bad_action_offset = 0; + struct ofpbuf aligned_buf; + + if (!OFPACT_IS_ALIGNED(actions)) { + ofpbuf_init(&aligned_buf, actions_len); + ofpbuf_put(&aligned_buf, actions, actions_len); + } else { + ofpbuf_use_data(&aligned_buf, actions, actions_len); + } + + enum ofperr error + = ofpacts_decode_aligned(&aligned_buf, ofp_version, vl_mff_map, + ofpacts_tlv_bitmap, ofpacts, + &bad_action_offset); + if (error) { + log_bad_action(actions, actions_len, bad_action_offset, error); + } + ofpbuf_uninit(&aligned_buf); + return error; } static enum ofperr diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 0330681b2518..b79d89e71447 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -115,6 +115,24 @@ ofpbuf_use_const(struct ofpbuf *b, const void *data, size_t size) ofpbuf_use__(b, CONST_CAST(void *, data), size, size, OFPBUF_STACK); } +/* Initializes 'b' as an ofpbuf whose data starts at 'data' and continues for + * 'size' bytes. This is appropriate for an ofpbuf that will be mostly used to + * inspect existing data, however, if needed, data may be occasionally changed. + * + * The first time the data is changed the provided buffer will be copied into + * a malloc()'d buffer. Thus, it is wise to call ofpbuf_uninit() on an ofpbuf + * initialized by this function, so that if it expanded into the heap, that + * memory is freed. + * + * 'base' should be appropriately aligned. Using an array of uint32_t or + * uint64_t for the buffer is a reasonable way to ensure appropriate alignment + * for 32- or 64-bit data. */ +void +ofpbuf_use_data(struct ofpbuf *b, const void *data, size_t size) +{ + ofpbuf_use__(b, CONST_CAST(void *, data), size, size, OFPBUF_STUB); +} + /* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size' * bytes. */ void @@ -322,6 +340,27 @@ ofpbuf_trim(struct ofpbuf *b) } } +/* Re-aligns the buffer data. Relies on malloc() to ensure proper alignment. + * + * This function should not be called for buffers of type OFPBUF_STUB. + */ +void +ofpbuf_align(struct ofpbuf *b) +{ + switch (b->source) { + case OFPBUF_MALLOC: + case OFPBUF_STUB: + /* Resizing 'b' always reallocates the buffer, ensuring proper + * alignment. + */ + ofpbuf_resize__(b, 0, 0); + break; + case OFPBUF_STACK: + OVS_NOT_REACHED(); + break; + } +} + /* If 'b' is shorter than 'length' bytes, pads its tail out with zeros to that * length. */ void From patchwork Mon Jan 24 14:20:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=JMiK8q33; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBx742ckz9tT8 for ; Tue, 25 Jan 2022 01:21:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DD3E44179B; Mon, 24 Jan 2022 14:21:12 +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 FzO5x4seXXfz; Mon, 24 Jan 2022 14:21:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 21A494175B; Mon, 24 Jan 2022 14:21:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E66B4C0039; Mon, 24 Jan 2022 14:21:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11397C0039 for ; Mon, 24 Jan 2022 14:21:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id AEF2D40A4E for ; Mon, 24 Jan 2022 14:20:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 jR46vrnELeHO for ; Mon, 24 Jan 2022 14:20:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 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 8DB4340901 for ; Mon, 24 Jan 2022 14:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643034024; 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: in-reply-to:in-reply-to:references:references; bh=3OBH3s9prSY1ixlxQv68cdMgpoNLqul4fX/jpnwett0=; b=JMiK8q33krsYVvvHiTnHbRQe3r/LEUeAH24SuqG0nQjuNZZz8QWa622MstqnHDk2Zngoks dgMaYy2srrJPXP4q/AI3fO0iwxpfDUcDKRnxwMd+4zdIckqnwZVInxNCEX6eM6XsT9e69W oth6FX7isMQIohjFRJO+k0FTjvlz9kQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440-WLIEs8RlPBm-UIL04KJ1Pw-1; Mon, 24 Jan 2022 09:20:21 -0500 X-MC-Unique: WLIEs8RlPBm-UIL04KJ1Pw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 345A1100CCC1; Mon, 24 Jan 2022 14:20:20 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223BE7A54F; Mon, 24 Jan 2022 14:20:15 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:20:13 +0100 Message-Id: <20220124142008.11777.70393.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 12/14] util: Avoid false positive UB when iterating collections. 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" UB Sanitizer was flagging OBJECT_CONTAINING() as undefined behavior due to the way it's used when iterating through collections, e.g., HMAP_FOR_EACH_INIT(). However, in such cases we don't actually dereference the pointer, we just use its value. Avoid the undefined behavior by casting to 'void *' first. Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara --- v3: - Added Aaron's ack. Note: this is not a perfect fix because it will potentially hide some UB. The proper fix is probably something along the lines of Adrian's series: https://patchwork.ozlabs.org/project/openvswitch/list/?series=282481&state=* --- include/openvswitch/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h index f45dc505164c..9a22ed56c505 100644 --- a/include/openvswitch/util.h +++ b/include/openvswitch/util.h @@ -128,7 +128,7 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *); * from the type of '*OBJECT'. */ #define OBJECT_CONTAINING(POINTER, OBJECT, MEMBER) \ ((OVS_TYPEOF(OBJECT)) (void *) \ - ((char *) (POINTER) - OBJECT_OFFSETOF(OBJECT, MEMBER))) + ((uintptr_t)(void *)(POINTER) - OBJECT_OFFSETOF(OBJECT, MEMBER))) /* Given POINTER, the address of the given MEMBER within an object of the type * that that OBJECT points to, assigns the address of the outer object to From patchwork Mon Jan 24 14:20:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=PQ9yraL/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBxF0Hqhz9tjx for ; Tue, 25 Jan 2022 01:21:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B269E40A9E; Mon, 24 Jan 2022 14:21:18 +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 ecT_1AbIk9yv; Mon, 24 Jan 2022 14:21:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 593D940A8F; Mon, 24 Jan 2022 14:21:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 36EAAC007B; Mon, 24 Jan 2022 14:21:16 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 13789C0039 for ; Mon, 24 Jan 2022 14:21:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5C57784B7A for ; Mon, 24 Jan 2022 14:20:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R57iG3_8Ca7T for ; Mon, 24 Jan 2022 14:20:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id BC66A84B76 for ; Mon, 24 Jan 2022 14:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643034037; 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: in-reply-to:in-reply-to:references:references; bh=4wcu55eKZW5sGoocgkLsiYqAdQgJVqfrteqHQDuoRZs=; b=PQ9yraL/4O9Z1zgILnDMevvfuDFpdTaHjLdmXC7W+UxfVxaHyr2G2zpvxfg9Pw8S7G6BNc VhEt3Bs21fUyjDx6FsHhZPR9JDkhxT/7mSzoKMnzeGF7Z75yQnhaX3oI4Upj+rR6CNdkej 57/7IxSIx3TVdgc7xCmU9R5GmuV0pjc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-qVYjuRZHOlKy43ey1neS_w-1; Mon, 24 Jan 2022 09:20:34 -0500 X-MC-Unique: qVYjuRZHOlKy43ey1neS_w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F98886A8A3; Mon, 24 Jan 2022 14:20:33 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DD4A79C5E; Mon, 24 Jan 2022 14:20:31 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:20:28 +0100 Message-Id: <20220124142025.11777.12869.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 13/14] ci: Fix typo in variable name. 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" Reported-by: David Marchand Signed-off-by: Dumitru Ceara Acked-by: Paolo Valerio --- .ci/linux-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 8d111b6d7f6b..6cd38ff3efb5 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -246,8 +246,8 @@ if [ "$ASAN" ]; then export ASAN_OPTIONS='detect_leaks=1' # -O2 generates few false-positive memory leak reports in test-ovsdb # application, so lowering optimizations to -O1 here. - CLFAGS_ASAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=address" - CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CLFAGS_ASAN}" + CFLAGS_ASAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=address" + CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CFLAGS_ASAN}" fi save_OPTS="${OPTS} $*" From patchwork Mon Jan 24 14:20:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1583506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=IkeNOUKC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjBxK0jjYz9t5m for ; Tue, 25 Jan 2022 01:21:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 32A7E60FB8; Mon, 24 Jan 2022 14:21:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KQj8RrnKxOWm; Mon, 24 Jan 2022 14:21:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 0D45560F11; Mon, 24 Jan 2022 14:21:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DEF64C0039; Mon, 24 Jan 2022 14:21:19 +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 176F6C007C for ; Mon, 24 Jan 2022 14:21:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8976260E88 for ; Mon, 24 Jan 2022 14:21:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R2bWBY07ZfGr for ; Mon, 24 Jan 2022 14:21:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4D12C60E74 for ; Mon, 24 Jan 2022 14:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643034060; 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: in-reply-to:in-reply-to:references:references; bh=3HP4r0RC4ZKMyxgEpGXCiWrURI1X6ENQSWTOGcAIZ/8=; b=IkeNOUKCDmSGcNx1qg730I2eae75JnGhW2PwSn7j34ZuqrefRr/uNCpLayzZBX/B1h4amY SsG/NhySA6nDztOddZz36uleE1gwx82rwJbUs/QzHnJxJMzsqYoreoqiUkTLWzqb5htY0H sWT+D+qO3KIgcpdINOfakBjLg3tMRdk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-u5CVqy5fPxiBx3L7UG0wgA-1; Mon, 24 Jan 2022 09:20:56 -0500 X-MC-Unique: u5CVqy5fPxiBx3L7UG0wgA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D93C9344B1; Mon, 24 Jan 2022 14:20:55 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C4DB8464F; Mon, 24 Jan 2022 14:20:47 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 24 Jan 2022 15:20:44 +0100 Message-Id: <20220124142038.11777.16794.stgit@dceara.remote.csb> In-Reply-To: <20220124141706.11777.99804.stgit@dceara.remote.csb> References: <20220124141706.11777.99804.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v3 14/14] ci: Add UB Sanitizer. 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" Note: There still is an UB instance when using SSE4.2 as reported here: https://mail.openvswitch.org/pipermail/ovs-dev/2022-January/390904.html Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara --- v3: - Fix typo in variable name. - Added SSE4.2 UB note to commit log. --- .ci/linux-build.sh | 6 ++++++ .github/workflows/build-and-test.yml | 5 +++++ configure.ac | 1 + tests/atlocal.in | 16 ++++++++++++++++ tests/automake.mk | 1 + tests/daemon.at | 8 ++++++++ tests/ovs-macros.at | 5 +++++ tests/ovsdb-server.at | 16 ++++++++++++++++ 8 files changed, 58 insertions(+) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 6cd38ff3efb5..afd4379e6923 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -250,6 +250,12 @@ if [ "$ASAN" ]; then CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CFLAGS_ASAN}" fi +if [ "$UBSAN" ]; then + # Use the default options configured in tests/atlocal.in, in UBSAN_OPTIONS. + CFLAGS_UBSAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=undefined" + CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CFLAGS_UBSAN}" +fi + save_OPTS="${OPTS} $*" OPTS="${EXTRA_OPTS} ${save_OPTS}" diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index eac3504e48f8..9e3583781baa 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,6 +13,7 @@ jobs: linux-headers-$(uname -r) build-essential fakeroot devscripts equivs AFXDP: ${{ matrix.afxdp }} ASAN: ${{ matrix.asan }} + UBSAN: ${{ matrix.ubsan }} CC: ${{ matrix.compiler }} DEB_PACKAGE: ${{ matrix.deb_package }} DPDK: ${{ matrix.dpdk }} @@ -44,6 +45,10 @@ jobs: testsuite: test kernel: 3.16 asan: asan + - compiler: clang + testsuite: test + kernel: 3.16 + ubsan: ubsan - compiler: gcc testsuite: test diff --git a/configure.ac b/configure.ac index 298ea85aba22..198653a60528 100644 --- a/configure.ac +++ b/configure.ac @@ -197,6 +197,7 @@ OVS_CHECK_LINUX_SCTP_CT OVS_CHECK_LINUX_VIRTIO_TYPES OVS_CHECK_DPDK OVS_CHECK_PRAGMA_MESSAGE +AC_SUBST([CFLAGS]) AC_SUBST([OVS_CFLAGS]) AC_SUBST([OVS_LDFLAGS]) diff --git a/tests/atlocal.in b/tests/atlocal.in index a0ad239ecef2..142ea2090bc8 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -4,6 +4,7 @@ OPENSSL_SUPPORTS_SNI='@OPENSSL_SUPPORTS_SNI@' HAVE_UNBOUND='@HAVE_UNBOUND@' EGREP='@EGREP@' PYTHON3='@PYTHON3@' +CFLAGS='@CFLAGS@' # PYTHONCOERCECLOCALE=0 disables the Unicode compatibility warning on # stderr that breaks almost any Python3 test (PEP 0538) @@ -197,6 +198,16 @@ else DIFF_SUPPORTS_NORMAL_FORMAT=no fi +# Check whether UB Sanitizer is being used. +case "$CFLAGS" in +*fsanitize=undefined*) + TESTS_WITH_UBSAN=yes + ;; +*) + TESTS_WITH_UBSAN=no + ;; +esac + # Turn off proxies. unset http_proxy unset https_proxy @@ -222,3 +233,8 @@ export OVS_CTL_TIMEOUT # matter break everything. ASAN_OPTIONS=detect_leaks=0:abort_on_error=true:log_path=asan:$ASAN_OPTIONS export ASAN_OPTIONS + +# Add some default flags for UndefinedBehaviorSanitizer, if it was used +# for the build. +UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=true:log_path=ubsan:$UBSAN_OPTIONS +export UBSAN_OPTIONS diff --git a/tests/automake.mk b/tests/automake.mk index 8a9151f81b86..a526be84b493 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -213,6 +213,7 @@ check-local: set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \ "$$@" $(TESTSUITEFLAGS) || \ (test -z "$$(find $(TESTSUITE_DIR) -name 'asan.*')" && \ + test -z "$$(find $(TESTSUITE_DIR) -name 'ubsan.*')" && \ test X'$(RECHECK)' = Xyes && "$$@" --recheck) # Python Coverage support. diff --git a/tests/daemon.at b/tests/daemon.at index 39d9aa391e9b..d7981f9d23a6 100644 --- a/tests/daemon.at +++ b/tests/daemon.at @@ -81,6 +81,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start the daemon and wait for the pidfile to get created. on_exit 'kill $(cat *.pid)' AT_CHECK([ovsdb-server --monitor --pidfile --no-db 2>/dev/null & echo $!], @@ -149,6 +153,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + on_exit 'kill $(cat *.pid)' # Start the daemon and make sure that the pidfile exists immediately. diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 66545da5728f..7899583f3c21 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -216,6 +216,11 @@ ovs_cleanup() { cat asan.* AT_FAIL_IF([:]) fi + if test "$(echo ubsan.*)" != 'ubsan.*'; then + echo "Undefined Behavior Sanitizer reported errors in:" ubsan.* + cat ubsan.* + AT_FAIL_IF([:]) + fi } ovs_wait () { diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 2b742f78b079..1e00be60684b 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -292,6 +292,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with one db. ordinal_schema > schema AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) @@ -327,6 +331,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with one db. ordinal_schema > schema AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) @@ -477,6 +485,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with no remotes. ordinal_schema > schema AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) @@ -512,6 +524,10 @@ AT_SKIP_IF([test "$IS_WIN32" = "yes"]) # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS +# Skip it if UB Sanitizer is being used. There's no way to disable the +# SEGV check at runtime. +AT_SKIP_IF([test $TESTS_WITH_UBSAN = yes]) + # Start ovsdb-server, initially with no remotes. ordinal_schema > schema AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])