From 7bcaece1a14ea6159682e63e931110f9d520ce67 Mon Sep 17 00:00:00 2001 From: kurt Date: Thu, 25 May 2023 19:35:58 +0000 Subject: [PATCH] Disable witness for mutexes created on the stack which allows the ddb command 'show witness' to succeed without panicking. Leaving witness enabled on these mutexes saves a pointer to struct lock_type on the stack which gets clobbered resulting in a panic in witness_ddb_display_descendants(). okay miod@ --- sys/dev/ic/mfi.c | 5 +++-- sys/dev/ic/mpi.c | 5 +++-- sys/dev/pci/mfii.c | 5 +++-- sys/dev/pci/mpii.c | 5 +++-- sys/scsi/scsi_base.c | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index 724783a8b22..3867bb94e4d 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.188 2022/04/16 19:19:59 naddy Exp $ */ +/* $OpenBSD: mfi.c,v 1.189 2023/05/25 19:35:58 kurt Exp $ */ /* * Copyright (c) 2006 Marco Peereboom * @@ -925,7 +925,8 @@ mfi_poll(struct mfi_softc *sc, struct mfi_ccb *ccb) void mfi_exec(struct mfi_softc *sc, struct mfi_ccb *ccb) { - struct mutex m = MUTEX_INITIALIZER(IPL_BIO); + struct mutex m = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, + MTX_NOWITNESS); #ifdef DIAGNOSTIC if (ccb->ccb_cookie != NULL || ccb->ccb_done != NULL) diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c index 75aa8d22257..5ded2b169df 100644 --- a/sys/dev/ic/mpi.c +++ b/sys/dev/ic/mpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpi.c,v 1.224 2022/04/16 19:19:59 naddy Exp $ */ +/* $OpenBSD: mpi.c,v 1.225 2023/05/25 19:35:58 kurt Exp $ */ /* * Copyright (c) 2005, 2006, 2009 David Gwynne @@ -1263,7 +1263,8 @@ mpi_poll_done(struct mpi_ccb *ccb) void mpi_wait(struct mpi_softc *sc, struct mpi_ccb *ccb) { - struct mutex cookie = MUTEX_INITIALIZER(IPL_BIO); + struct mutex cookie = MUTEX_INITIALIZER_FLAGS( + IPL_BIO, __MTX_NAME, MTX_NOWITNESS); void (*done)(struct mpi_ccb *); done = ccb->ccb_done; diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c index c4daf333751..760b30d1f2f 100644 --- a/sys/dev/pci/mfii.c +++ b/sys/dev/pci/mfii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfii.c,v 1.87 2022/09/25 08:15:43 stsp Exp $ */ +/* $OpenBSD: mfii.c,v 1.88 2023/05/25 19:35:58 kurt Exp $ */ /* * Copyright (c) 2012 David Gwynne @@ -1764,7 +1764,8 @@ mfii_poll_done(struct mfii_softc *sc, struct mfii_ccb *ccb) int mfii_exec(struct mfii_softc *sc, struct mfii_ccb *ccb) { - struct mutex m = MUTEX_INITIALIZER(IPL_BIO); + struct mutex m = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, + MTX_NOWITNESS); #ifdef DIAGNOSTIC if (ccb->ccb_cookie != NULL || ccb->ccb_done != NULL) diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index 2f14f6bf7d9..51da9d5748a 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpii.c,v 1.144 2022/10/18 07:04:20 kn Exp $ */ +/* $OpenBSD: mpii.c,v 1.145 2023/05/25 19:35:58 kurt Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -2857,7 +2857,8 @@ mpii_init_queues(struct mpii_softc *sc) void mpii_wait(struct mpii_softc *sc, struct mpii_ccb *ccb) { - struct mutex mtx = MUTEX_INITIALIZER(IPL_BIO); + struct mutex mtx = MUTEX_INITIALIZER_FLAGS(IPL_BIO, + __MTX_NAME, MTX_NOWITNESS); void (*done)(struct mpii_ccb *); void *cookie; diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 299509c7bc7..50aa10fd6cd 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.280 2022/02/28 14:48:11 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.281 2023/05/25 19:35:58 kurt Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -1497,7 +1497,8 @@ scsi_done(struct scsi_xfer *xs) int scsi_xs_sync(struct scsi_xfer *xs) { - struct mutex cookie = MUTEX_INITIALIZER(IPL_BIO); + struct mutex cookie = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, + MTX_NOWITNESS); int error; #ifdef DIAGNOSTIC -- 2.20.1