Sun Mar 11 08:32:21 2018 UTC ()
Since we use pointer semantics when walking the alias lists, declare
the pointer variable accordingly.


(pgoyette)
diff -r1.130.2.2 -r1.130.2.3 src/sys/kern/kern_module.c
diff -r1.23.2.2 -r1.23.2.3 src/sys/kern/sys_module.c

cvs diff -r1.130.2.2 -r1.130.2.3 src/sys/kern/kern_module.c (expand / switch to unified diff)

--- src/sys/kern/kern_module.c 2018/03/11 07:25:59 1.130.2.2
+++ src/sys/kern/kern_module.c 2018/03/11 08:32:21 1.130.2.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_module.c,v 1.130.2.2 2018/03/11 07:25:59 pgoyette Exp $ */ 1/* $NetBSD: kern_module.c,v 1.130.2.3 2018/03/11 08:32:21 pgoyette 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 * This code is derived from software developed for The NetBSD Foundation 7 * This code is derived from software developed for The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * Kernel module support. 33 * Kernel module support.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.2 2018/03/11 07:25:59 pgoyette Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.3 2018/03/11 08:32:21 pgoyette Exp $");
38 38
39#define _MODULE_INTERNAL 39#define _MODULE_INTERNAL
40 40
41#ifdef _KERNEL_OPT 41#ifdef _KERNEL_OPT
42#include "opt_ddb.h" 42#include "opt_ddb.h"
43#include "opt_modular.h" 43#include "opt_modular.h"
44#endif 44#endif
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/systm.h> 47#include <sys/systm.h>
48#include <sys/kernel.h> 48#include <sys/kernel.h>
49#include <sys/proc.h> 49#include <sys/proc.h>
50#include <sys/kauth.h> 50#include <sys/kauth.h>
@@ -656,27 +656,27 @@ module_unload(const char *name) @@ -656,27 +656,27 @@ module_unload(const char *name)
656 kernconfig_unlock(); 656 kernconfig_unlock();
657 657
658 return error; 658 return error;
659} 659}
660 660
661/* 661/*
662 * module_alias_lookup 662 * module_alias_lookup
663 * 663 *
664 * locate a name within a module's alias list 664 * locate a name within a module's alias list
665 */ 665 */
666int 666int
667module_alias_lookup(const char *name, module_t *mod) 667module_alias_lookup(const char *name, module_t *mod)
668{ 668{
669 const char * const aliasp[]; 669 const char * const *aliasp;
670 670
671 aliasp = *mod->mod_info->mi_aliases; 671 aliasp = *mod->mod_info->mi_aliases;
672 if (aliasp == NULL) 672 if (aliasp == NULL)
673 return 0; 673 return 0;
674 while (*aliasp) 674 while (*aliasp)
675 if (strcmp(*aliasp++, name) == 0) 675 if (strcmp(*aliasp++, name) == 0)
676 return 1; 676 return 1;
677 return 0; 677 return 0;
678} 678}
679 679
680/* 680/*
681 * module_lookup: 681 * module_lookup:
682 * 682 *
@@ -774,27 +774,27 @@ module_enqueue(module_t *mod) @@ -774,27 +774,27 @@ module_enqueue(module_t *mod)
774} 774}
775 775
776/* 776/*
777 * module_do_builtin: 777 * module_do_builtin:
778 * 778 *
779 * Initialize a module from the list of modules that are 779 * Initialize a module from the list of modules that are
780 * already linked into the kernel. 780 * already linked into the kernel.
781 */ 781 */
782static int 782static int
783module_do_builtin(const module_t *pmod, const char *name, module_t **modp, 783module_do_builtin(const module_t *pmod, const char *name, module_t **modp,
784 prop_dictionary_t props) 784 prop_dictionary_t props)
785{ 785{
786 const char *p, *s; 786 const char *p, *s;
787 const char * const aliasp[]; 787 const char * const *aliasp;
788 char buf[MAXMODNAME]; 788 char buf[MAXMODNAME];
789 modinfo_t *mi = NULL; 789 modinfo_t *mi = NULL;
790 module_t *mod, *mod2, *mod_loaded, *prev_active; 790 module_t *mod, *mod2, *mod_loaded, *prev_active;
791 size_t len; 791 size_t len;
792 int error; 792 int error;
793 793
794 KASSERT(kernconfig_is_held()); 794 KASSERT(kernconfig_is_held());
795 795
796 /* 796 /*
797 * Search the list to see if we have a module by this name. 797 * Search the list to see if we have a module by this name.
798 */ 798 */
799 TAILQ_FOREACH(mod, &module_builtins, mod_chain) { 799 TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
800 if (strcmp(mod->mod_info->mi_name, name) == 0) { 800 if (strcmp(mod->mod_info->mi_name, name) == 0) {
@@ -900,27 +900,27 @@ module_do_load(const char *name, bool is @@ -900,27 +900,27 @@ module_do_load(const char *name, bool is
900{ 900{
901#define MODULE_MAX_DEPTH 6 901#define MODULE_MAX_DEPTH 6
902 902
903 TAILQ_HEAD(pending_t, module); 903 TAILQ_HEAD(pending_t, module);
904 static int depth = 0; 904 static int depth = 0;
905 static struct pending_t *pending_lists[MODULE_MAX_DEPTH]; 905 static struct pending_t *pending_lists[MODULE_MAX_DEPTH];
906 struct pending_t *pending; 906 struct pending_t *pending;
907 struct pending_t new_pending = TAILQ_HEAD_INITIALIZER(new_pending); 907 struct pending_t new_pending = TAILQ_HEAD_INITIALIZER(new_pending);
908 modinfo_t *mi; 908 modinfo_t *mi;
909 module_t *mod, *mod2, *prev_active; 909 module_t *mod, *mod2, *prev_active;
910 prop_dictionary_t filedict; 910 prop_dictionary_t filedict;
911 char buf[MAXMODNAME]; 911 char buf[MAXMODNAME];
912 const char *s, *p; 912 const char *s, *p;
913 const char * const aliasp[]; 913 const char * const *aliasp;
914 int error; 914 int error;
915 size_t len; 915 size_t len;
916 916
917 KASSERT(kernconfig_is_held()); 917 KASSERT(kernconfig_is_held());
918 918
919 filedict = NULL; 919 filedict = NULL;
920 error = 0; 920 error = 0;
921 921
922 /* 922 /*
923 * Avoid recursing too far. 923 * Avoid recursing too far.
924 */ 924 */
925 if (++depth > MODULE_MAX_DEPTH) { 925 if (++depth > MODULE_MAX_DEPTH) {
926 module_error("recursion too deep for `%s' %d > %d", name, 926 module_error("recursion too deep for `%s' %d > %d", name,

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

--- src/sys/kern/sys_module.c 2018/03/11 07:25:59 1.23.2.2
+++ src/sys/kern/sys_module.c 2018/03/11 08:32:21 1.23.2.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_module.c,v 1.23.2.2 2018/03/11 07:25:59 pgoyette Exp $ */ 1/* $NetBSD: sys_module.c,v 1.23.2.3 2018/03/11 08:32:21 pgoyette 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,27 +21,27 @@ @@ -21,27 +21,27 @@
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.23.2.2 2018/03/11 07:25:59 pgoyette Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23.2.3 2018/03/11 08:32:21 pgoyette Exp $");
35 35
36#ifdef _KERNEL_OPT 36#ifdef _KERNEL_OPT
37#include "opt_modular.h" 37#include "opt_modular.h"
38#endif 38#endif
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/proc.h> 42#include <sys/proc.h>
43#include <sys/namei.h> 43#include <sys/namei.h>
44#include <sys/kauth.h> 44#include <sys/kauth.h>
45#include <sys/kmem.h> 45#include <sys/kmem.h>
46#include <sys/kobj.h> 46#include <sys/kobj.h>
47#include <sys/module.h> 47#include <sys/module.h>
@@ -112,27 +112,27 @@ out1: @@ -112,27 +112,27 @@ out1:
112 112
113static int 113static int
114handle_modctl_stat(struct iovec *iov, void *arg) 114handle_modctl_stat(struct iovec *iov, void *arg)
115{ 115{
116 modstat_t *ms, *mso; 116 modstat_t *ms, *mso;
117 modinfo_t *mi; 117 modinfo_t *mi;
118 module_t *mod; 118 module_t *mod;
119 vaddr_t addr; 119 vaddr_t addr;
120 size_t size; 120 size_t size;
121 size_t mslen; 121 size_t mslen;
122 int error; 122 int error;
123 int mscnt; 123 int mscnt;
124 bool stataddr; 124 bool stataddr;
125 const char * const aliasp[]; 125 const char * const *aliasp;
126 126
127 /* If not privileged, don't expose kernel addresses. */ 127 /* If not privileged, don't expose kernel addresses. */
128 error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE, 128 error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
129 0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL); 129 0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL);
130 stataddr = (error == 0); 130 stataddr = (error == 0);
131 131
132 kernconfig_lock(); 132 kernconfig_lock();
133 mscnt = 0; 133 mscnt = 0;
134 TAILQ_FOREACH(mod, &module_list, mod_chain) { 134 TAILQ_FOREACH(mod, &module_list, mod_chain) {
135 mscnt++; 135 mscnt++;
136 mi = mod->mod_info; 136 mi = mod->mod_info;
137 if ((aliasp = *mi->mi_aliases) != NULL) { 137 if ((aliasp = *mi->mi_aliases) != NULL) {
138 while (*aliasp++ != NULL) 138 while (*aliasp++ != NULL)