Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/sys Pull up following revision(s) (requested by pgoye...



details:   https://anonhg.NetBSD.org/src/rev/626f50db77c6
branches:  netbsd-9
changeset: 963234:626f50db77c6
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Nov 11 17:11:07 2019 +0000

description:
Pull up following revision(s) (requested by pgoyette in ticket #413):

        sys/kern/kern_core.c: revision 1.27 (patch)
        sys/kern/kern_sig.c: revision 1.377 (patch)
        sys/kern/kern_sig.c: revision 1.378 (patch)
        sys/kern/sys_sig.c: revision 1.50
        sys/kern/sys_ptrace_common.c: revision 1.70
        sys/kern/compat_stub.c: revision 1.16
        sys/compat/common/kern_sig_16.c: revision 1.4
        sys/kern/compat_stub.c: revision 1.17
        sys/sys/compat_stub.h: revision 1.20
        sys/sys/signalvar.h: revision 1.98
        sys/sys/compat_stub.h: revision 1.21
        sys/sys/signalvar.h: revision 1.99

Convert the sendsig_sigcontext_16 function pointer to use the new
compat_hook mechanism.
XXX Despite being a kernel<-->module abi change, this should be
XXX pulled up to -9

 -

Convert the coredump_vec modular function pointer to use the new
compat_hook mechanism.
XXX Should be pulled up to -9 despite the kernel <--> module ABI
XXX change.

diffstat:

 sys/compat/common/kern_sig_16.c |  12 +++++++-----
 sys/kern/compat_stub.c          |  12 +++++++++++-
 sys/kern/kern_core.c            |  12 +++++++-----
 sys/kern/kern_sig.c             |  17 ++++++-----------
 sys/kern/sys_ptrace_common.c    |   7 ++++---
 sys/kern/sys_sig.c              |  13 ++++++-------
 sys/sys/compat_stub.h           |  16 +++++++++++++++-
 sys/sys/signalvar.h             |   9 +--------
 8 files changed, 57 insertions(+), 41 deletions(-)

diffs (truncated from 317 to 300 lines):

diff -r e3acfa91c340 -r 626f50db77c6 sys/compat/common/kern_sig_16.c
--- a/sys/compat/common/kern_sig_16.c   Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/compat/common/kern_sig_16.c   Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig_16.c,v 1.3 2019/01/27 02:08:39 pgoyette Exp $ */
+/*     $NetBSD: kern_sig_16.c,v 1.3.4.1 2019/11/11 17:11:07 martin Exp $       */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.3 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.3.4.1 2019/11/11 17:11:07 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -84,6 +84,7 @@
 #include <sys/kauth.h>
 #include <sys/wait.h>
 #include <sys/kmem.h>
+#include <sys/compat_stub.h>
 
 #include <uvm/uvm_object.h>
 #include <uvm/uvm_prot.h>
@@ -155,8 +156,8 @@
        emul_netbsd.e_esigcode = esigcode;
        emul_netbsd.e_sigobject = &emul_netbsd_object;
        rw_exit(&exec_lock);
-       KASSERT(sendsig_sigcontext_vec == NULL);
-       sendsig_sigcontext_vec = sendsig_sigcontext;
+       MODULE_HOOK_SET(sendsig_sigcontext_16_hook, "sndsig16",
+          sendsig_sigcontext);
 #endif
 
        return 0;
@@ -188,7 +189,6 @@
                syscall_establish(NULL, kern_sig_16_syscalls);
                return EBUSY;
        }
-       sendsig_sigcontext_vec = NULL;
 
 #if defined(COMPAT_SIGCONTEXT)
        /*
@@ -204,6 +204,8 @@
        emul_netbsd.e_esigcode = NULL;
        emul_netbsd.e_sigobject = NULL;
        rw_exit(&exec_lock);
+
+       MODULE_HOOK_UNSET(sendsig_sigcontext_16_hook);
 #endif
        return 0;
 }
diff -r e3acfa91c340 -r 626f50db77c6 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/kern/compat_stub.c    Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.15 2019/07/20 18:23:05 christos Exp $    */
+/* $NetBSD: compat_stub.c,v 1.15.2.1 2019/11/11 17:11:07 martin Exp $  */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -274,3 +274,13 @@
  */
 struct netbsd32_machine32_hook_t netbsd32_machine32_hook;
 struct netbsd32_reg_validate_hook_t netbsd32_reg_validate_hook;
+
+/*
+ * Hook for sendsig_sigcontext_16
+ */
+struct sendsig_sigcontext_16_hook_t sendsig_sigcontext_16_hook;
+
+/*
+ * Hook for coredumps
+ */
+struct coredump_hook_t coredump_hook;
diff -r e3acfa91c340 -r 626f50db77c6 sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/kern/kern_core.c      Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.24 2016/07/07 06:55:43 msaitoh Exp $   */
+/*     $NetBSD: kern_core.c,v 1.24.22.1 2019/11/11 17:11:07 martin Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24.22.1 2019/11/11 17:11:07 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -50,6 +50,7 @@
 #include <sys/filedesc.h>
 #include <sys/kauth.h>
 #include <sys/module.h>
+#include <sys/compat_stub.h>
 
 MODULE(MODULE_CLASS_MISC, coredump, NULL);
 
@@ -69,16 +70,17 @@
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               coredump_vec = coredump;
+               MODULE_HOOK_SET(coredump_hook, "coredump", coredump);
                return 0;
        case MODULE_CMD_FINI:
                /*
-                * In theory we don't need to patch this, as the various
+                * In theory we don't need to UNSET this, as the various
                 * exec formats depend on this module.  If this module has
                 * no references, and so can be unloaded, no user programs
                 * can be running and so nothing can call *coredump_vec.
                 */
-               coredump_vec = (int (*)(struct lwp *, const char *))enosys;
+
+               MODULE_HOOK_UNSET(coredump_hook);
                return 0;
        default:
                return ENOTTY;
diff -r e3acfa91c340 -r 626f50db77c6 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/kern/kern_sig.c       Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.364.2.8 2019/10/23 19:25:39 martin Exp $        */
+/*     $NetBSD: kern_sig.c,v 1.364.2.9 2019/11/11 17:11:07 martin Exp $        */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.8 2019/10/23 19:25:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.9 2019/11/11 17:11:07 martin Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -100,6 +100,7 @@
 #include <sys/cpu.h>
 #include <sys/module.h>
 #include <sys/sdt.h>
+#include <sys/compat_stub.h>
 
 #ifdef PAX_SEGVGUARD
 #include <sys/pax.h>
@@ -131,10 +132,6 @@
 static void    sigacts_poolpage_free(struct pool *, void *);
 static void    *sigacts_poolpage_alloc(struct pool *, int);
 
-void (*sendsig_sigcontext_vec)(const struct ksiginfo *, const sigset_t *);
-int (*coredump_vec)(struct lwp *, const char *) =
-    (int (*)(struct lwp *, const char *))enosys;
-
 /*
  * DTrace SDT provider definitions
  */
@@ -2145,10 +2142,8 @@
        case 0:
        case 1:
                /* Compat for 1.6 and earlier. */
-               if (sendsig_sigcontext_vec == NULL) {
-                       break;
-               }
-               (*sendsig_sigcontext_vec)(ksi, mask);
+               MODULE_HOOK_CALL_VOID(sendsig_sigcontext_16_hook, (ksi, mask),
+                   break);
                return;
        case 2:
        case 3:
@@ -2289,7 +2284,7 @@
 
        if (docore) {
                mutex_exit(p->p_lock);
-               error = (*coredump_vec)(l, NULL);
+               MODULE_HOOK_CALL(coredump_hook, (l, NULL), enosys(), error);
 
                if (kern_logsigexit) {
                        int uid = l->l_cred ?
diff -r e3acfa91c340 -r 626f50db77c6 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.58.2.9 2019/10/23 19:25:39 martin Exp $        */
+/*     $NetBSD: sys_ptrace_common.c,v 1.58.2.10 2019/11/11 17:11:07 martin Exp $       */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.58.2.9 2019/10/23 19:25:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.58.2.10 2019/11/11 17:11:07 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -148,6 +148,7 @@
 #include <sys/module.h>
 #include <sys/condvar.h>
 #include <sys/mutex.h>
+#include <sys/compat_stub.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -958,7 +959,7 @@
                path[len] = '\0';
        }
        DPRINTF(("%s: lwp=%d\n", __func__, lt->l_lid));
-       error = (*coredump_vec)(lt, path);
+       MODULE_HOOK_CALL(coredump_hook, (lt, path), enosys(), error);
 out:
        if (path)
                kmem_free(path, len + 1);
diff -r e3acfa91c340 -r 626f50db77c6 sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c        Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/kern/sys_sig.c        Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_sig.c,v 1.47.4.2 2019/11/10 13:24:50 martin Exp $  */
+/*     $NetBSD: sys_sig.c,v 1.47.4.3 2019/11/11 17:11:07 martin Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.47.4.2 2019/11/10 13:24:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.47.4.3 2019/11/11 17:11:07 martin Exp $");
 
 #include "opt_dtrace.h"
 
@@ -81,6 +81,7 @@
 #include <sys/kmem.h>
 #include <sys/module.h>
 #include <sys/sdt.h>
+#include <sys/compat_stub.h>
 
 SDT_PROVIDER_DECLARE(proc);
 SDT_PROBE_DEFINE2(proc, kernel, , signal__clear,
@@ -413,11 +414,9 @@
                                v0v1valid = true;
                        else if ((p->p_lflag & PL_SIGCOMPAT) == 0) {
                                kernconfig_lock();
-                               if (sendsig_sigcontext_vec == NULL) {
-                                       (void)module_autoload("compat_16",
-                                           MODULE_CLASS_ANY);
-                               }
-                               if (sendsig_sigcontext_vec != NULL) {
+                               (void)module_autoload("compat_16",
+                                   MODULE_CLASS_ANY);
+                               if (sendsig_sigcontext_16_hook.hooked) {
                                        /*
                                         * We need to remember if the
                                         * sigcontext method may be useable,
diff -r e3acfa91c340 -r 626f50db77c6 sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h     Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/sys/compat_stub.h     Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_stub.h,v 1.18.2.1 2019/10/21 20:06:17 martin Exp $      */
+/*     $NetBSD: compat_stub.h,v 1.18.2.2 2019/11/11 17:11:07 martin Exp $      */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,6 +35,7 @@
 #include <sys/module_hook.h>
 #include <sys/param.h>
 #include <sys/socket.h>
+#include <sys/sigtypes.h>
 
 /*
  * NOTE: If you make changes here, please remember to update the
@@ -357,4 +358,17 @@
 MODULE_HOOK(netbsd32_machine32_hook, const char *, (void));
 MODULE_HOOK(netbsd32_reg_validate_hook, int,
     (struct lwp *, const struct reg *));
+
+/*
+ * Hook for compat_16 sendsig_sigcontext
+ */
+struct ksiginfo;
+MODULE_HOOK(sendsig_sigcontext_16_hook, void,
+    (const struct ksiginfo *, const sigset_t *));
+
+/*
+ * Hook for coredumps
+ */
+MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
+
 #endif /* _SYS_COMPAT_STUB_H */
diff -r e3acfa91c340 -r 626f50db77c6 sys/sys/signalvar.h
--- a/sys/sys/signalvar.h       Sun Nov 10 13:26:20 2019 +0000
+++ b/sys/sys/signalvar.h       Mon Nov 11 17:11:07 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signalvar.h,v 1.93.2.3 2019/10/21 20:13:09 martin Exp $        */
+/*     $NetBSD: signalvar.h,v 1.93.2.4 2019/11/11 17:11:07 martin Exp $        */



Home | Main Index | Thread Index | Old Index