Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Convert the sendsig_sigcontext_16 function pointer t...



details:   https://anonhg.NetBSD.org/src/rev/64d37d473e7b
branches:  trunk
changeset: 966662:64d37d473e7b
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Nov 10 13:28:06 2019 +0000

description:
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

diffstat:

 sys/compat/common/kern_sig_16.c |  12 +++++++-----
 sys/kern/compat_stub.c          |   7 ++++++-
 sys/kern/kern_sig.c             |  12 +++++-------
 sys/kern/sys_sig.c              |  13 ++++++-------
 sys/sys/compat_stub.h           |  11 ++++++++++-
 sys/sys/signalvar.h             |   4 +---
 6 files changed, 35 insertions(+), 24 deletions(-)

diffs (208 lines):

diff -r 8582a0d08230 -r 64d37d473e7b sys/compat/common/kern_sig_16.c
--- a/sys/compat/common/kern_sig_16.c   Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/compat/common/kern_sig_16.c   Sun Nov 10 13:28:06 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.4 2019/11/10 13:28:06 pgoyette 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.4 2019/11/10 13:28:06 pgoyette 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 8582a0d08230 -r 64d37d473e7b sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/kern/compat_stub.c    Sun Nov 10 13:28:06 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.16 2019/11/10 13:28:06 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -274,3 +274,8 @@
  */
 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;
diff -r 8582a0d08230 -r 64d37d473e7b sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/kern/kern_sig.c       Sun Nov 10 13:28:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.376 2019/10/21 17:07:00 mgorny Exp $    */
+/*     $NetBSD: kern_sig.c,v 1.377 2019/11/10 13:28:06 pgoyette 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.376 2019/10/21 17:07:00 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.377 2019/11/10 13:28:06 pgoyette 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,7 +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 *) =
     __FPTRCAST(int (*)(struct lwp *, const char *), enosys);
 
@@ -2147,10 +2147,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:
diff -r 8582a0d08230 -r 64d37d473e7b sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c        Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/kern/sys_sig.c        Sun Nov 10 13:28:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_sig.c,v 1.49 2019/11/09 23:34:13 pgoyette Exp $    */
+/*     $NetBSD: sys_sig.c,v 1.50 2019/11/10 13:28:06 pgoyette 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.49 2019/11/09 23:34:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.50 2019/11/10 13:28:06 pgoyette 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 8582a0d08230 -r 64d37d473e7b sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h     Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/sys/compat_stub.h     Sun Nov 10 13:28:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_stub.h,v 1.19 2019/09/27 00:32:03 pgoyette Exp $        */
+/*     $NetBSD: compat_stub.h,v 1.20 2019/11/10 13:28:06 pgoyette 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,12 @@
 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 *));
+
 #endif /* _SYS_COMPAT_STUB_H */
diff -r 8582a0d08230 -r 64d37d473e7b sys/sys/signalvar.h
--- a/sys/sys/signalvar.h       Sun Nov 10 12:07:50 2019 +0000
+++ b/sys/sys/signalvar.h       Sun Nov 10 13:28:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signalvar.h,v 1.97 2019/10/12 19:57:09 kamil Exp $     */
+/*     $NetBSD: signalvar.h,v 1.98 2019/11/10 13:28:06 pgoyette Exp $  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -204,8 +204,6 @@
 /*
  * Modularity / compatibility.
  */
-extern void    (*sendsig_sigcontext_vec)(const struct ksiginfo *,
-                                         const sigset_t *);
 extern int     (*coredump_vec)(struct lwp *, const char *);
 
 /*



Home | Main Index | Thread Index | Old Index