All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] [PATCH] coredump: Add new %P variable in core_pattern
@ 2013-08-15 12:51 Stéphane Graber
  2013-08-15 13:48 ` Serge Hallyn
  0 siblings, 1 reply; 2+ messages in thread
From: Stéphane Graber @ 2013-08-15 12:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fsdevel, Alexander Viro, Eric W. Biederman, Serge Hallyn,
	Andy Whitcroft

This adds 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).

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: Stéphane Graber <stgraber@ubuntu.com>

---
 Documentation/sysctl/kernel.txt | 1 +
 fs/coredump.c                   | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index ccd4258..833026d 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.
 	%<NUL>	'%' is dropped
 	%%	output one '%'
 	%p	pid
+	%P	global pid (init PID namespace)
 	%u	uid
 	%g	gid
 	%d	dump mode, matches PR_SET_DUMPABLE and
diff --git a/fs/coredump.c b/fs/coredump.c
index c647965..528c6fc 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -186,6 +186,11 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
 				err = cn_printf(cn, "%d",
 					      task_tgid_vnr(current));
 				break;
+			/* global pid */
+			case 'P':
+				err = cn_printf(cn, "%d",
+					      task_tgid_nr(current));
+				break;
 			/* uid */
 			case 'u':
 				err = cn_printf(cn, "%d", cred->uid);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RESEND] [PATCH] coredump: Add new %P variable in core_pattern
  2013-08-15 12:51 [RESEND] [PATCH] coredump: Add new %P variable in core_pattern Stéphane Graber
@ 2013-08-15 13:48 ` Serge Hallyn
  0 siblings, 0 replies; 2+ messages in thread
From: Serge Hallyn @ 2013-08-15 13:48 UTC (permalink / raw)
  To: Stéphane Graber
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Eric W. Biederman,
	Serge Hallyn, Andy Whitcroft, Andrew Morton

Thanks Stéphane.  There were no objections last time this was posted,
right?  Hopefully it can be applied this time.

-serge

Quoting Stéphane Graber (stgraber@ubuntu.com):
> This adds 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).
> 
> 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: Stéphane Graber <stgraber@ubuntu.com>
> 
> ---
>  Documentation/sysctl/kernel.txt | 1 +
>  fs/coredump.c                   | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
> index ccd4258..833026d 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.
>  	%<NUL>	'%' is dropped
>  	%%	output one '%'
>  	%p	pid
> +	%P	global pid (init PID namespace)
>  	%u	uid
>  	%g	gid
>  	%d	dump mode, matches PR_SET_DUMPABLE and
> diff --git a/fs/coredump.c b/fs/coredump.c
> index c647965..528c6fc 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -186,6 +186,11 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
>  				err = cn_printf(cn, "%d",
>  					      task_tgid_vnr(current));
>  				break;
> +			/* global pid */
> +			case 'P':
> +				err = cn_printf(cn, "%d",
> +					      task_tgid_nr(current));
> +				break;
>  			/* uid */
>  			case 'u':
>  				err = cn_printf(cn, "%d", cred->uid);
> -- 
> 1.8.1.2
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-15 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-15 12:51 [RESEND] [PATCH] coredump: Add new %P variable in core_pattern Stéphane Graber
2013-08-15 13:48 ` Serge Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.