diff options
author | Dumitru Ceara <dceara@redhat.com> | 2022-04-11 13:38:59 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-05-17 23:10:20 +0200 |
commit | c8c49a9db9f20e8b5115e9ef7924e702ee70f4c3 (patch) | |
tree | 801684274d85d2b1b999dfdb0c188974de3116fa /include | |
parent | a5cc859a4228a9ce70c40304041ed2b18064ddcc (diff) | |
download | openvswitch-c8c49a9db9f20e8b5115e9ef7924e702ee70f4c3.tar.gz |
netdev-linux: Properly access 32-bit aligned rtnl_link_stats64 structs.
Detected by UB Sanitizer when running system tests:
lib/netdev-linux.c:6250:26:
runtime error: member access within misaligned address 0x00000229a204
for type 'const struct rpl_rtnl_link_stats64', which requires 8 byte
alignment
0x00000229a204: note: pointer points here
c4 00 17 00 01 00 00 00 00 00 00 00 01 00 00 00
^
00 00 00 00 6e 00 00 00 00 00 00 00 6e 00 00 00
0 0x89f10e in netdev_stats_from_rtnl_link_stats64 lib/netdev-linux.c:6250
1 0x89f10e in get_stats_via_netlink lib/netdev-linux.c:6298
2 0x8a039a in netdev_linux_get_stats lib/netdev-linux.c:2227
3 0x68e149 in netdev_get_stats lib/netdev.c:1599
4 0x407b21 in iface_refresh_stats vswitchd/bridge.c:2687
5 0x419eb6 in iface_create vswitchd/bridge.c:2134
6 0x419eb6 in bridge_add_ports__ vswitchd/bridge.c:1170
7 0x41f71c in bridge_add_ports vswitchd/bridge.c:1181
8 0x41f71c in bridge_reconfigure vswitchd/bridge.c:898
9 0x429f59 in bridge_run vswitchd/bridge.c:3331
10 0x430af3 in main vswitchd/ovs-vswitchd.c:129
11 0x7fbdfd43eb74 in __libc_start_main (/lib64/libc.so.6+0x27b74)
12 0x4072fd in _start (/root/ovs/vswitchd/ovs-vswitchd+0x4072fd)
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/openvswitch/util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h index 96f600160..8e6c46a85 100644 --- a/include/openvswitch/util.h +++ b/include/openvswitch/util.h @@ -429,6 +429,9 @@ is_pow2(uintmax_t x) * segfault, so it is important to be aware of correct alignment. */ #define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR)) +#define IS_PTR_ALIGNED(OBJ) \ + (!(OBJ) || (uintptr_t) (OBJ) % __alignof__(OVS_TYPEOF(OBJ)) == 0) + #ifdef __cplusplus } #endif |