cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* piping core dump to a program escapes container
@ 2015-10-24 21:54 Shayan Pooya
       [not found] ` <CABAubTgj8+xngrvc7sNbYS_Hq+-rGAYCz0y433ByiZ45dZuT0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Shayan Pooya @ 2015-10-24 21:54 UTC (permalink / raw)
  To: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

I noticed the following core_pattern behavior in my linux box while
running docker containers. I am not sure if it is bug, but it is
inconsistent and not documented.

If the core_pattern is set on the host, the containers will observe
and use the pattern for dumping cores (there is no per cgroup
core_pattern). According to core(5) for setting core_pattern one can:

1. echo "/tmp/cores/core.%e.%p" > /proc/sys/kernel/core_pattern
2. echo "|/bin/custom_core /tmp/cores/ %e %p " > /proc/sys/kernel/core_pattern

The former pattern evaluates the /tmp/cores path in the container's
filesystem namespace. Which means, the host does not see a core file
in /tmp/cores.

However, the latter evaluates the /bin/custom_core path in the global
filesystem namespace. Moreover, if /bin/core decides to write the core
to a path (/tmp/cores in this case as shown by the arg to
custom_core), the path will be evaluated in the global filesystem
namespace as well.

The latter behaviour is counter-intuitive and error-prone as the
container can fill up the core-file directory which it does not have
direct access to (which means the core is also not accessible for
debugging if someone only has access to the container).

Currently, I work around this issue by detecting that the process is
crashing from a container (by comparing the namespace pid to the
global pid) and refuse to dump the core if it is from a container.

Tested on Ubuntu (kernel 3.16) and Fedora (kernel 4.1).

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

end of thread, other threads:[~2015-12-10  2:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-24 21:54 piping core dump to a program escapes container Shayan Pooya
     [not found] ` <CABAubTgj8+xngrvc7sNbYS_Hq+-rGAYCz0y433ByiZ45dZuT0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-01 20:25   ` Richard Weinberger
     [not found]     ` <CAFLxGvz=d=4u7LZ_ZPES_MqfO0kWGxyWE9SPUuONjH9aM=dxFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-05  4:42       ` Shayan Pooya
2015-12-09  2:26   ` Dongsheng Yang
     [not found]     ` <56679161.303-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2015-12-09  2:36       ` Dongsheng Yang
     [not found]         ` <56679399.6080306-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2015-12-09  3:29           ` Eric W. Biederman
     [not found]             ` <876108fgfq.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2015-12-09  5:53               ` Dongsheng Yang
     [not found]                 ` <5667C1BC.7070204-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2015-12-09  6:32                   ` Eric W. Biederman
2015-12-09  8:06                     ` Dongsheng Yang
2015-12-09  8:34               ` Bruno Prémont
     [not found]                 ` <20151209093418.4d28b78c-I2t2yFIzmohO7ya8xxV06g@public.gmane.org>
2015-12-10  0:27                   ` Dongsheng Yang
2015-12-10  2:58               ` Dongsheng Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).