Fix unaligned memory access detected by UBSAN

Recently, Chromium added -fsanitize=alignment for `is_ubsan=true`,
and due to this, unaligned memory access was found in several places,
and chromium roll is currently blocked.
Modify unaligned memory access in rtc_base/byte_order.h to use memcpy.
Since libaom and libsrtp perform unaligned memory accesses, add them
to the suppression list.
Also, remove any mention of yasm from the UBSAN suppression list,
as yasm is no longer used.

Bug: chromium:1057551
Change-Id: I4961b66831750f4fa7b6de0b80b2052fe6ef27c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286200
Commit-Queue: Daniel.L (Byoungchan) Lee <daniel.l@hpcnt.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38806}
diff --git a/rtc_base/byte_order.h b/rtc_base/byte_order.h
index ae1c634..b8f8ae9 100644
--- a/rtc_base/byte_order.h
+++ b/rtc_base/byte_order.h
@@ -13,6 +13,8 @@
 
 #include <stdint.h>
 
+#include <cstring>
+
 #if defined(WEBRTC_POSIX) && !defined(__native_client__)
 #include <arpa/inet.h>
 #endif
@@ -107,51 +109,69 @@
 }
 
 inline void SetBE16(void* memory, uint16_t v) {
-  *static_cast<uint16_t*>(memory) = htobe16(v);
+  uint16_t val = htobe16(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline void SetBE32(void* memory, uint32_t v) {
-  *static_cast<uint32_t*>(memory) = htobe32(v);
+  uint32_t val = htobe32(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline void SetBE64(void* memory, uint64_t v) {
-  *static_cast<uint64_t*>(memory) = htobe64(v);
+  uint64_t val = htobe64(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline uint16_t GetBE16(const void* memory) {
-  return be16toh(*static_cast<const uint16_t*>(memory));
+  uint16_t val;
+  memcpy(&val, memory, sizeof(val));
+  return be16toh(val);
 }
 
 inline uint32_t GetBE32(const void* memory) {
-  return be32toh(*static_cast<const uint32_t*>(memory));
+  uint32_t val;
+  memcpy(&val, memory, sizeof(val));
+  return be32toh(val);
 }
 
 inline uint64_t GetBE64(const void* memory) {
-  return be64toh(*static_cast<const uint64_t*>(memory));
+  uint64_t val;
+  memcpy(&val, memory, sizeof(val));
+  return be64toh(val);
 }
 
 inline void SetLE16(void* memory, uint16_t v) {
-  *static_cast<uint16_t*>(memory) = htole16(v);
+  uint16_t val = htole16(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline void SetLE32(void* memory, uint32_t v) {
-  *static_cast<uint32_t*>(memory) = htole32(v);
+  uint32_t val = htole32(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline void SetLE64(void* memory, uint64_t v) {
-  *static_cast<uint64_t*>(memory) = htole64(v);
+  uint64_t val = htole64(v);
+  memcpy(memory, &val, sizeof(val));
 }
 
 inline uint16_t GetLE16(const void* memory) {
-  return le16toh(*static_cast<const uint16_t*>(memory));
+  uint16_t val;
+  memcpy(&val, memory, sizeof(val));
+  return le16toh(val);
 }
 
 inline uint32_t GetLE32(const void* memory) {
-  return le32toh(*static_cast<const uint32_t*>(memory));
+  uint32_t val;
+  memcpy(&val, memory, sizeof(val));
+  return le32toh(val);
 }
 
 inline uint64_t GetLE64(const void* memory) {
-  return le64toh(*static_cast<const uint64_t*>(memory));
+  uint64_t val;
+  memcpy(&val, memory, sizeof(val));
+  return le64toh(val);
 }
 
 // Check if the current host is big endian.
diff --git a/tools_webrtc/ubsan/suppressions.txt b/tools_webrtc/ubsan/suppressions.txt
index dc76f38..2ece795 100644
--- a/tools_webrtc/ubsan/suppressions.txt
+++ b/tools_webrtc/ubsan/suppressions.txt
@@ -6,10 +6,6 @@
 # the RTC_NO_SANITIZE macro. Please think twice before adding new exceptions.
 
 #############################################################################
-# YASM does some funny things that UBsan doesn't like.
-# https://crbug.com/489901
-src:*/third_party/yasm/*
-
 # OpenH264 triggers some errors that are out of our control.
 src:*/third_party/ffmpeg/libavcodec/*
 src:*/third_party/openh264/*
@@ -22,3 +18,9 @@
 #############################################################################
 # Ignore system libraries.
 src:*/usr/*
+
+#############################################################################
+[alignment]
+# Libaom and libsrtp are doing unaligned memory access.
+src:*/third_party/libaom/source/libaom/*
+src:*/third_party/libsrtp/srtp/srtp.c