08f0a1bdc091 dropped the check that O_TCPMSS has a TCP header to look
at. For a non-first fragment of a TCP datagram ulp is NULL, and
args->f_id._flags is not set for such a packet. ipfw_check_packet()
does not zero its struct ip_fw_args, so the flags may still have
TH_SYN from an earlier packet; a tcpmss rule then reads the TCP
header through the NULL pointer and the kernel panics.
Check offset == 0, as the other TCP header opcodes do: then the TCP
header has been pulled up and the flags belong to this packet.
Document that tcpmss looks only at packets with the SYN flag set and
never matches a fragment with a non-zero offset.
Add tests that send SYNs through a tcpmss rule, alone and each
followed by a non-first TCP fragment, and check the rule counters:
frag4: IPv4; panics without the fix. frag6: IPv6; panics without the fix.
Only -current is affected.
Reported by: Jubal Skaggs <jubal@vcontext.net>
Co-authored-by: Claude Opus 5.5
Fixes: 08f0a1bdc091 ("ipfw: use typed pointers to access network protocols headers where possible")