Bug 256757

Summary: net/realtek-re-kmod: kernel panic when running kernel with INVARIANTS
Product: Ports & Packages Reporter: Niels Bakker <niels=freebsd>
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed FIXED    
Severity: Affects Only Me CC: kib
Priority: --- Keywords: crash
Version: LatestFlags: bugzilla: maintainer-feedback? (ale)
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
patch-lock none

Description Niels Bakker 2021-06-21 20:05:06 UTC
...
re0: <Realtek PCIe 2.5GbE Family Controller> port 0xd000-0xd0ff mem 0xf7a10000-0xf7a1ffff,0xf7a20000-0xf7a23fff irq 18 at device 0.0 on pci5
re0: Using Memory Mapping!
re0: Using 1 MSI-X message
re0: version:1.96.04
re0: Ethernet address: 00:e0:4c:xx:xx:xx

This product is covered by one or more of the following patents:            
US6,570,884, US6,115,776, and US6,327,625.
...
re0: link state changed to UP
panic: _mtx_lock_sleep: recursed on non-recursive mutex re0 @ if_re.c:7085

cpuid = 1
time = 1623711227
KDB: stack backtrace:
#0 0xffffffff80c3b5c5 at kdb_backtrace+0x65
#1 0xffffffff80bf0fa1 at vpanic+0x181
#2 0xffffffff80bf0d73 at panic+0x43
#3 0xffffffff80bce208 at __mtx_lock_sleep+0x478
#4 0xffffffff80bcdd32 at __mtx_lock_flags+0xa2
#5 0xffffffff828e87eb at re_init+0x2b
#6 0xffffffff828e7fbd at re_ioctl+0x1dd
#7 0xffffffff80d04dc5 at ifhwioctl+0xf65
#8 0xffffffff80d05f5f at ifioctl+0x37f
#9 0xffffffff80c5c8c9 at kern_ioctl+0x289
#10 0xffffffff80c5c58a at sys_ioctl+0x12a
#11 0xffffffff81083ede at amd64_syscall+0x12e
#12 0xffffffff81057e2e at fast_syscall_common+0xf8
Uptime: 17s
Dumping 792 out of 16147 MB:..3%..11%..21%..31%..41%..51%..61%..71%..81%..91%

A panic only occurs with INVARIANTS / INVARIANT_SUPPORT in the kernel config.
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2021-06-21 20:58:09 UTC
This should be fixed in the latest commits in
https://github.com/kostikbel/rere

See https://github.com/kostikbel/rere/issues/4
Comment 2 Niels Bakker 2021-06-21 21:56:35 UTC
Created attachment 225980 [details]
patch-lock
Comment 3 Niels Bakker 2021-06-21 21:57:25 UTC
This seems to work, thanks!
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-06-22 05:53:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c83bb257d1cd80e1627375a1875a0764b059620e

commit c83bb257d1cd80e1627375a1875a0764b059620e
Author:     Alex Dupre <ale@FreeBSD.org>
AuthorDate: 2021-06-22 05:51:09 +0000
Commit:     Alex Dupre <ale@FreeBSD.org>
CommitDate: 2021-06-22 05:52:49 +0000

    net/realtek-re-kmod: fix locking bugs.

    PR:             256757
    Submitted by:   Niels Bakker <niels=freebsd@bakker.net>

 net/realtek-re-kmod/Makefile             |   2 +-
 net/realtek-re-kmod/files/patch-if__re.c | 121 ++++++++++++++++++++++++++++---
 2 files changed, 113 insertions(+), 10 deletions(-)