From patchwork Fri Jan 19 16:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1888556 X-Patchwork-Delegate: echaudro@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I7vug5R5; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGl5j09F3z1yPv for ; Sat, 20 Jan 2024 03:13:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5897F40981; Fri, 19 Jan 2024 16:13:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5897F40981 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I7vug5R5 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 NfPO0n28umcZ; Fri, 19 Jan 2024 16:13:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2A6EB402F2; Fri, 19 Jan 2024 16:13:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2A6EB402F2 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E81F5C0072; Fri, 19 Jan 2024 16:13:06 +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 143A3C0037 for ; Fri, 19 Jan 2024 16:13:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E1DEA41C10 for ; Fri, 19 Jan 2024 16:13:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E1DEA41C10 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I7vug5R5 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 IsXmxoJGi5se for ; Fri, 19 Jan 2024 16:13:04 +0000 (UTC) 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 B806E41779 for ; Fri, 19 Jan 2024 16:13:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B806E41779 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705680782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0JxC36TnSb+a5ptP2d3Mhld6+5hBDFNUC2rxChdZQuw=; b=I7vug5R5O/crGJlNfOVw1VLWqeEaUcbm4nf/89XJdso958ty0S6D4IFjPOXWBKmdz6C+NP NTIaObdY8Attt13EHm5/hUgIDUaL6c8ySsjn57wA381ViM3mvtLpbEWfxS5qTTnwIseXYb VebTRynON0aZG+MggKnArAKR1rxiMOo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-XoeyOuHYOHmfi07sAzOEOA-1; Fri, 19 Jan 2024 11:13:01 -0500 X-MC-Unique: XoeyOuHYOHmfi07sAzOEOA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16B9029AA385 for ; Fri, 19 Jan 2024 16:13:01 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.8.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5119492BC6; Fri, 19 Jan 2024 16:13:00 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Fri, 19 Jan 2024 11:12:49 -0500 Message-Id: <20240119161249.388483-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] compiler: Fix errors in Clang 17 ubsan checks. 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 patch attempts to fix a large number of ubsan error messages that take the following form: lib/netlink-notifier.c:237:13: runtime error: call to function route_table_change through pointer to incorrect function type 'void (*)(const void *, void *)' In Clang 17 the undefined behaviour sanatizer check for function pointers was enabled by default, whereas it was previously disabled while compiling C code. These warnings are a false positive in the case of OVS, as our macros already check to make sure the function parameter is the correct size. So that check is disabled in the single function that is causing all of the errors. Signed-off-by: Mike Pattrick --- include/openvswitch/compiler.h | 11 +++++++++++ lib/ovs-rcu.c | 1 + 2 files changed, 12 insertions(+) diff --git a/include/openvswitch/compiler.h b/include/openvswitch/compiler.h index 878c5c6a7..59a835f15 100644 --- a/include/openvswitch/compiler.h +++ b/include/openvswitch/compiler.h @@ -69,6 +69,17 @@ #define OVS_UNLIKELY(CONDITION) (!!(CONDITION)) #endif +/* Clang 17's implementation of ubsan enables checking that function pointers + * match the type of the called function. This currently breaks ovs-rcu, which + * calls multiple different types of callbacks via a generic void *(void*) + * function pointer type. This macro enables disabling that check for specific + * functions. */ +#if __clang__ && __has_feature(undefined_behavior_sanitizer) +#define OVS_FUNCTION_PTR __attribute__((no_sanitize("function"))) +#else +#define OVS_FUNCTION_PTR +#endif + #if __has_feature(c_thread_safety_attributes) /* "clang" annotations for thread safety check. * diff --git a/lib/ovs-rcu.c b/lib/ovs-rcu.c index 9e07d9bab..56608aa46 100644 --- a/lib/ovs-rcu.c +++ b/lib/ovs-rcu.c @@ -327,6 +327,7 @@ ovsrcu_postpone__(void (*function)(void *aux), void *aux) } static bool +OVS_FUNCTION_PTR ovsrcu_call_postponed(void) { struct ovsrcu_cbset *cbset;