Bug 127042 - [pf] [patch] pf recursion panic if interface group is the same as the new interface name
Summary: [pf] [patch] pf recursion panic if interface group is the same as the new int...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-pf (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2008-09-02 12:10 UTC by Artis Caune
Modified: 2022-10-17 12:39 UTC (History)
2 users (show)

See Also:


Attachments
file.diff (975 bytes, patch)
2008-09-02 12:10 UTC, Artis Caune
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Artis Caune 2008-09-02 12:10:01 UTC
On carp enabled kernels, there is interface group "carp" with all carpX interfaces as menbers.
If I change name for any carpX interface to "carp", pf will panic with recursive call to pfi_kif_update().




#487 0xffffffff801d92dc in pfi_kif_update (kif=0xffffff0001ec4700) at /usr/src/sys/contrib/pf/net/pf_if.c:525
#488 0xffffffff801d92dc in pfi_kif_update (kif=0xffffff0001ec4700) at /usr/src/sys/contrib/pf/net/pf_if.c:525
#489 0xffffffff801d92dc in pfi_kif_update (kif=0xffffff0001ec4700) at /usr/src/sys/contrib/pf/net/pf_if.c:525
#490 0xffffffff801d92dc in pfi_kif_update (kif=0xffffff0001ec4700) at /usr/src/sys/contrib/pf/net/pf_if.c:525
#491 0xffffffff801d92dc in pfi_kif_update (kif=0xffffff0001ec4700) at /usr/src/sys/contrib/pf/net/pf_if.c:525
#492 0xffffffff801d9c0d in pfi_attach_ifnet_event (arg=Variable "arg" is not available.
) at /usr/src/sys/contrib/pf/net/pf_if.c:895
#493 0xffffffff8053f9f0 in ifhwioctl (cmd=Variable "cmd" is not available.
) at pcpu.h:194
#494 0xffffffff80541871 in if_detach (ifp=0xffffff0001f0d800) at /usr/src/sys/net/if.c:730
#495 0xffffffff804e11f2 in kern_ioctl (td=0xffffff00030e09f0, fd=3, com=2149607720, data=0xffffff0001ea28e0 "carp0") at file.h:266
#496 0xffffffff804e1519 in ioctl (td=0xffffff00030e09f0, uap=0xffffffffafaf7be0) at /usr/src/sys/kern/sys_generic.c:570
#497 0xffffffff80730514 in syscall (frame=0xffffffffafaf7c70) at /usr/src/sys/amd64/amd64/trap.c:841
#498 0xffffffff8071614b in Xpage () at /usr/src/sys/amd64/amd64/exception.S:228
#499 0x0000000800722cfc in ?? ()

Fix: this patch will check:
*) if group name already exists when renaming interface
*) if interface already exists when adding interface to group


Patch attached with submission follows:
How-To-Repeat: # ifconfig em0 group externals
# ifconfig em0 name externals

or

# ifconfig carp0 create
# ifconfig carp0 name carp


but the following works fine:

# ifconfig em0 group externals
# ifconfig fxp0 name externals
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2008-09-02 23:34:07 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-pf

Over to maintainer(s).
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:46:15 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 3 ben 2022-02-24 01:35:00 UTC
This is showing up with wireguard, where the wireguard tools create an if_wg interface named "wg" by default.

root@freebsd:~ # uname -v
FreeBSD 13.0-RELEASE-p7 #0: Mon Jan 31 18:24:03 UTC 2022     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC

root@freebsd:~ # ifconfig wg create name wg
wg

root@freebsd:~ # kldload pf

Fatal double fault
rip 0xffffffff823780ec rsp 0xfffffe004b1e8000 rbp 0xfffffe004b1e8020
rax 0xfffff8000381ed00 rdx 0 rbx 0xfffff8000357b7a0
rcx 0xfffff8000541f900 rsi 0xfffff80005687600 rdi 0xfffff8000541f900
r8 0 r9 0xc350 r10 0x3
r11 0 r12 0x80 r13 0xfffffe004b1ebb98
r14 0xfffff8000541f900 r15 0xfffffe004d38b500 rflags 0x286
cs 0x20 ss 0x28 ds 0x3b es 0x3b fs 0x13 gs 0x1b
fsbase 0x80028f120 gsbase 0xffffffff82211000 kgsbase 0
cpuid = 1; apic id = 01
panic: double fault
cpuid = 1
time = 1645646385
KDB: stack backtrace:
Uptime: 1m23s
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:39:53 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>