Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Protect against attempting to load modules from the file...
details: https://anonhg.NetBSD.org/src/rev/6d941b915509
branches: trunk
changeset: 755151:6d941b915509
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon May 24 03:50:25 2010 +0000
description:
Protect against attempting to load modules from the filesystem until we
have mounted the root file-system. This allows us to load built-in and
boot-loader-provided modules much earlier during startup.
diffstat:
sys/kern/kern_module.c | 25 +++++++++++++++++++------
sys/kern/vfs_subr.c | 10 ++++++++--
sys/sys/module.h | 6 +++++-
3 files changed, 32 insertions(+), 9 deletions(-)
diffs (130 lines):
diff -r 35ae19acd848 -r 6d941b915509 sys/kern/kern_module.c
--- a/sys/kern/kern_module.c Mon May 24 02:19:10 2010 +0000
+++ b/sys/kern/kern_module.c Mon May 24 03:50:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.65 2010/05/02 11:01:03 pooka Exp $ */
+/* $NetBSD: kern_module.c,v 1.66 2010/05/24 03:50:25 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.65 2010/05/02 11:01:03 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.66 2010/05/24 03:50:25 pgoyette Exp $");
#define _MODULE_INTERNAL
@@ -97,16 +97,26 @@
static bool module_merge_dicts(prop_dictionary_t, const prop_dictionary_t);
-int module_eopnotsupp(void);
+int module_eopnotsupp(const char *, int, bool, module_t *,
+ prop_dictionary_t *);
+
+int (*module_load_vfs_vec)(const char *, int, bool, module_t *,
+ prop_dictionary_t *);
int
-module_eopnotsupp(void)
+module_eopnotsupp(const char *name, int flags, bool autoload, module_t *mod,
+ prop_dictionary_t *filedictp)
{
-
return EOPNOTSUPP;
}
__weak_alias(module_load_vfs,module_eopnotsupp);
+void
+module_load_vfs_init(void)
+{
+ module_load_vfs_vec = module_load_vfs;
+}
+
/*
* module_error:
*
@@ -314,6 +324,8 @@
mutex_init(&module_lock, MUTEX_DEFAULT, IPL_NONE);
cv_init(&module_thread_cv, "modunload");
mutex_init(&module_thread_lock, MUTEX_DEFAULT, IPL_NONE);
+ module_load_vfs_vec = module_eopnotsupp;
+
#ifdef MODULAR /* XXX */
module_init_md();
#endif
@@ -846,7 +858,8 @@
return ENOMEM;
}
- error = module_load_vfs(name, flags, autoload, mod, &filedict);
+ error = (*module_load_vfs_vec)(name, flags, autoload, mod,
+ &filedict);
if (error != 0) {
kmem_free(mod, sizeof(*mod));
depth--;
diff -r 35ae19acd848 -r 6d941b915509 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Mon May 24 02:19:10 2010 +0000
+++ b/sys/kern/vfs_subr.c Mon May 24 03:50:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.400 2010/04/30 10:03:13 pooka Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.401 2010/05/24 03:50:25 pgoyette Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.400 2010/04/30 10:03:13 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.401 2010/05/24 03:50:25 pgoyette Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -119,6 +119,7 @@
#include <sys/atomic.h>
#include <sys/kthread.h>
#include <sys/wapbl.h>
+#include <sys/module.h>
#include <miscfs/genfs/genfs.h>
#include <miscfs/specfs/specdev.h>
@@ -2617,6 +2618,11 @@
initproc->p_cwdi->cwdi_cdir = rootvnode;
vref(initproc->p_cwdi->cwdi_cdir);
initproc->p_cwdi->cwdi_rdir = NULL;
+ /*
+ * Enable loading of modules from the filesystem
+ */
+ module_load_vfs_init();
+
}
return (error);
}
diff -r 35ae19acd848 -r 6d941b915509 sys/sys/module.h
--- a/sys/sys/module.h Mon May 24 02:19:10 2010 +0000
+++ b/sys/sys/module.h Mon May 24 03:50:25 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: module.h,v 1.22 2010/04/26 23:18:51 pooka Exp $ */
+/* $NetBSD: module.h,v 1.23 2010/05/24 03:50:25 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -135,11 +135,15 @@
void module_rele(const char *);
int module_find_section(const char *, void **, size_t *);
void module_thread_kick(void);
+void module_load_vfs_init(void);
void module_whatis(uintptr_t, void (*)(const char *, ...));
void module_print_list(void (*)(const char *, ...));
#ifdef _MODULE_INTERNAL
+extern
+int (*module_load_vfs_vec)(const char *, int, bool, module_t *,
+ prop_dictionary_t *);
int module_load_vfs(const char *, int, bool, module_t *,
prop_dictionary_t *);
void module_error(const char *, ...)
Home |
Main Index |
Thread Index |
Old Index