On 28.05.2019 11:17, Michael van Elst wrote: > n54%gmx.com@localhost (Kamil Rytarowski) writes: > >> As mentioned in the logs [1], the address is misaligned. >> [1] http://netbsd.org/~kamil/patch-00115-tcp_input.2.txt > > As I said, if the assumption is broken worse things will happen. > OK, so I assume that there is no a real kernel bug here exposed by my local network or my local networking device. > The most likely explanation is that, since x86 doesn't require alignment, > the code doesn't force align the data in the first place. The logged > addresses are all even, so that's probably a driver that ignores or > mishandles ETHER_ALIGN (ethernet header is 14 bytes). > > And now please start arguing that unaligned accesses on x86 are > undefined behaviour and that compilers are allowed to break it. > > Could you please also verify that my suggested change appeases > the sanitizer? It seems to ignore all the evil a few lines later... > For this patch: Index: sys/netinet/tcp_input.c =================================================================== RCS file: /cvsroot/src/sys/netinet/tcp_input.c,v retrieving revision 1.413 diff -u -r1.413 tcp_input.c --- sys/netinet/tcp_input.c 8 Nov 2018 06:43:52 -0000 1.413 +++ sys/netinet/tcp_input.c 28 May 2019 14:10:50 -0000 @@ -1337,7 +1337,8 @@ } KASSERT(TCP_HDR_ALIGNED_P(th)); optlen = thlen - sizeof(struct tcphdr); - optp = ((u_int8_t *)th) + sizeof(struct tcphdr); +// optp = ((u_int8_t *)th) + sizeof(struct tcphdr); + optp = (u_int8_t *)(th + 1); /* * Do quick retrieval of timestamp options. I'm getting this: [ 66,719550] UBSan: Undefined Behavior in /usr/src/sys/netinet/tcp_input.c:1354:7, load of misaligned address 0xffffe4cf15578836 for type 'u_int32_t' which requires 4 byte alignment [ 66,719550] UBSan: Undefined Behavior in /usr/src/sys/netinet/tcp_input.c:1357:18, load of misaligned address 0xffffe4cf15a2183a for type 'u_int32_t' which requires 4 byte alignment [ 66,719550] UBSan: Undefined Behavior in /usr/src/sys/netinet/tcp_input.c:1357:18, load of misaligned address 0xffffe4cf15a2183a for type 'u_int32_t' which requires 4 byte alignment [ 66,719550] UBSan: Undefined Behavior in /usr/src/sys/netinet/tcp_input.c:1358:18, load of misaligned address 0xffffe4cf15a2183e for type 'u_int32_t' which requires 4 byte alignment [ 66,719550] UBSan: Undefined Behavior in /usr/src/sys/netinet/tcp_input.c:1358:18, load of misaligned address 0xffffe4cf15a2183e for type 'u_int32_t' which requires 4 byte alignment
Attachment:
signature.asc
Description: OpenPGP digital signature