Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Core dump in docker #19289

Open
zhangjianfnst opened this issue Jan 13, 2016 · 8 comments
Open

Proposal: Core dump in docker #19289

zhangjianfnst opened this issue Jan 13, 2016 · 8 comments
Labels
area/runtime kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@zhangjianfnst
Copy link
Contributor

In the current docker, we can only use the system global config of /proc/sys/kernel/core_pattern to specify the output place of core dump in container. There are several problems in this way:

  1. It maybe affect the original core dump behaviour config for host.
  2. It can't specify the output place of core dump independently for every container.
  3. The specified output place of core dump is in the container, but there are no tools (gdb e.g.) to investigate the core dump file in the container, and the core dump file may be too large. So it's better
    to store the core dump out of the container.

One proposal of implementation steps:

  1. Introduce "--coredump-helper" option in docker daemon, this option enables and specifies core dump helper program.
    E.g.:
    docker daemon --coredump-helper=/usr/libexec/docker-coredump-helper

    docker-coredump-helper is an executable program built from a project of docker-coredump-helper (it doesn't exsist now, also need to be implemented).

    Process steps:

    1. Require root
    2. Check /usr/libexec/docker-coredump-helper
    3. Copy /proc/sys/kernel/core_pattern to /var/run/docker/core_patterns/host
    4. Set /proc/sys/kernel/core_pattern with "|/usr/libexec/docker-coredump-helper %c %d %e %E %g %h %i %I %p %P %s %t %u"

    If the value of "--coredump-helper" isn't specified, docker daemon need not do the above steps.

  2. Introduce "--core-pattern" option in docker run/create, this option specifies the container core pattern.
    E.g.:
    a) docker run --core-pattern="#/var/core.%s.%p.%e" [IMAGE] [CMD] // path with '#' means it would be in host mnt namespace
    b) docker run --core-pattern="/var/core.%s.%p.%e" [IMAGE] [CMD] // path is in the container mnt namespace
    c) docker run [IMAGE] [CMD] // if "--core-pattern" not specified, default as: "#/var/run/docker/core_files/[ContainerID]/core.%p"

    Process steps:

    1. Check "--core-pattern" option
    2. Save core-pattern value to /var/run/docker/core_patterns/[ContainerID]
    Tree of core_patterns:
     /var/run/docker/core_patterns/
     ├── host
     ├── [ContainerID1]
     ├── [ContainerID2]
     ├── ...
     └── [ContainerIDn]
    
    1. When core dump is triggered, the docker-coredump-helper is executed. This program can judge the core dump source process and dispatch the core dump file according the config of /var/run/docker/core_patterns/*.
@zhangjianfnst
Copy link
Contributor Author

@cpuguy83 @moxiegirl @thaJeztah @vdemeester Hi, what do you think about this? Could you please give some comments?

@thaJeztah thaJeztah added the kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny label Jan 15, 2016
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Feb 3, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Feb 15, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Feb 25, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue May 14, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue May 14, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 6, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 6, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@LK4D4
Copy link
Contributor

LK4D4 commented Sep 14, 2016

This looks like nice thing to have.

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Oct 21, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@sanmai-NL
Copy link

Supporting, since it appears impossible to use a host data volume as a custom core_pattern file instead.

Docker Engine 1.12.2:

oci runtime error: rootfs_linux.go:53: mounting "/proc/sys/kernel/core_pattern" to rootfs 
"/var/lib/docker/devicemapper/mnt/28be96a0d47790bbe9560482a100bc475326f0f2cfb3ba6393ddf0d295b0eaf4/rootfs" caused 
"\\"/var/lib/docker/devicemapper/mnt/28be96a0d47790bbe9560482a100bc475326f0f2cfb3ba6393ddf0d295b0eaf4/rootfs/proc/sys/kernel/core_pattern\\" 
cannot be mounted because it is located inside \\"/proc\\""'

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Nov 26, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Dec 9, 2016
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Feb 10, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 1, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue May 6, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jul 21, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 19, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Dec 1, 2017
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@playground
Copy link

What is the best way to get the core dump files onto my local machine from remote container so I can examine the files? The files are huge.

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 9, 2018
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Feb 3, 2018
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Mar 10, 2018
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jun 15, 2018
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@kajmagnus
Copy link

kajmagnus commented Aug 6, 2018

@playground What about installing gdb on the remote machine? (the host or the container, both could work I would think) and running gdb ... backtrace remotely? Or maybe mount the /tmp/core-dump-directory/ in an object store like Amazon S3 or Google Cloud's object storage.

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 5, 2018
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@WanLinghao
Copy link

Hi, everyone, do we have any progress about this issue?

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 14, 2019
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Nov 1, 2019
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Nov 13, 2019
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Dec 21, 2019
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
@adelca
Copy link

adelca commented Mar 16, 2020

2020 - it is still a struggle to get a core dump without having to start container in privilege mode and impacting host config and other PODs... coronavirus will get us all before we can analyse those juicy core dumps waiting for us

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 25, 2020
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Dec 30, 2020
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Dec 30, 2020
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 28, 2021
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Oct 27, 2021
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
@kuvaldini
Copy link

Too much effort. And therefore not implemented during 5yrs. For me it would be just enough

docker run --core-pattern="WORKS exactly kernel.core_pattern=" [IMAGE] [CMD]

openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 1, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 20, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Mar 23, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Mar 23, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 18, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jun 17, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 27, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 28, 2022
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 10, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 10, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 1, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jul 7, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Aug 18, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Sep 9, 2023
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Jan 19, 2024
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 9, 2024
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
openvz-integrator pushed a commit to OpenVZ/vzkernel that referenced this issue Apr 9, 2024
1) put core_pattern on ve_struct and add virtualized proc_handler
using macro sysctl_virtual()

2) use in-container khelper kthread for collecting cores

We need support of pipe'ing coredump in CT. If process crashes
in CT and kernel.core_pattern begins with "|" we get error:

CT:
  CT-101-bash-4.2# sysctl kernel.core_pattern
   kernel.core_pattern = |/root/core_test %p UID=%u GID=%g sig=%s
  CT-101-bash-4.2# sleep 100 &
   [1] 445
  CT-101-bash-4.2# kill -11 445
  CT-101-bash-4.2#
   [1]+  Segmentation fault      sleep 100
  CT-101-bash-4.2# ll /root
   total 8
   rwxr-xr-x 1 root root 7424 Jan 27 17:28 core_test
Host:
  [root@s143 ~]# less /var/log/messages
   Jan 28 10:40:42 s143 kernel: [87698.969582] Core dump to
   |/root/core_test 445 UID=0 GID=0 sig=11 pipe failed

Also docker is going to use pipe'ing in coredumps functionality:
moby/moby#19289

https://jira.sw.ru/browse/PSBM-43596

v2: split sysctl_virtual in separate patch

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

+++
ve, coredump: Fix usercopy warning.

Usercopy WARNs about copying ve.core_pattern to user space:

vzctl exec e2783e5e-840e-4c9a-9ef2-7ead73afb81c cat /proc/sys/kernel/core_pattern
 Call Trace:
  __check_object_size+0x134/0x160
  proc_dostring+0x164/0x200
  proc_dostring_coredump_virtual+0xb2/0xd0
  proc_dostring+0x200/0x200
  proc_sys_call_handler+0xa7/0xf0
  vfs_read+0x9d/0x150
  ksys_read+0x4f/0xb0
  do_syscall_64+0x5b/0x1c0
  entry_SYSCALL_64_after_hwframe+0x65/0xca

Whitelist core_pattern in ve_struct kmem_cache since copying core_pattern
is allowed by design.

Fixes: e931118 ("ve: Add ve cgroup and ve_hook subsys")
https://jira.sw.ru/browse/PSBM-106216

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

vz9 change: merge with usercopy warning fixup for ve->core_pattern

(cherry picked from vz8 commit f8c44aa)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Feature: sysctl: virtualize "kernel.core_pattern"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests

9 participants