summaryrefslogtreecommitdiffstats
path: root/sys/sys/lkm.h
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-06-17 05:02:30 +0000
committerwpaul <wpaul@FreeBSD.org>1995-06-17 05:02:30 +0000
commit0ddcef0978c695d92c556ad8e96d7a1bbd7c3dc2 (patch)
tree4ab565b9b4cf1c9147c82251dad64a129d5025d3 /sys/sys/lkm.h
parent4137dcf51eb6345e3634175d32e7de4ee84eb893 (diff)
downloadFreeBSD-src-0ddcef0978c695d92c556ad8e96d7a1bbd7c3dc2.zip
FreeBSD-src-0ddcef0978c695d92c556ad8e96d7a1bbd7c3dc2.tar.gz
Close out PR #507 (loading LM_MISC pseudo-lkms twice crashes system).
For the LKM_E_LOAD case of the DISPATCH() macro, use lkmexists() to make sure we don't have another instance the module we're trying to load already loaded _before_ calling the module's load() function. If lkmexists() returns true, return EEXIST without trying to load the module. For most types of modules, the individual dispatch functions in the kernel check for duplicated modules, but for LM_MISC we can't trust the module to do the checks itself. Currently, the kernel does do an lkmexists() check on LM_MISC modules, but not until after the module's load() function has been called, which is too late for it to do any good. If the load() function does irreversible things to the kernel, the belated lkmexists() check forces an unload() and a crash.
Diffstat (limited to 'sys/sys/lkm.h')
-rw-r--r--sys/sys/lkm.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/sys/lkm.h b/sys/sys/lkm.h
index 1c04a2a..d4abfd1 100644
--- a/sys/sys/lkm.h
+++ b/sys/sys/lkm.h
@@ -34,7 +34,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: lkm.h,v 1.3 1994/09/27 20:39:48 phk Exp $
+ * lkm.h,v 1.5 1995/04/20 05:08:51 wpaul Exp
*/
#ifndef _SYS_LKM_H_
@@ -272,6 +272,8 @@ extern int nosys();
int error; \
case LKM_E_LOAD: \
lkmtp->private.lkm_any = (struct lkm_any *)&_module; \
+ if (lkmexists(lkmtp)) /* !!! */ \
+ return EEXIST; \
if (load != nosys && (error = load(lkmtp, cmd))) \
return error; \
break; \
@@ -287,6 +289,7 @@ extern int nosys();
return lkmdispatch(lkmtp, cmd);
int lkmdispatch __P((struct lkm_table *lkmtp, int cmd));
+int lkmexists __P((struct lkm_table *lkmtp));
#endif /* KERNEL */
OpenPOWER on IntegriCloud