UBSAN report for main [so: 14] /usr/sbin/traceroute: various misaligned address reports

From: Mark Millard <marklmi_at_yahoo.com>
Date: Tue, 11 Jan 2022 07:33:58 UTC
I tried a /usr/sbin/traceroute from a chroot that had been built using
WITH_UBSAN= in use. It got the common lib/libc/stdio/fread.c zero offset
to null pointer notice but also reported "member access within misaligned
address" for types:

'struct ifreq', which requires 8 byte alignment

'union (unnamed union at /usr/obj/BUILDs/main-amd64-nodbg-clang-alt/usr/main-src/amd64.amd64/tmp/usr/include/net/if.h:398:2)', which requires 8 byte alignment

'struct sockaddr', which requires 8 byte alignment

'unsigned char', which requires 8 byte alignment

The reports are:

/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/lib/libc/stdio/fread.c:133:10 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:113:13: runtime error: member access within misaligned address 0x7fffffff55fc for type 'struct ifreq', which requires 8 byte alignment
0x7fffffff55fc: note: pointer points here
  00 00 00 00 6c 6f 30 00  00 00 00 00 00 00 00 00  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:113:13 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:113:13: runtime error: member access within misaligned address 0x7fffffff560c for type 'union (unnamed union at /usr/obj/BUILDs/main-amd64-nodbg-clang-alt/usr/main-src/amd64.amd64/tmp/usr/include/net/if.h:398:2)', which requires 8 byte alignment
0x7fffffff560c: note: pointer points here
  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:113:13 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:113:13: runtime error: member access within misaligned address 0x7fffffff560c for type 'struct sockaddr', which requires 8 byte alignment
0x7fffffff560c: note: pointer points here
  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:113:13 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:113:22: runtime error: load of misaligned address 0x7fffffff560c for type 'unsigned char', which requires 8 byte alignment
0x7fffffff560c: note: pointer points here
  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:113:22 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:118:13: runtime error: member access within misaligned address 0x7fffffff55fc for type 'struct ifreq', which requires 8 byte alignment
0x7fffffff55fc: note: pointer points here
  00 00 00 00 6c 6f 30 00  00 00 00 00 00 00 00 00  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:118:13 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:118:13: runtime error: member access within misaligned address 0x7fffffff560c for type 'union (unnamed union at /usr/obj/BUILDs/main-amd64-nodbg-clang-alt/usr/main-src/amd64.amd64/tmp/usr/include/net/if.h:398:2)', which requires 8 byte alignment
0x7fffffff560c: note: pointer points here
  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:118:13 in 
/usr/main-src/contrib/traceroute/ifaddrlist.c:118:13: runtime error: member access within misaligned address 0x7fffffff560c for type 'struct sockaddr', which requires 8 byte alignment
0x7fffffff560c: note: pointer points here
  00 00 00 00 1c 1c 00 00  00 00 00 00 fe 80 00 02  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/contrib/traceroute/ifaddrlist.c:118:13 in 

===
Mark Millard
marklmi at yahoo.com