Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Do not not look for modules in the current working directory...
details: https://anonhg.NetBSD.org/src/rev/2f1650b09b75
branches: trunk
changeset: 767993:2f1650b09b75
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Sat Aug 06 08:11:09 2011 +0000
description:
Do not not look for modules in the current working directory first. This is
to prevent from accidentally loading ./module.kmod when we actually wanted to
load module from the system module area.
To load a module from a filesystem path, the module name must contain at
least on path separator character (/), to load a module from the system
module areas, the name must not contain a path separator character:
modload ./mymod.kmod # loads mymod.kmod from the curren directory
modload mymod # loads mymod.kmod from the system module area
diffstat:
sbin/modload/modload.8 | 11 ++++++-----
sys/kern/kern_module_vfs.c | 24 +++++++++++++++---------
sys/kern/subr_kobj_vfs.c | 8 ++++++--
3 files changed, 27 insertions(+), 16 deletions(-)
diffs (109 lines):
diff -r ecebd87352f8 -r 2f1650b09b75 sbin/modload/modload.8
--- a/sbin/modload/modload.8 Sat Aug 06 07:36:20 2011 +0000
+++ b/sbin/modload/modload.8 Sat Aug 06 08:11:09 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: modload.8,v 1.40 2010/12/14 16:23:59 jruoho Exp $
+.\" $NetBSD: modload.8,v 1.41 2011/08/06 08:11:10 mbalmer Exp $
.\"
.\" Copyright (c) 1993 Christopher G. Demetriou
.\" All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
.\"
-.Dd December 14, 2010
+.Dd August 6, 2011
.Dt MODLOAD 8
.Os
.Sh NAME
@@ -57,10 +57,11 @@
.Nm
utility loads a kernel module specified by the
.Ar module
-paramamter into the running system.
+parameter into the running system.
.Pp
-The current working directory is first searched for the module object file.
-If not found there, the default system module areas are searched.
+Modules are loaded from the default system module areas unless the
+.Ar module
+parameter contains a path separator character (/).
.Pp
The options to
.Nm
diff -r ecebd87352f8 -r 2f1650b09b75 sys/kern/kern_module_vfs.c
--- a/sys/kern/kern_module_vfs.c Sat Aug 06 07:36:20 2011 +0000
+++ b/sys/kern/kern_module_vfs.c Sat Aug 06 08:11:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module_vfs.c,v 1.10 2010/11/28 00:26:38 jnemeth Exp $ */
+/* $NetBSD: kern_module_vfs.c,v 1.11 2011/08/06 08:11:09 mbalmer Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module_vfs.c,v 1.10 2010/11/28 00:26:38 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module_vfs.c,v 1.11 2011/08/06 08:11:09 mbalmer Exp $");
#define _MODULE_INTERNAL
#include <sys/param.h>
@@ -77,15 +77,21 @@
path = PNBUF_GET();
if (!autoload) {
- nochroot = false;
- snprintf(path, MAXPATHLEN, "%s", name);
- error = kobj_load_vfs(&mod->mod_kobj, path, nochroot);
+ if (strchr(name, '/') != NULL) {
+ nochroot = false;
+ snprintf(path, MAXPATHLEN, "%s", name);
+ error = kobj_load_vfs(&mod->mod_kobj, path, nochroot);
+ } else
+ error = ENOENT;
}
if (autoload || (error == ENOENT)) {
- nochroot = true;
- snprintf(path, MAXPATHLEN, "%s/%s/%s.kmod",
- module_base, name, name);
- error = kobj_load_vfs(&mod->mod_kobj, path, nochroot);
+ if (strchr(name, '/') == NULL) {
+ nochroot = true;
+ snprintf(path, MAXPATHLEN, "%s/%s/%s.kmod",
+ module_base, name, name);
+ error = kobj_load_vfs(&mod->mod_kobj, path, nochroot);
+ } else
+ error = ENOENT;
}
if (error != 0) {
PNBUF_PUT(path);
diff -r ecebd87352f8 -r 2f1650b09b75 sys/kern/subr_kobj_vfs.c
--- a/sys/kern/subr_kobj_vfs.c Sat Aug 06 07:36:20 2011 +0000
+++ b/sys/kern/subr_kobj_vfs.c Sat Aug 06 08:11:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kobj_vfs.c,v 1.4 2010/11/19 06:44:43 dholland Exp $ */
+/* $NetBSD: subr_kobj_vfs.c,v 1.5 2011/08/06 08:11:09 mbalmer Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
#include <sys/vnode.h>
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kobj_vfs.c,v 1.4 2010/11/19 06:44:43 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj_vfs.c,v 1.5 2011/08/06 08:11:09 mbalmer Exp $");
static void
kobj_close_vfs(kobj_t ko)
@@ -139,6 +139,10 @@
int error;
kobj_t ko;
+ KASSERT(path != NULL);
+ if (strchr(path, '/') == NULL)
+ return ENOENT;
+
cred = kauth_cred_get();
ko = kmem_zalloc(sizeof(*ko), KM_SLEEP);
Home |
Main Index |
Thread Index |
Old Index