Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Arrange so that no options COREDUMP and no options P...



details:   https://anonhg.NetBSD.org/src/rev/651f34c7eccd
branches:  trunk
changeset: 941142:651f34c7eccd
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Oct 19 19:33:01 2020 +0000

description:
Arrange so that no options COREDUMP and no options PTRACE work together.
Thanks to Paul Goyette for testing.

diffstat:

 sys/arch/amd64/conf/MODULAR          |   7 ++++---
 sys/arch/amd64/conf/files.amd64      |   4 ++--
 sys/kern/compat_stub.c               |   4 +++-
 sys/kern/core_elf32.c                |   6 +++---
 sys/kern/files.kern                  |   6 +++---
 sys/kern/kern_core.c                 |  25 ++++++++++++++++++++++---
 sys/kern/kern_sig.c                  |  32 +++++++++++++++++++++++++-------
 sys/modules/coredump/Makefile        |  21 ++++++++++-----------
 sys/modules/exec_elf32/Makefile      |   4 ++--
 sys/modules/exec_elf64/Makefile      |   4 ++--
 sys/modules/ptrace_common/Makefile   |   6 ++++--
 sys/modules/ptrace_common/machdep.mk |  13 +++++++++++++
 sys/sys/compat_stub.h                |   6 +++++-
 sys/sys/exec_elf.h                   |  14 +++++++++-----
 14 files changed, 107 insertions(+), 45 deletions(-)

diffs (truncated from 414 to 300 lines):

diff -r 226e2641606b -r 651f34c7eccd sys/arch/amd64/conf/MODULAR
--- a/sys/arch/amd64/conf/MODULAR       Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/arch/amd64/conf/MODULAR       Mon Oct 19 19:33:01 2020 +0000
@@ -1,11 +1,9 @@
-# $NetBSD: MODULAR,v 1.17 2020/09/27 13:48:49 roy Exp $
+# $NetBSD: MODULAR,v 1.18 2020/10/19 19:33:01 christos Exp $
 #
 # Try to exclude all the drivers in GENERIC that have been modularized
 # XXX: incomplete
 
 include "arch/amd64/conf/GENERIC"
-options        MODULAR         # new style module(7) framework
-options        MODULAR_DEFAULT_AUTOLOAD
 
 -no acpicpu*   at cpu?
 -no est0               at cpu0
@@ -85,6 +83,9 @@
 
 -no options    AIO
 
+-no options    PTRACE
+-no options    COREDUMP
+
 -no acpiacad*  at acpi?                # ACPI AC Adapter
 -no acpibat*   at acpi?                # ACPI Battery
 -no acpibut*   at acpi?                # ACPI Button
diff -r 226e2641606b -r 651f34c7eccd sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64   Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/arch/amd64/conf/files.amd64   Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amd64,v 1.117 2020/10/15 17:40:13 mgorny Exp $
+#      $NetBSD: files.amd64,v 1.118 2020/10/19 19:33:01 christos Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -47,7 +47,7 @@
 file   arch/amd64/amd64/gdt.c                  machdep
 file   arch/amd64/amd64/machdep.c              machdep
 file   arch/amd64/amd64/prekern.c              kaslr
-file   arch/amd64/amd64/process_machdep.c      machdep
+file   arch/amd64/amd64/process_machdep.c      machdep & ptrace
 file   arch/amd64/amd64/trap.c                 machdep
 file   arch/x86/x86/fpu.c                      machdep
 file   arch/x86/x86/dbregs.c                   machdep
diff -r 226e2641606b -r 651f34c7eccd sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/kern/compat_stub.c    Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.19 2019/11/20 19:37:53 pgoyette Exp $    */
+/* $NetBSD: compat_stub.c,v 1.20 2020/10/19 19:33:02 christos Exp $    */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -280,6 +280,8 @@
 struct coredump_offset_hook_t coredump_offset_hook;
 struct coredump_write_hook_t coredump_write_hook;
 struct coredump_netbsd_hook_t coredump_netbsd_hook;
+struct coredump_elf32_hook_t coredump_elf32_hook;
+struct coredump_elf64_hook_t coredump_elf64_hook;
 struct uvm_coredump_walkmap_hook_t uvm_coredump_walkmap_hook;
 struct uvm_coredump_count_segs_hook_t uvm_coredump_count_segs_hook;
 
diff -r 226e2641606b -r 651f34c7eccd sys/kern/core_elf32.c
--- a/sys/kern/core_elf32.c     Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/kern/core_elf32.c     Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: core_elf32.c,v 1.65 2020/10/10 00:10:06 rin Exp $      */
+/*     $NetBSD: core_elf32.c,v 1.66 2020/10/19 19:33:02 christos Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.65 2020/10/10 00:10:06 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.66 2020/10/19 19:33:02 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -109,7 +109,7 @@
 #define elf_fpreg              CONCAT(process_fpreg, ELFSIZE)
 
 int
-ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
+ELFNAMEEND(real_coredump)(struct lwp *l, struct coredump_iostate *cookie)
 {
        Elf_Ehdr ehdr;
        Elf_Shdr shdr;
diff -r 226e2641606b -r 651f34c7eccd sys/kern/files.kern
--- a/sys/kern/files.kern       Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/kern/files.kern       Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.kern,v 1.52 2020/09/07 03:50:41 thorpej Exp $
+#      $NetBSD: files.kern,v 1.53 2020/10/19 19:33:02 christos Exp $
 
 #
 # kernel sources
@@ -16,8 +16,8 @@
 file   kern/bufq_priocscan.c           bufq_priocscan
 file   kern/bufq_readprio.c            bufq_readprio | new_bufq_strategy
 file   kern/compat_stub.c              kern
-file   kern/core_elf32.c               exec_elf32
-file   kern/core_elf64.c               exec_elf64
+file   kern/core_elf32.c               exec_elf32 & coredump
+file   kern/core_elf64.c               exec_elf64 & coredump
 file   kern/core_netbsd.c              coredump
 file   kern/cnmagic.c                  kern
 file   kern/exec_aout.c                exec_aout
diff -r 226e2641606b -r 651f34c7eccd sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/kern/kern_core.c      Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.30 2020/05/23 23:42:43 ad Exp $        */
+/*     $NetBSD: kern_core.c,v 1.31 2020/10/19 19:33:02 christos Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.30 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.31 2020/10/19 19:33:02 christos Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd32.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -51,8 +55,15 @@
 #include <sys/kauth.h>
 #include <sys/module.h>
 #include <sys/compat_stub.h>
+#include <sys/exec_elf.h>
 
-MODULE(MODULE_CLASS_MISC, coredump, NULL);
+#ifdef COMPAT_NETBSD32
+#define COREDUMP_MODULE_DEP    "compat_netbsd32_ptrace"
+#else
+#define COREDUMP_MODULE_DEP    NULL
+#endif
+
+MODULE(MODULE_CLASS_MISC, coredump, COREDUMP_MODULE_DEP);
 
 struct coredump_iostate {
        struct lwp *io_lwp;
@@ -77,6 +88,10 @@
                MODULE_HOOK_SET(coredump_write_hook, coredump_write);
                MODULE_HOOK_SET(coredump_offset_hook, coredump_offset);
                MODULE_HOOK_SET(coredump_netbsd_hook, real_coredump_netbsd);
+               MODULE_HOOK_SET(coredump_elf32_hook, real_coredump_elf32);
+#ifdef _LP64
+               MODULE_HOOK_SET(coredump_elf64_hook, real_coredump_elf64);
+#endif
                MODULE_HOOK_SET(uvm_coredump_walkmap_hook,
                    uvm_coredump_walkmap);
                MODULE_HOOK_SET(uvm_coredump_count_segs_hook,
@@ -85,6 +100,10 @@
        case MODULE_CMD_FINI:
                MODULE_HOOK_UNSET(uvm_coredump_count_segs_hook);
                MODULE_HOOK_UNSET(uvm_coredump_walkmap_hook);
+#ifdef _LP64
+               MODULE_HOOK_UNSET(coredump_elf64_hook);
+#endif
+               MODULE_HOOK_UNSET(coredump_elf32_hook);
                MODULE_HOOK_UNSET(coredump_netbsd_hook);
                MODULE_HOOK_UNSET(coredump_offset_hook);
                MODULE_HOOK_UNSET(coredump_write_hook);
diff -r 226e2641606b -r 651f34c7eccd sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/kern/kern_sig.c       Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.390 2020/05/23 23:42:43 ad Exp $        */
+/*     $NetBSD: kern_sig.c,v 1.391 2020/10/19 19:33:02 christos Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.390 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.391 2020/10/19 19:33:02 christos 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/exec_elf.h>
 #include <sys/compat_stub.h>
 
 #ifdef PAX_SEGVGUARD
@@ -2343,12 +2344,9 @@
 }
 
 /*
- * Many emulations have a common coredump_netbsd() established as their
- * dump routine.  Since the "real" code may (or may not) be present in
- * loadable module, we provide a routine here which calls the module
- * hook.
+ * Since the "real" code may (or may not) be present in loadable module,
+ * we provide routines here which calls the module hooks.
  */
-
 int
 coredump_netbsd(struct lwp *l, struct coredump_iostate *iocookie)
 {
@@ -2358,6 +2356,26 @@
        return retval;
 }
 
+int
+coredump_elf32(struct lwp *l, struct coredump_iostate *iocookie)
+{
+       int retval;
+
+       MODULE_HOOK_CALL(coredump_elf32_hook, (l, iocookie), ENOSYS, retval);
+       return retval;
+}
+
+#ifdef _LP64
+int
+coredump_elf64(struct lwp *l, struct coredump_iostate *iocookie)
+{
+       int retval;
+
+       MODULE_HOOK_CALL(coredump_elf64_hook, (l, iocookie), ENOSYS, retval);
+       return retval;
+}
+#endif
+
 /*
  * Put process 'p' into the stopped state and optionally, notify the parent.
  */
diff -r 226e2641606b -r 651f34c7eccd sys/modules/coredump/Makefile
--- a/sys/modules/coredump/Makefile     Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/modules/coredump/Makefile     Mon Oct 19 19:33:01 2020 +0000
@@ -1,25 +1,24 @@
-#      $NetBSD: Makefile,v 1.6 2019/11/20 19:37:54 pgoyette Exp $
+#      $NetBSD: Makefile,v 1.7 2020/10/19 19:33:02 christos Exp $
 
 .include "../Makefile.inc"
 
 KMOD=  coredump
 
 .PATH: ${S}/kern
-SRCS=  kern_core.c core_netbsd.c 
+SRCS=  kern_core.c core_netbsd.c
+SRCS+= ${OBJECT_FMTS:S/^/core_/:S/$/.c/}
 
 .PATH: ${S}/uvm
 SRCS+= uvm_coredump.c
 
-.PATH: ${S}/arch/${MACHINE}/${MACHINE}
-.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
-.PATH: ${S}/arch/${MACHINE_CPU}/${MACHINE_CPU}
-.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
-.PATH: ${S}/arch/x86/x86
+.include "../ptrace_common/machdep.mk"
+SRCS+= core_machdep.c
+
+.include "${.CURDIR}/../../compat/netbsd32/netbsd32.mk"
+.if ${COMPAT_USE_NETBSD32} != "no"
+CPPFLAGS.core_elf32.c+=     -DCOMPAT_NETBSD32
+CPPFLAGS.kern_core.c+=     -DCOMPAT_NETBSD32
 .endif
-.if ${MACHINE_ARCH} == "powerpc64"
-.PATH: ${S}/arch/powerpc/powerpc
-.endif
-SRCS+= core_machdep.c
 
 WARNS= 3
 
diff -r 226e2641606b -r 651f34c7eccd sys/modules/exec_elf32/Makefile
--- a/sys/modules/exec_elf32/Makefile   Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/modules/exec_elf32/Makefile   Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.5 2019/11/20 19:37:54 pgoyette Exp $
+#      $NetBSD: Makefile,v 1.6 2020/10/19 19:33:02 christos Exp $
 
 .include "../Makefile.inc"
 
@@ -19,7 +19,7 @@
 .endif
 
 .PATH: ${S}/kern
-SRCS=  exec_elf32.c core_elf32.c
+SRCS=  exec_elf32.c
 
 WARNS= 3
 
diff -r 226e2641606b -r 651f34c7eccd sys/modules/exec_elf64/Makefile
--- a/sys/modules/exec_elf64/Makefile   Mon Oct 19 19:14:11 2020 +0000
+++ b/sys/modules/exec_elf64/Makefile   Mon Oct 19 19:33:01 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.4 2019/11/20 19:37:54 pgoyette Exp $



Home | Main Index | Thread Index | Old Index