HomeFreeBSD

ipfilter: Fix NULL dereferences in ipf_checkicmp6matchingstate()

Description

ipfilter: Fix NULL dereferences in ipf_checkicmp6matchingstate()

Add NULL checks for ic6 (the ICMPv6 header pointer from fin->fin_dp)
and oic (the inner ICMPv6 header from ofin.fin_dp after ipf_makefrip).
These pointers can be NULL when processing malformed ICMPv6 error
packets with extension headers.

Also fix the length validation: the original check (fin->fin_plen <
sizeof(ip6_t)) could never trigger because an earlier check already
ensures fin->fin_plen >= ICMP6ERR_MINPKTLEN (48). Replace with a proper
check that fin->fin_dlen contains at least ICMPERR_ICMPHLEN +
sizeof(ip6_t) bytes to ensure sufficient data exists for both the
ICMPv6 error header and the embedded IPv6 header.

PR: 288333
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/2214
Signed-off-by: Teddy Engel <engel.teddy@gmail.com>

(cherry picked from commit c028080749c09e68c555155df0e9f681ba63c6ae)

Details

Provenance
Teddy Engel <engel.teddy@gmail.com>Authored on May 19 2026, 9:36 PM
cyCommitted on May 27 2026, 1:41 PM
Parents
rGfefcd4994069: ipfilter: Add NULL check for fin_m in ipf_pr_icmp6()
Branches
Unknown
Tags
Unknown