Source-Changes-HG archive

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

[src/pgoyette-compat]: src Remove fixed allocation of modules' "required" lis...



details:   https://anonhg.NetBSD.org/src/rev/86121d94a382
branches:  pgoyette-compat
changeset: 321146:86121d94a382
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Apr 03 08:29:44 2018 +0000

description:
Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries).  Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT.  Update the compat_80
and compat_netbsd32 modules as needed.

diffstat:

 doc/COMPAT-branch-notes               |    5 +
 lib/libc/sys/modctl.2                 |   26 +-
 sbin/modstat/main.c                   |   30 ++-
 sys/compat/common/Makefile.sysio      |    5 +-
 sys/compat/common/compat_80_mod.c     |    6 +-
 sys/compat/common/compat_mod.h        |    4 +-
 sys/compat/common/files.common        |    3 +-
 sys/compat/common/kern_mod_80.c       |  203 ++++++++++++++++++++++
 sys/compat/netbsd32/netbsd32_module.c |  312 +++++++++++++++++++++++++++++++--
 sys/kern/compat_stub.c                |    7 +-
 sys/kern/sys_module.c                 |  137 +++++++++++---
 sys/modules/compat_80/Makefile        |    3 +-
 sys/sys/compat_stub.h                 |    8 +-
 sys/sys/module.h                      |   27 ++-
 14 files changed, 685 insertions(+), 91 deletions(-)

diffs (truncated from 1179 to 300 lines):

diff -r 640162ab246e -r 86121d94a382 doc/COMPAT-branch-notes
--- a/doc/COMPAT-branch-notes   Mon Apr 02 00:18:43 2018 +0000
+++ b/doc/COMPAT-branch-notes   Tue Apr 03 08:29:44 2018 +0000
@@ -27,6 +27,11 @@
    defopt/defflag lines in the config files* as needed, to insure that
    built-in dependencies get resolved.
 
+8. Fixed limits on the number of module depedencies and maximum
+   recursion level have been removed.  Previous code for reporting
+   module status to userland has been versioned and moved to the
+   compat_80 module.
+
 
 TODO
 ----
diff -r 640162ab246e -r 86121d94a382 lib/libc/sys/modctl.2
--- a/lib/libc/sys/modctl.2     Mon Apr 02 00:18:43 2018 +0000
+++ b/lib/libc/sys/modctl.2     Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: modctl.2,v 1.13 2017/07/03 21:32:50 wiz Exp $
+.\"    $NetBSD: modctl.2,v 1.13.4.1 2018/04/03 08:29:44 pgoyette Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -74,9 +74,19 @@
 argument should be a
 .Em struct iovec
 pointing to a suitable block of memory.
-The kernel will fill this block with an array of
+The kernel will fill this block with
+.Bl -bullet 
+.It
+a count of the number of modules loaded (including aliases),
+.It
+an array of
 .Em modstat_t
-structures, one per loaded module.
+structures, one per loaded module, and
+.It
+a series of NUL-terminated strings containing the modules'
+required modules lists.
+.El
+.Pp
 If the block is not large enough, the data returned will be truncated
 to fit.
 The kernel will then update the
@@ -146,9 +156,6 @@
 .Bl -tag -width aaaaaaaa
 .It Fa "char ms_name[MAXMODNAME]"
 The name of the module.
-.It Fa "char ms_required[MAXMODNAME * MAXMODDEPS]"
-The list of modules required by this module
-as a comma-delimited list of module names.
 .It Fa "modsrc_t ms_source"
 One of the following enumerated constants:
 .Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
@@ -172,14 +179,13 @@
 Executable file format.
 .It Dv MODULE_CLASS_MISC
 Miscellaneous.
-.It Dv MODULE_CLASS_ANY
-Any module class.
-.\" XXX: is MODULE_CLASS_ANY ever returned by this interface?
 .El
 .It Fa "uint64_t ms_addr"
 The load address within the kernel.
+(This value is available only for privileged users.)
 .It Fa "u_int ms_size"
 Loaded size of the module.
+(This value is available only for privileged users.)
 .It Fa "u_int ms_refcnt"
 Current number of live references to this module.
 .It Fa "u_int ms_flags"
@@ -190,6 +196,8 @@
 .It Dv MODFLAG_AUTO_LOADED
 The module was auto-loaded by the operating system.
 .El
+.It Fa "uint_ms_reqoffset"
+The offset (in bytes) from the beginning of the required-module data.
 .El
 .Sh RETURN VALUES
 Upon successful completion, the value returned is 0.
diff -r 640162ab246e -r 86121d94a382 sbin/modstat/main.c
--- a/sbin/modstat/main.c       Mon Apr 02 00:18:43 2018 +0000
+++ b/sbin/modstat/main.c       Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.24.12.1 2018/03/10 10:33:40 pgoyette Exp $  */
+/*     $NetBSD: main.c,v 1.24.12.2 2018/04/03 08:29:44 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.24.12.1 2018/03/10 10:33:40 pgoyette Exp $");
+__RCSID("$NetBSD: main.c,v 1.24.12.2 2018/04/03 08:29:44 pgoyette Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -81,6 +81,7 @@
        int ch, rc, modauto = 1;
        size_t maxnamelen = 16, i, modautolen;
        char loadable = '\0';
+       const char *reqoff, *req;
        bool address = false;
 
        name = NULL;
@@ -177,29 +178,36 @@
                len = iov.iov_len;
        }
 
-       len = iov.iov_len / sizeof(modstat_t);
-       qsort(iov.iov_base, len, sizeof(modstat_t), modstatcmp);
-       for (i = 0, ms = iov.iov_base; i < len; i++, ms++) {
+       len = *(int *)iov.iov_base;
+       ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
+
+       qsort(ms, len, sizeof(modstat_t), modstatcmp);
+       for (i = 0; i < len; i++, ms++) {
                size_t namelen = strlen(ms->ms_name);
                if (maxnamelen < namelen)
                        maxnamelen = namelen;
        }
+       ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
+       reqoff = (char *)(&ms[len]);
+
        printf("%-*s %-8s %-8s %-4s %5s ",
            (int)maxnamelen, "NAME", "CLASS", "SOURCE", "FLAG", "REFS");
        if (address)
                printf("%-16s ", "ADDRESS");
        printf("%7s %s \n", "SIZE", "REQUIRES");
-       for (ms = iov.iov_base; len != 0; ms++, len--) {
+
+       for (; len != 0; ms++, len--) {
                const char *class;
                const char *source;
 
+               if (ms->ms_reqoffset == 0)
+                       req = "-";
+               else {
+                       req = &reqoff[ms->ms_reqoffset];
+               }
                if (name != NULL && strcmp(ms->ms_name, name) != 0) {
                        continue;
                }
-               if (ms->ms_required[0] == '\0') {
-                       ms->ms_required[0] = '-';
-                       ms->ms_required[1] = '\0';
-               }
                if (ms->ms_size == 0) {
                        sbuf[0] = '-';
                        sbuf[1] = '\0';
@@ -221,7 +229,7 @@
                    ms->ms_refcnt);
                if (address)
                        printf("%-16" PRIx64 " ", ms->ms_addr);
-               printf("%7s %s\n", sbuf, ms->ms_required);
+               printf("%7s %s\n", sbuf, (req));
        }
 
        exit(EXIT_SUCCESS);
diff -r 640162ab246e -r 86121d94a382 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio  Mon Apr 02 00:18:43 2018 +0000
+++ b/sys/compat/common/Makefile.sysio  Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.sysio,v 1.7.18.19 2018/03/29 23:23:03 pgoyette Exp $
+#      $NetBSD: Makefile.sysio,v 1.7.18.20 2018/04/03 08:29:44 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -45,6 +45,9 @@
 # Compatibility code for NetBSD 7.0
 SRCS+= rtsock_70.c uipc_usrreq_70.c
 
+# Compatability code for NetBSD 8.0
+SRCS+= kern_mod_80.c
+
 # More compatibility code for NetBSD 5.0
 .PATH: ${S}/opencrypto
 SRCS+= ocryptodev.c
diff -r 640162ab246e -r 86121d94a382 sys/compat/common/compat_80_mod.c
--- a/sys/compat/common/compat_80_mod.c Mon Apr 02 00:18:43 2018 +0000
+++ b/sys/compat/common/compat_80_mod.c Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_80_mod.c,v 1.1.2.6 2018/03/24 08:10:49 pgoyette Exp $   */
+/*     $NetBSD: compat_80_mod.c,v 1.1.2.7 2018/04/03 08:29:44 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_80_mod.c,v 1.1.2.6 2018/03/24 08:10:49 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_80_mod.c,v 1.1.2.7 2018/04/03 08:29:44 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -46,6 +46,7 @@
 int compat_80_init(void)
 {
 
+       kern_mod_80_init();
        raidframe_80_init();
 
        return 0;
@@ -55,6 +56,7 @@
 {
 
        raidframe_80_fini();
+       kern_mod_80_fini();
 
        return 0;
 }
diff -r 640162ab246e -r 86121d94a382 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Mon Apr 02 00:18:43 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.1.42.17 2018/03/31 09:17:35 pgoyette Exp $    */
+/*     $NetBSD: compat_mod.h,v 1.1.42.18 2018/04/03 08:29:44 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -42,6 +42,8 @@
 #ifdef COMPAT_80
 int compat_80_init(void);
 int compat_80_fini(void);
+void kern_mod_80_init(void);
+void kern_mod_80_fini(void);
 #endif
 
 #ifdef COMPAT_70
diff -r 640162ab246e -r 86121d94a382 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Mon Apr 02 00:18:43 2018 +0000
+++ b/sys/compat/common/files.common    Tue Apr 03 08:29:44 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.common,v 1.1.2.29 2018/03/31 09:17:35 pgoyette Exp $
+#      $NetBSD: files.common,v 1.1.2.30 2018/04/03 08:29:44 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -96,6 +96,7 @@
 
 # Compatability code for NetBSD 8.0
 file   compat/common/compat_80_mod.c           compat_80
+file   compat/common/kern_mod_80.c             compat_80
 
 #
 # Sources for sysv ipc compatibility across the versions.
diff -r 640162ab246e -r 86121d94a382 sys/compat/common/kern_mod_80.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/kern_mod_80.c   Tue Apr 03 08:29:44 2018 +0000
@@ -0,0 +1,203 @@
+/*     $NetBSD: kern_mod_80.c,v 1.1.2.1 2018/04/03 08:29:44 pgoyette Exp $     */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * System calls relating to loadable modules.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: kern_mod_80.c,v 1.1.2.1 2018/04/03 08:29:44 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_modular.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/namei.h>
+#include <sys/kauth.h>
+#include <sys/kmem.h>
+#include <sys/kobj.h>



Home | Main Index | Thread Index | Old Index