aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Graber <stgraber@ubuntu.com>2013-09-11 17:24:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:01 -0400
commit65aafb1e7484b7434a0c1d4c593191ebe5776a2f (patch)
tree163b908974a487e6e8bdfd893d20fb28234255d2
parent73af963f9f3036dffed55c3a2898598186db1045 (diff)
coredump: add new %P variable in core_pattern
Add a new %P variable to be used in core_pattern. This variable contains the global PID (PID in the init namespace) as %p contains the PID in the current namespace which isn't always what we want. The main use for this is to make it easier to handle crashes that happened within a container. With that new variables it's possible to have the crashes dumped into the container or forwarded to the host with the right PID (from the host's point of view). Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Reported-by: Hans Feldt <hans.feldt@ericsson.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Andy Whitcroft <apw@canonical.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/sysctl/kernel.txt1
-rw-r--r--fs/coredump.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index ab7d16efa96b..9d4c1d18ad44 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -182,6 +182,7 @@ core_pattern is used to specify a core dumpfile pattern name.
182 %<NUL> '%' is dropped 182 %<NUL> '%' is dropped
183 %% output one '%' 183 %% output one '%'
184 %p pid 184 %p pid
185 %P global pid (init PID namespace)
185 %u uid 186 %u uid
186 %g gid 187 %g gid
187 %d dump mode, matches PR_SET_DUMPABLE and 188 %d dump mode, matches PR_SET_DUMPABLE and
diff --git a/fs/coredump.c b/fs/coredump.c
index 72f816d6cad9..9bdeca12ae0e 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -190,6 +190,11 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
190 err = cn_printf(cn, "%d", 190 err = cn_printf(cn, "%d",
191 task_tgid_vnr(current)); 191 task_tgid_vnr(current));
192 break; 192 break;
193 /* global pid */
194 case 'P':
195 err = cn_printf(cn, "%d",
196 task_tgid_nr(current));
197 break;
193 /* uid */ 198 /* uid */
194 case 'u': 199 case 'u':
195 err = cn_printf(cn, "%d", cred->uid); 200 err = cn_printf(cn, "%d", cred->uid);