Sun May 3 13:07:39 2009 UTC ()
Pull up following revision(s) (requested by skrll in ticket #729):
	sys/kern/sys_module.c: revision 1.9
copyin the modctl_load_t for the non-x86 world. Fixes PR/41294.


(bouyer)
diff -r1.8 -r1.8.4.1 src/sys/kern/sys_module.c

cvs diff -r1.8 -r1.8.4.1 src/sys/kern/sys_module.c (expand / switch to unified diff)

--- src/sys/kern/sys_module.c 2008/10/22 11:16:29 1.8
+++ src/sys/kern/sys_module.c 2009/05/03 13:07:39 1.8.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_module.c,v 1.8 2008/10/22 11:16:29 ad Exp $ */ 1/* $NetBSD: sys_module.c,v 1.8.4.1 2009/05/03 13:07:39 bouyer Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,43 +21,41 @@ @@ -21,43 +21,41 @@
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * System calls relating to loadable modules. 30 * System calls relating to loadable modules.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.8 2008/10/22 11:16:29 ad Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.8.4.1 2009/05/03 13:07:39 bouyer Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/proc.h> 38#include <sys/proc.h>
39#include <sys/namei.h> 39#include <sys/namei.h>
40#include <sys/kmem.h> 40#include <sys/kmem.h>
41#include <sys/kobj.h> 41#include <sys/kobj.h>
42#include <sys/module.h> 42#include <sys/module.h>
43#include <sys/syscall.h> 43#include <sys/syscall.h>
44#include <sys/syscallargs.h> 44#include <sys/syscallargs.h>
45 45
46static int 46static int
47handle_modctl_load(void *arg) 47handle_modctl_load(modctl_load_t *ml)
48{ 48{
49 modctl_load_t *ml = (modctl_load_t *)arg; 
50 
51 char *path; 49 char *path;
52 char *props; 50 char *props;
53 int error; 51 int error;
54 prop_dictionary_t dict; 52 prop_dictionary_t dict;
55 size_t propslen; 53 size_t propslen;
56 54
57 if ((ml->ml_props != NULL && ml->ml_propslen == 0) || 55 if ((ml->ml_props != NULL && ml->ml_propslen == 0) ||
58 (ml->ml_props == NULL && ml->ml_propslen > 0)) { 56 (ml->ml_props == NULL && ml->ml_propslen > 0)) {
59 error = EINVAL; 57 error = EINVAL;
60 goto out1; 58 goto out1;
61 } 59 }
62 60
63 path = PNBUF_GET(); 61 path = PNBUF_GET();
@@ -101,34 +99,38 @@ sys_modctl(struct lwp *l, const struct s @@ -101,34 +99,38 @@ sys_modctl(struct lwp *l, const struct s
101{ 99{
102 /* { 100 /* {
103 syscallarg(int) cmd; 101 syscallarg(int) cmd;
104 syscallarg(void *) arg; 102 syscallarg(void *) arg;
105 } */ 103 } */
106 char buf[MAXMODNAME]; 104 char buf[MAXMODNAME];
107 size_t mslen; 105 size_t mslen;
108 module_t *mod; 106 module_t *mod;
109 modinfo_t *mi; 107 modinfo_t *mi;
110 modstat_t *ms, *mso; 108 modstat_t *ms, *mso;
111 vaddr_t addr; 109 vaddr_t addr;
112 size_t size; 110 size_t size;
113 struct iovec iov; 111 struct iovec iov;
 112 modctl_load_t ml;
114 int error; 113 int error;
115 void *arg; 114 void *arg;
116 115
117 arg = SCARG(uap, arg); 116 arg = SCARG(uap, arg);
118 117
119 switch (SCARG(uap, cmd)) { 118 switch (SCARG(uap, cmd)) {
120 case MODCTL_LOAD: 119 case MODCTL_LOAD:
121 error = handle_modctl_load(arg); 120 error = copyin(arg, &ml, sizeof(ml));
 121 if (error != 0)
 122 break;
 123 error = handle_modctl_load(&ml);
122 break; 124 break;
123 125
124 case MODCTL_UNLOAD: 126 case MODCTL_UNLOAD:
125 error = copyinstr(arg, buf, sizeof(buf), NULL); 127 error = copyinstr(arg, buf, sizeof(buf), NULL);
126 if (error == 0) { 128 if (error == 0) {
127 error = module_unload(buf); 129 error = module_unload(buf);
128 } 130 }
129 break; 131 break;
130 132
131 case MODCTL_STAT: 133 case MODCTL_STAT:
132 error = copyin(arg, &iov, sizeof(iov)); 134 error = copyin(arg, &iov, sizeof(iov));
133 if (error != 0) { 135 if (error != 0) {
134 break; 136 break;