Module Name: src
Committed By: pgoyette
Date: Sun Nov 10 13:28:07 UTC 2019
Modified Files:
src/sys/compat/common: kern_sig_16.c
src/sys/kern: compat_stub.c kern_sig.c sys_sig.c
src/sys/sys: compat_stub.h signalvar.h
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/common/kern_sig_16.c
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.376 -r1.377 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/sys_sig.c
cvs rdiff -u -r1.19 -r1.20 src/sys/sys/compat_stub.h
cvs rdiff -u -r1.97 -r1.98 src/sys/sys/signalvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/common/kern_sig_16.c
diff -u src/sys/compat/common/kern_sig_16.c:1.3 src/sys/compat/common/kern_sig_16.c:1.4
--- src/sys/compat/common/kern_sig_16.c:1.3 Sun Jan 27 02:08:39 2019
+++ src/sys/compat/common/kern_sig_16.c Sun Nov 10 13:28:06 2019
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig_16.
#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 @@ kern_sig_16_init(void)
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 @@ kern_sig_16_fini(void)
syscall_establish(NULL, kern_sig_16_syscalls);
return EBUSY;
}
- sendsig_sigcontext_vec = NULL;
#if defined(COMPAT_SIGCONTEXT)
/*
@@ -204,6 +204,8 @@ kern_sig_16_fini(void)
emul_netbsd.e_esigcode = NULL;
emul_netbsd.e_sigobject = NULL;
rw_exit(&exec_lock);
+
+ MODULE_HOOK_UNSET(sendsig_sigcontext_16_hook);
#endif
return 0;
}
Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.15 src/sys/kern/compat_stub.c:1.16
--- src/sys/kern/compat_stub.c:1.15 Sat Jul 20 18:23:05 2019
+++ src/sys/kern/compat_stub.c Sun Nov 10 13:28:06 2019
@@ -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 ifmedia_80_post_hook_t ifmedia_80
*/
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;
Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.376 src/sys/kern/kern_sig.c:1.377
--- src/sys/kern/kern_sig.c:1.376 Mon Oct 21 17:07:00 2019
+++ src/sys/kern/kern_sig.c Sun Nov 10 13:28:06 2019
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v
#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 sigswitch_unlock_and_switch_
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 @@ sendsig(const struct ksiginfo *ksi, cons
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:
Index: src/sys/kern/sys_sig.c
diff -u src/sys/kern/sys_sig.c:1.49 src/sys/kern/sys_sig.c:1.50
--- src/sys/kern/sys_sig.c:1.49 Sat Nov 9 23:34:13 2019
+++ src/sys/kern/sys_sig.c Sun Nov 10 13:28:06 2019
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v
#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 @@ sigaction1(struct lwp *l, int signum, co
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,
Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.19 src/sys/sys/compat_stub.h:1.20
--- src/sys/sys/compat_stub.h:1.19 Fri Sep 27 00:32:03 2019
+++ src/sys/sys/compat_stub.h Sun Nov 10 13:28:06 2019
@@ -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 @@ struct reg;
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 */
Index: src/sys/sys/signalvar.h
diff -u src/sys/sys/signalvar.h:1.97 src/sys/sys/signalvar.h:1.98
--- src/sys/sys/signalvar.h:1.97 Sat Oct 12 19:57:09 2019
+++ src/sys/sys/signalvar.h Sun Nov 10 13:28:06 2019
@@ -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 @@ extern struct pool ksiginfo_pool;
/*
* Modularity / compatibility.
*/
-extern void (*sendsig_sigcontext_vec)(const struct ksiginfo *,
- const sigset_t *);
extern int (*coredump_vec)(struct lwp *, const char *);
/*