UB Sanitizer report:
  controller/pinctrl.c:1921:54: runtime error: member access within misaligned 
address 0x00000261ce26 for type 'const struct sctp_init_chunk', which requires 
4 byte alignment
  0x00000261ce26: note: pointer points here
   01 00 00 14 00 00  00 02 00 00 00 00 00 01  00 01 00 00 00 02 00 00  00 03 
00 05 11 00 00 00  00 04
               ^
      #0 0x466da5 in pinctrl_handle_sctp_abort controller/pinctrl.c:1921
      #1 0x46725a in pinctrl_handle_reject controller/pinctrl.c:1975
      [...]

Signed-off-by: Dumitru Ceara <[email protected]>
---
 controller/pinctrl.c |    4 ++--
 lib/ovn-util.h       |   12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index e4ee8917e..373ed6cb2 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -1857,7 +1857,7 @@ pinctrl_handle_sctp_abort(struct rconn *swconn, const 
struct flow *ip_flow,
         return;
     }
 
-    const struct sctp_init_chunk *sh_in_init = NULL;
+    const struct sctp_16aligned_init_chunk *sh_in_init = NULL;
     if (sh_in_chunk->sctp_chunk_type == SCTP_CHUNK_TYPE_INIT) {
         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
         sh_in_init = dp_packet_at(pkt_in, pkt_in->l4_ofs +
@@ -1904,7 +1904,7 @@ pinctrl_handle_sctp_abort(struct rconn *swconn, const 
struct flow *ip_flow,
     bool tag_reflected;
     if (get_16aligned_be32(&sh_in->sctp_vtag) == 0 && sh_in_init) {
         /* See RFC 4960 Section 8.4, item 3. */
-        put_16aligned_be32(&sh->sctp_vtag, sh_in_init->initiate_tag);
+        sh->sctp_vtag = sh_in_init->initiate_tag;
         tag_reflected = false;
     } else {
         /* See RFC 4960 Section 8.4, item 8. */
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index a923c3b65..b212c64b7 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -261,14 +261,16 @@ struct sctp_chunk_header {
 BUILD_ASSERT_DECL(SCTP_CHUNK_HEADER_LEN == sizeof(struct sctp_chunk_header));
 
 #define SCTP_INIT_CHUNK_LEN 16
-struct sctp_init_chunk {
-    ovs_be32 initiate_tag;
-    ovs_be32 a_rwnd;
+struct sctp_16aligned_init_chunk {
+    ovs_16aligned_be32 initiate_tag;
+    ovs_16aligned_be32 a_rwnd;
     ovs_be16 num_outbound_streams;
     ovs_be16 num_inbound_streams;
-    ovs_be32 initial_tsn;
+    ovs_16aligned_be32 initial_tsn;
 };
-BUILD_ASSERT_DECL(SCTP_INIT_CHUNK_LEN == sizeof(struct sctp_init_chunk));
+BUILD_ASSERT_DECL(
+    SCTP_INIT_CHUNK_LEN == sizeof(struct sctp_16aligned_init_chunk)
+);
 
 /* These are the only SCTP chunk types that OVN cares about.
  * There is no need to define the other chunk types until they are

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to