Arrange so that no options COREDUMP and no options PTRACE work together.

Thanks to Paul Goyette for testing.
This commit is contained in:
christos 2020-10-19 19:33:01 +00:00
parent 637b8f48e5
commit 3d852e0ec8
14 changed files with 107 additions and 45 deletions

View File

@ -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 @@ options MODULAR_DEFAULT_AUTOLOAD
-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

View File

@ -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 kern/subr_disk_mbr.c disk
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

View File

@ -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_hook_t coredump_hook;
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;

View File

@ -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 @@ static int ELFNAMEEND(coredump_note)(struct lwp *, struct note_state *);
#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;

View File

@ -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_fcfs.c bufq_fcfs
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

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.30 2020/05/23 23:42:43 ad Exp $");
#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 @@ coredump_modcmd(modcmd_t cmd, void *arg)
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 @@ coredump_modcmd(modcmd_t cmd, void *arg)
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);

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.390 2020/05/23 23:42:43 ad Exp $");
#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 @@ sigexit(struct lwp *l, int signo)
}
/*
* 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 @@ coredump_netbsd(struct lwp *l, struct coredump_iostate *iocookie)
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.
*/

View File

@ -1,26 +1,25 @@
# $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
.endif
.if ${MACHINE_ARCH} == "powerpc64"
.PATH: ${S}/arch/powerpc/powerpc
.endif
.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
WARNS= 3
COPTS.kern_core.c+= ${GCC_NO_CAST_FUNCTION_TYPE}

View File

@ -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 @@ CPPFLAGS+= -DPAX_ASLR
.endif
.PATH: ${S}/kern
SRCS= exec_elf32.c core_elf32.c
SRCS= exec_elf32.c
WARNS= 3

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.4 2019/11/20 19:37:54 pgoyette Exp $
# $NetBSD: Makefile,v 1.5 2020/10/19 19:33:02 christos Exp $
.include "../Makefile.inc"
@ -11,7 +11,7 @@ CPPFLAGS+= -DPAX_ASLR
.endif
.PATH: ${S}/kern
SRCS= exec_elf64.c core_elf64.c
SRCS= exec_elf64.c
WARNS= 3

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2019/10/13 07:28:13 mrg Exp $
# $NetBSD: Makefile,v 1.4 2020/10/19 19:33:02 christos Exp $
#
.include "../Makefile.inc"
@ -6,8 +6,10 @@
CPPFLAGS+= -DPTRACE
.include "machdep.mk"
KMOD= ptrace_common
SRCS= sys_ptrace_common.c
SRCS= sys_ptrace_common.c process_machdep.c
WARNS= 3

View File

@ -0,0 +1,13 @@
# $NetBSD: machdep.mk,v 1.1 2020/10/19 19:33:02 christos Exp $
# Paths to find machine dependent sources
.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
.endif
.if ${MACHINE_ARCH} == "powerpc64"
.PATH: ${S}/arch/powerpc/powerpc
.endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_stub.h,v 1.23 2020/03/08 00:53:13 pgoyette Exp $ */
/* $NetBSD: compat_stub.h,v 1.24 2020/10/19 19:33:02 christos Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -377,6 +377,10 @@ MODULE_HOOK(coredump_write_hook, int,
(struct coredump_iostate *, enum uio_seg, const void *, size_t));
MODULE_HOOK(coredump_netbsd_hook, int,
(struct lwp *, struct coredump_iostate *));
MODULE_HOOK(coredump_elf32_hook, int,
(struct lwp *, struct coredump_iostate *));
MODULE_HOOK(coredump_elf64_hook, int,
(struct lwp *, struct coredump_iostate *));
MODULE_HOOK(uvm_coredump_walkmap_hook, int,
(struct proc *, int (*)(struct uvm_coredump_state *), void *));
MODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf.h,v 1.167 2020/10/10 21:25:51 thorpej Exp $ */
/* $NetBSD: exec_elf.h,v 1.168 2020/10/19 19:33:02 christos Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -1439,12 +1439,14 @@ int elf32_populate_auxv(struct lwp *, struct exec_package *, char **);
int elf32_copyargs(struct lwp *, struct exec_package *,
struct ps_strings *, char **, void *);
int elf32_check_header(Elf32_Ehdr *);
#endif
int real_coredump_elf32(struct lwp *, struct coredump_iostate *);
int coredump_elf32(struct lwp *, struct coredump_iostate *);
void coredump_savenote_elf32(struct note_state *, unsigned int,
const char *, void *, size_t);
int elf32_check_header(Elf32_Ehdr *);
#endif
#ifdef EXEC_ELF64
int exec_elf64_makecmds(struct lwp *, struct exec_package *);
@ -1452,12 +1454,14 @@ int elf64_populate_auxv(struct lwp *, struct exec_package *, char **);
int elf64_copyargs(struct lwp *, struct exec_package *,
struct ps_strings *, char **, void *);
int elf64_check_header(Elf64_Ehdr *);
#endif
int real_coredump_elf64(struct lwp *, struct coredump_iostate *);
int coredump_elf64(struct lwp *, struct coredump_iostate *);
void coredump_savenote_elf64(struct note_state *, unsigned int,
const char *, void *, size_t);
int elf64_check_header(Elf64_Ehdr *);
#endif
#endif /* _KERNEL */