Sat Jun 5 22:21:15 2021 UTC ()
As with usbverbose and pciverbose, these modules are not safe to be
auto-unloaded.  Disable for now.

All of these need to be updated with an appropriate refcount mechanism
to ensure that the code and/or tables aren't unloaded while they are
being used.


(pgoyette)
diff -r1.6 -r1.7 src/sys/dev/mii/mii_verbose.c
diff -r1.34 -r1.35 src/sys/dev/scsipi/scsipi_verbose.c

cvs diff -r1.6 -r1.7 src/sys/dev/mii/mii_verbose.c (expand / switch to unified diff)

--- src/sys/dev/mii/mii_verbose.c 2019/03/25 09:46:24 1.6
+++ src/sys/dev/mii/mii_verbose.c 2021/06/05 22:21:15 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mii_verbose.c,v 1.6 2019/03/25 09:46:24 msaitoh Exp $ */ 1/* $NetBSD: mii_verbose.c,v 1.7 2021/06/05 22:21:15 pgoyette Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center, and by Frank van der Linden. 9 * NASA Ames Research Center, and by Frank van der Linden.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -45,52 +45,54 @@ @@ -45,52 +45,54 @@
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */ 55 */
56 56
57#include <sys/cdefs.h> 57#include <sys/cdefs.h>
58__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.6 2019/03/25 09:46:24 msaitoh Exp $"); 58__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.7 2021/06/05 22:21:15 pgoyette Exp $");
59 59
60#include <sys/module.h> 60#include <sys/module.h>
61#include <dev/mii/miidevs.h> 61#include <dev/mii/miidevs.h>
62#include <dev/mii/miidevs_data.h> 62#include <dev/mii/miidevs_data.h>
63#include <dev/mii/mii_verbose.h> 63#include <dev/mii/mii_verbose.h>
64 64
65const char * mii_get_descr_real(int, int); 65const char * mii_get_descr_real(int, int);
66 66
67MODULE(MODULE_CLASS_MISC, miiverbose, NULL); 67MODULE(MODULE_CLASS_MISC, miiverbose, NULL);
68 68
69static int 69static int
70miiverbose_modcmd(modcmd_t cmd, void *arg) 70miiverbose_modcmd(modcmd_t cmd, void *arg)
71{ 71{
72 static const char *(*saved_mii_get_descr)(int, int); 72 static const char *(*saved_mii_get_descr)(int, int);
73 73
74 switch (cmd) { 74 switch (cmd) {
75 case MODULE_CMD_INIT: 75 case MODULE_CMD_INIT:
76 saved_mii_get_descr = mii_get_descr; 76 saved_mii_get_descr = mii_get_descr;
77 mii_get_descr = mii_get_descr_real; 77 mii_get_descr = mii_get_descr_real;
78 mii_verbose_loaded = 1; 78 mii_verbose_loaded = 1;
79 return 0; 79 return 0;
80 case MODULE_CMD_FINI: 80 case MODULE_CMD_FINI:
81 mii_get_descr = saved_mii_get_descr; 81 mii_get_descr = saved_mii_get_descr;
82 mii_verbose_loaded = 0; 82 mii_verbose_loaded = 0;
83 return 0; 83 return 0;
 84 casce MODULE_CMD_AUTOUNLOAD:
 85 return EBUSY;
84 default: 86 default:
85 return ENOTTY; 87 return ENOTTY;
86 } 88 }
87} 89}
88 90
89const char * 91const char *
90mii_get_descr_real(int oui, int model) 92mii_get_descr_real(int oui, int model)
91{ 93{
92 int i; 94 int i;
93 95
94 for (i = 0; mii_knowndevs[i].descr != NULL; i++) 96 for (i = 0; mii_knowndevs[i].descr != NULL; i++)
95 if (mii_knowndevs[i].oui == oui && 97 if (mii_knowndevs[i].oui == oui &&
96 mii_knowndevs[i].model == model) 98 mii_knowndevs[i].model == model)

cvs diff -r1.34 -r1.35 src/sys/dev/scsipi/scsipi_verbose.c (expand / switch to unified diff)

--- src/sys/dev/scsipi/scsipi_verbose.c 2018/09/16 23:20:18 1.34
+++ src/sys/dev/scsipi/scsipi_verbose.c 2021/06/05 22:21:15 1.35
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: scsipi_verbose.c,v 1.34 2018/09/16 23:20:18 mrg Exp $ */ 1/* $NetBSD: scsipi_verbose.c,v 1.35 2021/06/05 22:21:15 pgoyette Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum. 8 * by Charles M. Hannum.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.34 2018/09/16 23:20:18 mrg Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: scsipi_verbose.c,v 1.35 2021/06/05 22:21:15 pgoyette Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/time.h> 36#include <sys/time.h>
37#include <sys/proc.h> 37#include <sys/proc.h>
38#include <sys/device.h> 38#include <sys/device.h>
39 39
40#ifdef _KERNEL 40#ifdef _KERNEL
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/module.h> 42#include <sys/module.h>
43#else 43#else
44#include <stdio.h> 44#include <stdio.h>
45#endif 45#endif
46#include <dev/scsipi/scsipi_all.h> 46#include <dev/scsipi/scsipi_all.h>
@@ -843,26 +843,28 @@ scsiverbose_modcmd(modcmd_t cmd, void *a @@ -843,26 +843,28 @@ scsiverbose_modcmd(modcmd_t cmd, void *a
843 switch (cmd) { 843 switch (cmd) {
844 case MODULE_CMD_INIT: 844 case MODULE_CMD_INIT:
845 saved_print_sense = scsipi_print_sense; 845 saved_print_sense = scsipi_print_sense;
846 saved_print_sense_data = scsipi_print_sense_data; 846 saved_print_sense_data = scsipi_print_sense_data;
847 scsipi_print_sense = scsipi_print_sense_real; 847 scsipi_print_sense = scsipi_print_sense_real;
848 scsipi_print_sense_data = scsipi_print_sense_data_real; 848 scsipi_print_sense_data = scsipi_print_sense_data_real;
849 scsi_verbose_loaded = 1; 849 scsi_verbose_loaded = 1;
850 return 0; 850 return 0;
851 case MODULE_CMD_FINI: 851 case MODULE_CMD_FINI:
852 scsipi_print_sense = saved_print_sense; 852 scsipi_print_sense = saved_print_sense;
853 scsipi_print_sense_data = saved_print_sense_data; 853 scsipi_print_sense_data = saved_print_sense_data;
854 scsi_verbose_loaded = 0; 854 scsi_verbose_loaded = 0;
855 return 0; 855 return 0;
 856 case MODULE_CMD_AUTOUNLOAD:
 857 return EBUSY;
856 default: 858 default:
857 return ENOTTY; 859 return ENOTTY;
858 } 860 }
859} 861}
860#else 862#else
861int (*scsipi_print_sense)(struct scsipi_xfer *, int) = 863int (*scsipi_print_sense)(struct scsipi_xfer *, int) =
862 scsipi_print_sense_real; 864 scsipi_print_sense_real;
863void (*scsipi_print_sense_data)(struct scsi_sense_data *, int) = 865void (*scsipi_print_sense_data)(struct scsi_sense_data *, int) =
864 scsipi_print_sense_data_real;  866 scsipi_print_sense_data_real;
865#endif 867#endif
866 868
867static void 869static void
868asc2ascii(u_char asc, u_char ascq, char *result, size_t l) 870asc2ascii(u_char asc, u_char ascq, char *result, size_t l)