From patchwork Mon Apr 11 11:38: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: 1615710 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=RV9tNhYS; 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 4KcRh33czCz9sDX for ; Mon, 11 Apr 2022 21:38:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1435781A8E; Mon, 11 Apr 2022 11:38:42 +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 YrHotqugp-zb; Mon, 11 Apr 2022 11:38:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 443A8813DB; Mon, 11 Apr 2022 11:38:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E9EDC0033; Mon, 11 Apr 2022 11:38:40 +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 22D92C0033 for ; Mon, 11 Apr 2022 11:38:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D795141728 for ; Mon, 11 Apr 2022 11:38:38 +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 7y9wAygmOCwW for ; Mon, 11 Apr 2022 11:38: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 smtp4.osuosl.org (Postfix) with ESMTPS id B7DDE410E8 for ; Mon, 11 Apr 2022 11:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649677116; 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=6Dl8elnjOwc8C/w+JDRCunCYK3IfjX/j//BCy4qBi2I=; b=RV9tNhYSyPDCKrIeTyxAuQyT8UT9aR2T09FrT3SslLw4ncrkfsaXQ0Iyqn7WPSccfDAzzD GZDn+SUWP3hY0NEUhnn6YaiUQBdRoJpHXms5mgYD+Peof7lLOpeYTyo49q4kUdXd0cMO44 LUDoWo+TxchZWEYJiQbYzvisNGm+p/k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-dCEsBOrtNC2slA6GwfroHg-1; Mon, 11 Apr 2022 07:38:33 -0400 X-MC-Unique: dCEsBOrtNC2slA6GwfroHg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E678811E75; Mon, 11 Apr 2022 11:38:33 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.194.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD32A40CF8E4; Mon, 11 Apr 2022 11:38:31 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Mon, 11 Apr 2022 13:38:28 +0200 Message-Id: <20220411113826.20007.28256.stgit@dceara.remote.csb> In-Reply-To: <20220411113659.20007.91457.stgit@dceara.remote.csb> References: <20220411113659.20007.91457.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: noloader@gmail.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v6 4/7] 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 Acked-by: Aaron Conole Signed-off-by: Dumitru Ceara --- v6: Added Aaron's ack. v5: Rebased. v4: Rebased. 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; }