CVSROOT: /cvs Module name: src Changes by: bl...@cvs.openbsd.org 2024/02/13 06:58:19
Modified files: sys/dev/pci : if_bnxt.c if_em.c if_igc.c if_ix.c if_ixl.c sys/dev/pv : if_vio.c sys/net : if_ethersubr.c sys/netinet : if_ether.h Log message: Analyse header layout in ether_extract_headers(). Several drivers need IPv4 header length and TCP offset for checksum offload, TSO and LRO. Accessing these fields directly caused crashes on sparc64 due to misaligned access. It cannot be guaranteed that IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1 assumes that bit fields can be accessed with 32 bit load instructions. Use memcpy() in ether_extract_headers() to get the bits from IPv4 and TCP header and store the header length in struct ether_extracted. >From there network drivers can esily use it without caring about alignment and bit shift. Do some sanity checks with the length values to prevent that invalid values from evil packets get stored into hardware registers. If check fails, clear the pointer to the header to hide it from the driver. Add debug prints that help to figure out the reason for bad packets and provide information when debugging drivers. OK mglocker@