[Bug 265484] Adding INVARIANTS to GENERIC 13.1 kernel causes panic in mrsas

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 22 Mar 2023 16:59:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265484

Jérémie Jourdin <jeremie.jourdin@advens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeremie.jourdin@advens.fr

--- Comment #7 from Jérémie Jourdin <jeremie.jourdin@advens.fr> ---
(In reply to Mark Johnston from comment #6)

Hello, 

I faced the same issue running HardenedBSD (13-stable and current) on a HP
Server DL360 Gen 10 plus with BROADCOM AERO-10E2 SAS Raid Controller. kernel
panic occurs as soon as a write access is attempted on /dev/da0.

So I decided to test on FreeBSD and I can confirm that :
 - On FreeBSD-13.2-RC3 -> it works
 - On FreeBSD-14.0-CURRENT -> kernel panic

According to me this problem is related to the "INVARIANTS" options in kernel :
the mrsas driver source code has not been modified to deal with these options.
kernel panic occurs when trying to unlock the "sim_lock" mutex.

With a custom GENERIC kernel without these options (tested on HardenedBSD), it
works.

As a proof of concept, I patched sys/kern/kern_mutex.c to not panic in case of
wrong assertion (!mtx_owned(m)) on the mutex "mrsas_sim_lock" used in
sys/dev/mrsas/mrsas.c. With this workaround in place, even with INVARIANTS
options, no problem with mrsas driver anymore.

Hope it can help to fix this issue, I would be happy to help testing a patch or
anything, do not hesitate.

-- 
You are receiving this mail because:
You are the assignee for the bug.