aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man5/core.516
-rw-r--r--sys/kern/kern_exec.c7
2 files changed, 22 insertions, 1 deletions
diff --git a/share/man/man5/core.5 b/share/man/man5/core.5
index d176548d1570..0af1b2b7e8bf 100644
--- a/share/man/man5/core.5
+++ b/share/man/man5/core.5
@@ -28,7 +28,7 @@
.\" @(#)core.5 8.3 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd August 2, 2020
+.Dd October 5, 2021
.Dt CORE 5
.Os
.Sh NAME
@@ -57,6 +57,20 @@ The maximum size of a core file is limited by the
limit.
Files which would be larger than the limit are not created.
.Pp
+With a large limit, a process that had mapped a very large,
+and perhaps sparsely populated, virtual memory region, could take
+a very long time to create core dumps.
+The system ignores all signals sent to a process writing a core file, except
+.Dv SIGKILL
+which terminates the writing and causes immediate exit of the process.
+The behavior of
+.Dv SIGKILL
+can be disabled by setting tunable
+.Xr sysctl 8
+variable
+.Va kern.core_dump_can_intr
+to zero.
+.Pp
The name of the file is controlled via the
.Xr sysctl 8
variable
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 4b3035cb7e08..7ec405ee6a62 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -151,6 +151,11 @@ static int map_at_zero = 0;
SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RWTUN, &map_at_zero, 0,
"Permit processes to map an object at virtual address 0.");
+static int core_dump_can_intr = 1;
+SYSCTL_INT(_kern, OID_AUTO, core_dump_can_intr, CTLFLAG_RWTUN,
+ &core_dump_can_intr, 0,
+ "Core dumping interruptible with SIGKILL");
+
static int
sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS)
{
@@ -1943,6 +1948,8 @@ core_output(char *base, size_t len, off_t offset, struct coredump_params *cp,
* anonymous memory or truncated files, for example.
*/
for (runlen = 0; runlen < len; runlen += PAGE_SIZE) {
+ if (core_dump_can_intr && curproc_sigkilled())
+ return (EINTR);
error = vm_fault(map, (uintptr_t)base + runlen,
VM_PROT_READ, VM_FAULT_NOFILL, NULL);
if (runlen == 0)