Skip to content

ipfilter: Add NULL check for fin_dp in TCP, UDP, GRE, and AH packet h…#2229

Closed
devnexen wants to merge 1 commit into
freebsd:mainfrom
devnexen:fil_fix
Closed

ipfilter: Add NULL check for fin_dp in TCP, UDP, GRE, and AH packet h…#2229
devnexen wants to merge 1 commit into
freebsd:mainfrom
devnexen:fil_fix

Conversation

@devnexen
Copy link
Copy Markdown
Contributor

…andlers

Mirror commit 68ed816, which added the same check in ipf_pr_icmp() and ipf_pr_icmp6(). ipf_pr_pullup() can return success while leaving fin->fin_dp NULL (e.g. when fin_m is NULL on a synthesized fr_info_t, as constructed by ipf_checkicmp6matchingstate()), so callers that immediately dereference fin_dp must check for NULL too.

The same pattern was missed in ipf_pr_tcpcommon(), ipf_pr_udpcommon(), ipf_pr_gre(), ipf_pr_gre6(), and ipf_pr_ah(), each of which would panic on a NULL dereference under the same conditions.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Thank you for taking the time to contribute to FreeBSD!

Some of files have special handling:

Important

@cschuber wants to review changes to sys/netpfil/ipfilter

…andlers

Mirror commit 68ed816, which added the same check in ipf_pr_icmp()
and ipf_pr_icmp6().  ipf_pr_pullup() can return success while leaving
fin->fin_dp NULL (e.g. when fin_m is NULL on a synthesized fr_info_t,
as constructed by ipf_checkicmp6matchingstate()), so callers that
immediately dereference fin_dp must check for NULL too.

The same pattern was missed in ipf_pr_tcpcommon(), ipf_pr_udpcommon(),
ipf_pr_gre(), ipf_pr_gre6(), and ipf_pr_ah(), each of which would
panic on a NULL dereference under the same conditions.

Signed-off-by: David Carlier <devnexen@gmail.com>
@cschuber
Copy link
Copy Markdown
Member

Thanks for the patch. (On phone app.) I'll review this when I get back on Monday.

@cschuber
Copy link
Copy Markdown
Member

I don't see how fin_dp could ever be NULL. It is always *ip + hlen. fin_dp always points to the data header following the IP header. Do you have a panic dump I can look at?

@devnexen
Copy link
Copy Markdown
Contributor Author

You're right ; ipf_makefrip() sets fin_dp = ip + hlen unconditionally,
and the only later mutators add a non-negative shift, so it can't reach
these handlers as NULL. Patterned this on the ICMP commit without a
real trigger. Closing.

@devnexen devnexen closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants