Date: Wed, 27 May 2026 13:42:12 +0000 From: Cy Schubert <cy@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Teddy Engel <engel.teddy@gmail.com> Subject: git: 36ab14d79529 - stable/14 - ipfilter: Fix NULL dereferences in ipf_checkicmp6matchingstate() Message-ID: <6a16f4b4.1c814.1af10b9f@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=36ab14d7952997b102ca07ae2b61590b52144078 commit 36ab14d7952997b102ca07ae2b61590b52144078 Author: Teddy Engel <engel.teddy@gmail.com> AuthorDate: 2026-05-19 21:36:33 +0000 Commit: Cy Schubert <cy@FreeBSD.org> CommitDate: 2026-05-27 13:42:02 +0000 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 Pull Request: https://github.com/freebsd/freebsd-src/pull/2214 Signed-off-by: Teddy Engel <engel.teddy@gmail.com> (cherry picked from commit c028080749c09e68c555155df0e9f681ba63c6ae) --- sys/netpfil/ipfilter/netinet/ip_state.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/ipfilter/netinet/ip_state.c b/sys/netpfil/ipfilter/netinet/ip_state.c index bfb9b9eb19f3..a22e19db15aa 100644 --- a/sys/netpfil/ipfilter/netinet/ip_state.c +++ b/sys/netpfil/ipfilter/netinet/ip_state.c @@ -4368,9 +4368,13 @@ ipf_checkicmp6matchingstate(fr_info_t *fin) } ic6 = fin->fin_dp; + if (ic6 == NULL) { + SBUMPD(ipf_state_stats, iss_icmp6_miss); + return (NULL); + } oip6 = (ip6_t *)((char *)ic6 + ICMPERR_ICMPHLEN); - if (fin->fin_plen < sizeof(*oip6)) { + if (fin->fin_dlen < ICMPERR_ICMPHLEN + sizeof(*oip6)) { SBUMPD(ipf_state_stats, iss_icmp_short); return (NULL); } @@ -4412,6 +4416,10 @@ ipf_checkicmp6matchingstate(fr_info_t *fin) if (oip6->ip6_nxt == IPPROTO_ICMPV6) { oic = ofin.fin_dp; + if (oic == NULL) { + SBUMPD(ipf_state_stats, iss_icmp6_miss); + return (NULL); + } /* * an ICMP error can only be generated as a result of an * ICMP query, not as the response on an ICMP errorhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a16f4b4.1c814.1af10b9f>
