Bug 291854 - Update to sys/netpfil/ipfw/ip_fw_bpf.c triggers a panic when ipfw starts
Summary: Update to sys/netpfil/ipfw/ip_fw_bpf.c triggers a panic when ipfw starts
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-21 04:03 UTC by rkoberman
Modified: 2025-12-25 21:12 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rkoberman 2025-12-21 04:03:12 UTC
After 3daae1ac1d82 was committed Dec.15, my system panics while starting up ipfw.

kernel: ipfw2 (+ipv6) initialized, divert loadable, nat loadable, default to deny, logging disabled
kernel: panic: Assertion tap->rule == rule failed at /usr/src/sys/netpfil/ipfw/ip_fw_bpf.c:86
kernel: cpuid = 11
kernel: time = 1766124707
kernel: KDB: stack backtrace:
kernel: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00eb3d3900
kernel: vpanic() at vpanic+0x136/frame 0xfffffe00eb3d3a30
kernel: panic() at panic+0x43/frame 0xfffffe00eb3d3a90
kernel: ipfw_tap_alloc() at ipfw_tap_alloc+0x2f7/frame 0xfffffe00eb3d3ac0
kernel: add_rules() at add_rules+0x137/frame 0xfffffe00eb3d3b30
kernel: ipfw_ctl3() at ipfw_ctl3+0x365/frame 0xfffffe00eb3d3ce0
kernel: sogetopt() at sogetopt+0x15a/frame 0xfffffe00eb3d3d40
kernel: kern_getsockopt() at kern_getsockopt+0xb5/frame 0xfffffe00eb3d3dd0
kernel: sys_getsockopt() at sys_getsockopt+0x52/frame 0xfffffe00eb3d3e00
kernel: amd64_syscall() at amd64_syscall+0x169/frame 0xfffffe00eb3d3f30
kernel: fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00eb3d3f30
kernel: --- syscall (118, FreeBSD ELF64, getsockopt), rip = 0x1d91f7dd13da, rsp = 0x1d91f513d1a8$
kernel: KDB: enter: panic

The commit was found by git bisect.
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-21 07:36:41 UTC
Can you please try to narrow down and share the exact rule that triggers the panic?
Comment 2 rkoberman 2025-12-22 00:48:21 UTC
I commented out every line except the final like to log any pack that reached the end without being allowed. It still panicked. Here are the only non-commented lines:
#!/bin/sh
ipfw -q -f flush

cmd="ipfw -q add"
pif="wlan0"     # interface name of NIC attached to Internet
[About 160 lines starting with '#'
$cmd 65534 deny log logamount 1000 ip from any to any

Still panicked.
Comment 3 Gleb Smirnoff freebsd_committer freebsd_triage 2025-12-22 00:51:27 UTC
Thanks, that helped to reproduce.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-12-22 02:24:03 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=129e15d4994311958db59a1718d4ff42d440ce2b

commit 129e15d4994311958db59a1718d4ff42d440ce2b
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-12-22 01:18:27 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-12-22 02:23:14 +0000

    ipfw: fix bpf tap point lookup

    The trick I blindly used works for pointers to structs, but not for rule
    numbers that can differ only by 1.

    PR:     291854
    Fixes:  3daae1ac1d82ecdcd855101bab5206e914b12350

 sys/netpfil/ipfw/ip_fw_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 5 O. Hartmann 2025-12-25 19:00:20 UTC
On recent CURRENT: FreeBSD 16.0-CURRENT #7 main-n282705-8d5a11cd0137: Wed Dec 24 12:14:13 CET 2025 amd64, a "service ipfw restart" or stopping jails via "service jail stop" panics the systems (I have several running recent CURRENT as of today, 25th Dec 2025, IPFW statically compiled in kernel). 

The problem is still present.

On CURRENT email list, R. Klopp mentioned tap being an issue. On all systems a tap0 device is present.
Comment 6 Gleb Smirnoff freebsd_committer freebsd_triage 2025-12-25 21:12:52 UTC
(In reply to O. Hartmann from comment #5)

This must be a different problem than the original that opened this bug report. Can you please share your backtrace and panic message? Preferably as a new bug report or just email to me.