Bug 263929 - panic: Assertion g_debugnet_pcb_inuse failed at /usr/src/sys/net/debugnet.c:608
Summary: panic: Assertion g_debugnet_pcb_inuse failed at /usr/src/sys/net/debugnet.c:608
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Mitchell Horne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-11 21:35 UTC by Martin Filla
Modified: 2022-05-27 16:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Filla 2022-05-11 21:35:35 UTC
Hi,
i discovered kernel panic with work nedump in mode db> 

db> netdump 
netdump: need a destination server address
Usage: netdump -s <server> [-g <gateway> -c <localip> -i <interface>]
Error configuring netdump: 22
db> netdump -s 192.168.42.54 -c 192.168.42.123 -i dwc0
debugnet: overwriting mbuf zone pointers
debugnet_connect: interface 'dwc0' does not support debugnet
panic: Assertion g_debugnet_pcb_inuse failed at /usr/src/sys/net/debugnet.c:608
cpuid = 0
time = 1652304663
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
vpanic() at vpanic+0x174
panic() at panic+0x44
debugnet_connect() at debugnet_connect+0x4a8
netdump_start() at netdump_start+0x128
dump_start() at dump_start+0xc8
cpu_minidumpsys() at cpu_minidumpsys+0x604
dumpsys_generic() at dumpsys_generic+0x64
doadump() at doadump+0x74
db_netdump_cmd() at db_netdump_cmd+0x12c
db_command() at db_command+0x368
db_command_loop() at db_command_loop+0x54
db_trap() at db_trap+0xf8
kdb_trap() at kdb_trap+0x1cc
handle_el1h_sync() at handle_el1h_sync+0x10
--- exception, esr 0xf2000000
kdb_enter() at kdb_enter+0x40
vpanic() at vpanic+0x1b0
panic() at panic+0x44
kdb_sysctl_panic() at kdb_sysctl_panic+0x68
sysctl_root_handler_locked() at sysctl_root_handler_locked+0xe0
sysctl_root() at sysctl_root+0x1ac
userland_sysctl() at userland_sysctl+0x140
sys___sysctl() at sys___sysctl+0x68
do_el0_sync() at do_el0_sync+0x524
handle_el0_sync() at handle_el0_sync+0x40
--- exception, esr 0x56000000
Comment 1 Mitchell Horne freebsd_committer freebsd_triage 2022-05-12 15:50:52 UTC
Hi,

I was able to reproduce this and identify the fix. The change is posted here:
https://reviews.freebsd.org/D35179

Cheers,
Mitchell
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-05-14 13:28:54 UTC
A commit in branch main references this bug:

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

commit a84bf5eaa10c2db8856c7497b63ae3caceac8c17
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-05-14 13:23:08 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-05-14 13:27:53 +0000

    debugnet: fix an errant assertion

    We may call debugnet_free() before g_debugnet_pcb_inuse is true,
    specifically in the cases where the interface is down or does not
    support debugnet. pcb->dp_drv_input is used to hold the real driver
    if_input callback while debugnet is in use, so we can check the status
    of this field in the assertion.

    This can be triggered trivially by trying to configure netdump on an
    unsupported interface at the ddb prompt.

    Initializing the dp_drv_input field to NULL explicitly is not necessary
    but helps display the intent.

    PR:             263929
    Reported by:    Martin Filla <freebsd@sysctl.cz>
    Reviewed by:    cem, markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D35179

 sys/net/debugnet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-05-27 16:23:45 UTC
A commit in branch stable/13 references this bug:

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

commit eda5293cd74a1a75cfa415ffcc0f49242b4622c3
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-05-14 13:23:08 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-05-27 16:22:48 +0000

    debugnet: fix an errant assertion

    We may call debugnet_free() before g_debugnet_pcb_inuse is true,
    specifically in the cases where the interface is down or does not
    support debugnet. pcb->dp_drv_input is used to hold the real driver
    if_input callback while debugnet is in use, so we can check the status
    of this field in the assertion.

    This can be triggered trivially by trying to configure netdump on an
    unsupported interface at the ddb prompt.

    Initializing the dp_drv_input field to NULL explicitly is not necessary
    but helps display the intent.

    PR:             263929
    Reported by:    Martin Filla <freebsd@sysctl.cz>
    Reviewed by:    cem, markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D35179

    (cherry picked from commit a84bf5eaa10c2db8856c7497b63ae3caceac8c17)

 sys/net/debugnet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)