From patchwork Tue Jul 16 11:45:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1961055 X-Patchwork-Delegate: horms@verge.net.au 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=coQsTBpx; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNcj06Bjrz1xqc for ; Tue, 16 Jul 2024 21:46:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CDD0160A41; Tue, 16 Jul 2024 11:46:10 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q9tfZxYPN-YB; Tue, 16 Jul 2024 11:46:09 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D10E560908 Authentication-Results: smtp3.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=coQsTBpx Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id D10E560908; Tue, 16 Jul 2024 11:46:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B5066C0A97; Tue, 16 Jul 2024 11:46:09 +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 3DC45C0A96 for ; Tue, 16 Jul 2024 11:46:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 38DA440401 for ; Tue, 16 Jul 2024 11:46:09 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3CxEyl_XcBHp for ; Tue, 16 Jul 2024 11:46:03 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 59FCA406E7 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 59FCA406E7 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=coQsTBpx 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 59FCA406E7 for ; Tue, 16 Jul 2024 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721130360; 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=XdsRiqdgazmzckQxzEWzkc9f5JZ/YTBAuqwo21kQ2tc=; b=coQsTBpxXclq/0mJO19V+rB1Mkx8Hy+0/HR7l1uffHaaSe9D6dZTQOIv6PAsa4jl++NXoq axdHgWDN3p1gz14VYaPkwWOHLuFaxw0sn1gjS0DHgSqg1DAap8iwB42TtjM+TerO67eIj9 GvrqxBQZ4uspHMOylHl/WqdtPOzUSwI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-vI_OZ38pMeKZ0XLrTsTYBQ-1; Tue, 16 Jul 2024 07:45:56 -0400 X-MC-Unique: vI_OZ38pMeKZ0XLrTsTYBQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F28611955D50; Tue, 16 Jul 2024 11:45:55 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.32]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 907AC1955F40; Tue, 16 Jul 2024 11:45:54 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Tue, 16 Jul 2024 13:45:53 +0200 Message-ID: <20240716114553.605421-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] flow: Fix unaligned access to the ND target in miniflow_extract. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@ovn.org Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The data in the buffer are aligned to 2 bytes, however 'struct in6_addr' is aligned to 4 bytes. Use the 2 bytes aligned equivalent 'union ovs_16aligned_in6_addr' instead. This was caught by one of the OVN tests: lib/flow.c:1133:25: runtime error: load of misaligned address 0x51400009cc92 for type 'const struct in6_addr *', which requires 4 byte alignment 0x51400009cc92: note: pointer points here 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ 0 0x8255b2 in miniflow_extract /workspace/ovn/ovs/lib/flow.c:1133:25 1 0x81d921 in flow_extract /workspace/ovn/ovs/lib/flow.c:671:5 2 0xa966d4 in ofp_packet_to_string /workspace/ovn/ovs/lib/ofp-print.c:82:5 3 0xa76de2 in ofputil_packet_in_private_format /workspace/ovn/ovs/lib/ofp-packet.c:1037:24 4 0xa99817 in ofp_print_packet_in /workspace/ovn/ovs/lib/ofp-print.c:132:9 5 0xa97f46 in ofp_to_string__ /workspace/ovn/ovs/lib/ofp-print.c 6 0xa97f46 in ofp_to_string /workspace/ovn/ovs/lib/ofp-print.c:1264:21 7 0xc338f4 in do_send /workspace/ovn/ovs/lib/vconn.c:687:19 8 0xb7f678 in try_send /workspace/ovn/ovs/lib/rconn.c:1128:14 9 0xb7d725 in rconn_send__ /workspace/ovn/ovs/lib/rconn.c:760:13 10 0xb7d8e7 in rconn_send_with_limit /workspace/ovn/ovs/lib/rconn.c:816:17 11 0x6f70de in do_send_packet_ins /workspace/ovn/ovs/ofproto/connmgr.c:1697:13 12 0x6f691f in connmgr_send_async_msg /workspace/ovn/ovs/ofproto/connmgr.c:1682:9 13 0x5c2d23 in run /workspace/ovn/ovs/ofproto/ofproto-dpif.c:1877:13 14 0x56737f in ofproto_run /workspace/ovn/ovs/ofproto/ofproto.c:1906:13 15 0x50d4fc in bridge_run__ /workspace/ovn/ovs/vswitchd/bridge.c:3287:9 16 0x50a764 in bridge_run /workspace/ovn/ovs/vswitchd/bridge.c:3346:5 17 0x53eed7 in main /workspace/ovn/ovs/vswitchd/ovs-vswitchd.c:130:9 Signed-off-by: Ales Musil Acked-by: Simon Horman --- lib/flow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/flow.c b/lib/flow.c index dc5fb328d..9be437524 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -408,7 +408,8 @@ parse_ethertype(const void **datap, size_t *sizep) static inline bool parse_icmpv6(const void **datap, size_t *sizep, const struct icmp6_data_header *icmp6, - ovs_be32 *rso_flags, const struct in6_addr **nd_target, + ovs_be32 *rso_flags, + const union ovs_16aligned_in6_addr **nd_target, struct eth_addr arp_buf[2], uint8_t *opt_type) { if (icmp6->icmp6_base.icmp6_code != 0 || @@ -1117,7 +1118,7 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst) } } else if (OVS_LIKELY(nw_proto == IPPROTO_ICMPV6)) { if (OVS_LIKELY(size >= sizeof(struct icmp6_data_header))) { - const struct in6_addr *nd_target; + const union ovs_16aligned_in6_addr *nd_target; struct eth_addr arp_buf[2]; /* This will populate whether we received Option 1 * or Option 2. */