Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Convert the coredump_vec modular function pointer to use...
details: https://anonhg.NetBSD.org/src/rev/22ac582a56c9
branches: trunk
changeset: 460937:22ac582a56c9
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Nov 10 14:20:50 2019 +0000
description:
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/kern/compat_stub.c | 7 ++++++-
sys/kern/kern_core.c | 13 +++++++------
sys/kern/kern_sig.c | 9 +++------
sys/kern/sys_ptrace_common.c | 7 ++++---
sys/sys/compat_stub.h | 7 ++++++-
sys/sys/signalvar.h | 7 +------
6 files changed, 27 insertions(+), 23 deletions(-)
diffs (178 lines):
diff -r b33080689c2d -r 22ac582a56c9 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/kern/compat_stub.c Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.16 2019/11/10 13:28:06 pgoyette Exp $ */
+/* $NetBSD: compat_stub.c,v 1.17 2019/11/10 14:20:50 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -279,3 +279,8 @@
* 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 b33080689c2d -r 22ac582a56c9 sys/kern/kern_core.c
--- a/sys/kern/kern_core.c Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/kern/kern_core.c Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_core.c,v 1.26 2019/10/16 18:29:49 christos Exp $ */
+/* $NetBSD: kern_core.c,v 1.27 2019/11/10 14:20:50 pgoyette 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.26 2019/10/16 18:29:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.27 2019/11/10 14:20:50 pgoyette 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,17 +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 = __FPTRCAST(
- int (*)(struct lwp *, const char *), enosys);
+
+ MODULE_HOOK_UNSET(coredump_hook);
return 0;
default:
return ENOTTY;
diff -r b33080689c2d -r 22ac582a56c9 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/kern/kern_sig.c Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.377 2019/11/10 13:28:06 pgoyette Exp $ */
+/* $NetBSD: kern_sig.c,v 1.378 2019/11/10 14:20:50 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.377 2019/11/10 13:28:06 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.378 2019/11/10 14:20:50 pgoyette Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@@ -132,9 +132,6 @@
static void sigacts_poolpage_free(struct pool *, void *);
static void *sigacts_poolpage_alloc(struct pool *, int);
-int (*coredump_vec)(struct lwp *, const char *) =
- __FPTRCAST(int (*)(struct lwp *, const char *), enosys);
-
/*
* DTrace SDT provider definitions
*/
@@ -2289,7 +2286,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 b33080689c2d -r 22ac582a56c9 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.69 2019/10/16 18:29:49 christos Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.70 2019/11/10 14:20:50 pgoyette 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.69 2019/10/16 18:29:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.70 2019/11/10 14:20:50 pgoyette 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 b33080689c2d -r 22ac582a56c9 sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/sys/compat_stub.h Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.20 2019/11/10 13:28:06 pgoyette Exp $ */
+/* $NetBSD: compat_stub.h,v 1.21 2019/11/10 14:20:50 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -366,4 +366,9 @@
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 b33080689c2d -r 22ac582a56c9 sys/sys/signalvar.h
--- a/sys/sys/signalvar.h Sun Nov 10 13:34:52 2019 +0000
+++ b/sys/sys/signalvar.h Sun Nov 10 14:20:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: signalvar.h,v 1.98 2019/11/10 13:28:06 pgoyette Exp $ */
+/* $NetBSD: signalvar.h,v 1.99 2019/11/10 14:20:50 pgoyette Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -202,11 +202,6 @@
extern struct pool ksiginfo_pool;
/*
- * Modularity / compatibility.
- */
-extern int (*coredump_vec)(struct lwp *, const char *);
-
-/*
* firstsig:
*
* Return the first signal in a signal set.
Home |
Main Index |
Thread Index |
Old Index