]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man5/core.5
sock_diag.7: ffix: white space tweaks in example program
[thirdparty/man-pages.git] / man5 / core.5
index f890799eb102d851a2bd3862f0ca0888d8f22404..a7b392f72531a8a8f52f52208d88d1ec39c8c930 100644 (file)
@@ -1,5 +1,6 @@
 .\" Copyright (c) 2006, 2008 by Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -19,8 +20,9 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
-.TH CORE 5 2010-02-27 "Linux" "Linux Programmer's Manual"
+.TH CORE 5 2016-10-08 "Linux" "Linux Programmer's Manual"
 .SH NAME
 core \- core dump file
 .SH DESCRIPTION
@@ -46,8 +48,13 @@ There are various circumstances in which a core dump file is
 not produced:
 .IP * 3
 The process does not have permission to write the core file.
-(By default the core file is called
-.IR core ,
+(By default, the core file is called
+.IR core
+or
+.IR core.pid ,
+where
+.I pid
+is the ID of the process that dumped core,
 and is created in the current working directory.
 See below for details on naming.)
 Writing the core file will fail if the directory in which
@@ -61,9 +68,9 @@ A (writable, regular) file with the same name as would be used for the
 core dump already exists, but there is more than one hard link to that
 file.
 .IP *
-The file system where the core dump file would be created is full;
+The filesystem where the core dump file would be created is full;
 or has run out of inodes; or is mounted read-only;
-or the user has reached their quota for the file system.
+or the user has reached their quota for the filesystem.
 .IP *
 The directory in which the core dump file is to be created does
 not exist.
@@ -86,7 +93,9 @@ permission enabled.
 .IP *
 The process is executing a set-user-ID (set-group-ID) program
 that is owned by a user (group) other than the real user (group)
-ID of the process.
+ID of the process,
+or the process is executing a program that has file capabilities (see
+.BR capabilities (7)).
 (However, see the description of the
 .BR prctl (2)
 .B PR_SET_DUMPABLE
@@ -96,6 +105,18 @@ operation, and the description of the
 .\" and PR_SET_DUMPABLE to this page?
 file in
 .BR proc (5).)
+.IP *
+(Since Linux 3.7)
+.\" commit 046d662f481830e652ac34cd112249adde16452a
+The kernel was configured without the
+.BR CONFIG_COREDUMP
+option.
+.PP
+In addition,
+a core dump may exclude part of the address space of the process if the
+.BR madvise (2)
+.B MADV_DONTDUMP
+flag was employed.
 .SS Naming of core dump files
 By default, a core dump file is named
 .IR core ,
@@ -112,15 +133,50 @@ by the following values when a core file is created:
 %%
 a single % character
 .TP
-%p
-PID of dumped process
+%c
+core file size soft resource limit of crashing process (since Linux 2.6.24)
 .TP
-%u
-(numeric) real UID of dumped process
+%d
+.\" Added in git commit 12a2b4b2241e318b4f6df31228e4272d2c2968a1
+dump mode\(emsame as value returned by
+.BR prctl (2)
+.B PR_GET_DUMPABLE
+(since Linux 3.7)
+.TP
+%e
+executable filename (without path prefix)
+.TP
+%E
+pathname of executable,
+with slashes (\(aq/\(aq) replaced by exclamation marks (\(aq!\(aq)
+(since Linux 3.0).
 .TP
 %g
 (numeric) real GID of dumped process
 .TP
+%h
+hostname (same as \fInodename\fP returned by \fBuname\fP(2))
+.TP
+%i
+TID of thread that triggered core dump,
+as seen in the PID namespace in which the thread resides
+.\" commit b03023ecbdb76c1dec86b41ed80b123c22783220
+(since Linux 3.18)
+.TP
+%I
+TID of thread that triggered core dump, as seen in the initial PID namespace
+.\" commit b03023ecbdb76c1dec86b41ed80b123c22783220
+(since Linux 3.18)
+.TP
+%p
+PID of dumped process,
+as seen in the PID namespace in which the process resides
+.TP
+%P
+.\" Added in git commit 65aafb1e7484b7434a0c1d4c593191ebe5776a2f
+PID of dumped process, as seen in the initial PID namespace
+(since Linux 3.12)
+.TP
 %s
 number of signal causing dump
 .TP
@@ -128,14 +184,8 @@ number of signal causing dump
 time of dump, expressed as seconds since the
 Epoch, 1970-01-01 00:00:00 +0000 (UTC)
 .TP
-%h
-hostname (same as \fInodename\fP returned by \fBuname\fP(2))
-.TP
-%e
-executable filename (without path prefix)
-.TP
-%c
-core file size soft resource limit of crashing process (since Linux 2.6.24)
+%u
+(numeric) real UID of dumped process
 .PD
 .RE
 .PP
@@ -151,11 +201,22 @@ in kernels before 2.6.19).
 The default value in this file is "core".
 For backward compatibility, if
 .I /proc/sys/kernel/core_pattern
-does not include "%p" and
+does not include
+.I %p
+and
 .I /proc/sys/kernel/core_uses_pid
 (see below)
 is nonzero, then .PID will be appended to the core filename.
 
+Paths are interpreted according to the settings that are active for the
+crashing process.
+That means the crashing process's mount namespace (see
+.BR mount_namespaces (7)),
+its current working directory (found via
+.BR getcwd (2)),
+and its root directory (see
+.BR chroot (2)).
+
 Since version 2.4, Linux has also provided
 a more primitive method of controlling
 the name of the core dump file.
@@ -166,12 +227,19 @@ file contains the value 0, then a core dump file is simply named
 If this file contains a nonzero value, then the core dump file includes
 the process ID in a name of the form
 .IR core.PID .
+
+Since Linux 3.6,
+.\" 9520628e8ceb69fa9a4aee6b57f22675d9e1b709
+if
+.I /proc/sys/fs/suid_dumpable
+is set to 2 ("suidsafe"), the pattern must be either an absolute pathname
+(starting with a leading \(aq/\(aq character) or a pipe, as defined below.
 .SS Piping core dumps to a program
 Since kernel 2.6.19, Linux supports an alternate syntax for the
 .I /proc/sys/kernel/core_pattern
 file.
 If the first character of this file is a pipe symbol (\fB|\fP),
-then the remainder of the line is interpreted as a program to be
+then the remainder of the line is interpreted as a user-space program to be
 executed.
 Instead of being written to a disk file, the core dump is given as
 standard input to the program.
@@ -181,11 +249,32 @@ The program must be specified using an absolute pathname (or a
 pathname relative to the root directory, \fI/\fP),
 and must immediately follow the '|' character.
 .IP *
+The program pathname is interpreted with respect to the initial mount namespace
+as it is always executed there.
+It is not affected by the settings
+(e.g., root directory, mount namespace, current working directory)
+of the crashing process.
+.IP *
 The process created to run the program runs as user and group
 .IR root .
 .IP *
+Running as
+.I root
+does not confer any exceptional security bypasses.
+Namely, LSMs (e.g., SELinux) are still active and may prevent the handler
+from accessing details about the crashed process via
+.IR /proc/[pid] .
+.IP *
+The process created runs in the initial namespaces (pid, mount, user, etc...)
+and not in the namespaces of the crashing process.
+One can utilize specifiers such as
+.I %P
+to find the right
+.I /proc/[pid]
+directory and probe/enter the crashing process's namespaces if needed.
+.IP *
 Command-line arguments can be supplied to the
-program (since kernel 2.6.24),
+program (since Linux 2.6.24),
 delimited by white space (up to a total line length of 128 bytes).
 .IP *
 The command-line arguments can include any of
@@ -193,9 +282,42 @@ the % specifiers listed above.
 For example, to pass the PID of the process that is being dumped, specify
 .I %p
 in an argument.
+.\"
+.SS /proc/sys/kernel/core_pipe_limit
+When collecting core dumps via a pipe to a user-space program,
+it can be useful for the collecting program to gather data about
+the crashing process from that process's
+.IR /proc/[pid]
+directory.
+In order to do this safely,
+the kernel must wait for the program collecting the core dump to exit,
+so as not to remove the crashing process's
+.IR /proc/[pid]
+files prematurely.
+This in turn creates the
+possibility that a misbehaving collecting program can block
+the reaping of a crashed process by simply never exiting.
+
+Since Linux 2.6.32,
+.\" commit a293980c2e261bd5b0d2a77340dd04f684caff58
+the
+.I /proc/sys/kernel/core_pipe_limit
+can be used to defend against this possibility.
+The value in this file defines how many concurrent crashing
+processes may be piped to user-space programs in parallel.
+If this value is exceeded, then those crashing processes above this value
+are noted in the kernel log and their core dumps are skipped.
+
+A value of 0 in this file is special.
+It indicates that unlimited processes may be captured in parallel,
+but that no waiting will take place (i.e., the collecting
+program is not guaranteed access to
+.IR /proc/<crashing-PID> ).
+The default value for this file is 0.
+.\"
 .SS Controlling which mappings are written to the core dump
 Since kernel 2.6.23, the Linux-specific
-.IR /proc/PID/coredump_filter
+.IR /proc/[pid]/coredump_filter
 file can be used to control which memory segments are written to the
 core dump file in the event that a core dump is performed for the
 process with the corresponding process ID.
@@ -231,12 +353,24 @@ Dump private huge pages.
 .TP
 bit 6 (since Linux 2.6.28)
 Dump shared huge pages.
+.TP
+bit 7 (since Linux 4.4)
+.\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82
+Dump private DAX pages.
+.TP
+bit 8 (since Linux 4.4)
+.\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82
+Dump shared DAX pages.
 .RE
 .PD
 .PP
 By default, the following bits are set: 0, 1, 4 (if the
 .B CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
 kernel configuration option is enabled), and 5.
+This default can be modified at boot time using the
+.I coredump_filter
+boot option.
+
 The value of this file is displayed in hexadecimal.
 (The default value is thus displayed as 33.)
 
@@ -266,7 +400,7 @@ in the parent shell before running a program, for example:
 .fi
 .in
 .PP
-This file is only provided if the kernel was built with the
+This file is provided only if the kernel was built with the
 .B CONFIG_ELF_CORE
 configuration option.
 .SH NOTES
@@ -275,16 +409,21 @@ The
 .I gcore
 command can be used to obtain a core dump of a running process.
 
-If a multithreaded process (or, more precisely, a process that
+In Linux versions up to and including 2.6.27,
+.\" Changed with commit 6409324b385f3f63a03645b4422e3be67348d922
+if a multithreaded process (or, more precisely, a process that
 shares its memory with another process by being created with the
 .B CLONE_VM
 flag of
 .BR clone (2))
 dumps core, then the process ID is always appended to the core filename,
 unless the process ID was already included elsewhere in the
-filename via a %p specification in
+filename via a
+.I %p
+specification in
 .IR /proc/sys/kernel/core_pattern .
-(This is primarily useful when employing the LinuxThreads implementation,
+(This is primarily useful when employing the obsolete
+LinuxThreads implementation,
 where each thread of a process has a different PID.)
 .\" Always including the PID in the name of the core file made
 .\" sense for LinuxThreads, where each thread had a unique PID,
@@ -292,7 +431,7 @@ where each thread of a process has a different PID.)
 .\" threads in a process share the same PID (as POSIX.1 requires).
 .\" Probably the behavior is maintained so that applications using
 .\" LinuxThreads continue appending the PID (the kernel has no easy
-.\" way of telling which threading implementation the userspace
+.\" way of telling which threading implementation the user-space
 .\" application is using). -- mtk, April 2006
 .SH EXAMPLE
 The program below can be used to demonstrate the use of the
@@ -308,8 +447,8 @@ The following shell session demonstrates the use of this program
 .RB "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c"
 .RB "$" " su"
 Password:
-.RB "#" " echo \(aq|$PWD/core_pattern_pipe_test %p \
-UID=%u GID=%g sig=%s\(aq > \e"
+.RB "#" " echo \(dq|$PWD/core_pattern_pipe_test %p \
+UID=%u GID=%g sig=%s\(dq > \e"
 .B "    /proc/sys/kernel/core_pattern"
 .RB "#" " exit"
 .RB "$" " sleep 100"
@@ -375,6 +514,7 @@ main(int argc, char *argv[])
         tot += nread;
     fprintf(fp, "Total bytes in core dump: %d\\n", tot);
 
+    fclose(fp);
     exit(EXIT_SUCCESS);
 }
 .fi