Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/kern Pull up revision 1.86 (requested by hanken in ti...



details:   https://anonhg.NetBSD.org/src/rev/41565b55fa65
branches:  netbsd-3
changeset: 575335:41565b55fa65
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Apr 13 16:01:38 2005 +0000

description:
Pull up revision 1.86 (requested by hanken in ticket #137):
`lkmlookup()' is called with its name argument either from kernel or from
user space. Add an argument `need_copyin' to only use `copyinstr()' if
the name is from user space.
modstat -n NAME works again.
Reviewed by: Peter Postma <peter%netbsd.org@localhost>

diffstat:

 sys/kern/kern_lkm.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (70 lines):

diff -r 6b40b0ab7b1e -r 41565b55fa65 sys/kern/kern_lkm.c
--- a/sys/kern/kern_lkm.c       Wed Apr 13 15:59:37 2005 +0000
+++ b/sys/kern/kern_lkm.c       Wed Apr 13 16:01:38 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lkm.c,v 1.83 2005/02/26 21:34:55 perry Exp $      */
+/*     $NetBSD: kern_lkm.c,v 1.83.2.1 2005/04/13 16:01:38 tron Exp $   */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.83 2005/02/26 21:34:55 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.83.2.1 2005/04/13 16:01:38 tron Exp $");
 
 #include "opt_ddb.h"
 #include "opt_malloclog.h"
@@ -101,7 +101,7 @@
 static TAILQ_HEAD(lkms_head, lkm_table) lkmods;        /* table of loaded modules */
 static struct lkm_table        *curp;                  /* global for in-progress ops */
 
-static struct lkm_table *lkmlookup(int, char *, int *);
+static struct lkm_table *lkmlookup(int, char *, int, int *);
 static struct lkm_table *lkmalloc(void);
 static void lkmfree(void);
 static void lkmunreserve(int);
@@ -173,7 +173,7 @@
  * Look up for a LKM in the list.
  */
 static struct lkm_table *
-lkmlookup(int i, char *name, int *error)
+lkmlookup(int i, char *name, int need_copyin, int *error)
 {
        struct lkm_table *p;
        char istr[MAXLKMNAME];
@@ -195,9 +195,12 @@
                 * Copy name and lookup id from all loaded
                 * modules.  May fail.
                 */
-               *error = copyinstr(name, istr, MAXLKMNAME - 1, NULL);
-               if (*error)
-                       return (NULL);
+               if (need_copyin) {
+                       *error = copyinstr(name, istr, MAXLKMNAME - 1, NULL);
+                       if (*error)
+                               return (NULL);
+               } else
+                       strncpy(istr, name, MAXLKMNAME - 1);
                istr[MAXLKMNAME - 1] = '\0';
 
                TAILQ_FOREACH(p, &lkmods, link) {
@@ -560,7 +563,7 @@
 
                unloadp = (struct lmc_unload *)data;
 
-               curp = lkmlookup(unloadp->id, unloadp->name, &error);
+               curp = lkmlookup(unloadp->id, unloadp->name, 1, &error);
                if (curp == NULL)
                        break;
 
@@ -580,7 +583,7 @@
 
                statp = (struct lmc_stat *)data;
 
-               if ((curp = lkmlookup(statp->id, statp->name, &error)) == NULL)
+               if ((curp = lkmlookup(statp->id, statp->name, 0, &error)) == NULL)
                        break;
 
                if ((error = (*curp->entry)(curp, LKM_E_STAT, LKM_VERSION)))



Home | Main Index | Thread Index | Old Index