From mboxrd@z Thu Jan 1 00:00:00 1970 From: Enke Chen Subject: Re: [PATCH] kernel/signal: Signal-based pre-coredump notification Date: Mon, 15 Oct 2018 11:16:36 -0700 Message-ID: <37401cea-5a37-2cd9-8595-8b07dfc4de7d@cisco.com> References: <20181013064023.GA28177@kroah.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20181013064023.GA28177@kroah.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Greg Kroah-Hartman Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Arnd Bergmann , "Eric W. Biederman" , Khalid Aziz , Kate Stewart , Helge Deller , Al Viro , Andrew Morton , Christian Brauner , Catalin Marinas , Will Deacon , Dave Martin , Mauro Carvalho Chehab , Michal Hocko , Rik van Riel , Kirill A. Shutemov List-Id: linux-arch.vger.kernel.org Hi, Greg: > Shouldn't there also be a manpage update, and a kselftest added for this > new user/kernel api that is being created? > I will submit a patch for manpage update once the code is accepted. Regarding the kselftest, I am not sure. Once the prctl() is limited to self (which I will do), the logic would be pretty straightforward. Not sure if the selftest would add much value. Thanks. -- Enke On 10/12/18 11:40 PM, Greg Kroah-Hartman wrote: > On Fri, Oct 12, 2018 at 05:33:35PM -0700, Enke Chen wrote: >> For simplicity and consistency, this patch provides an implementation >> for signal-based fault notification prior to the coredump of a child >> process. A new prctl command, PR_SET_PREDUMP_SIG, is defined that can >> be used by an application to express its interest and to specify the >> signal (SIGCHLD or SIGUSR1 or SIGUSR2) for such a notification. A new >> signal code (si_code), CLD_PREDUMP, is also defined for SIGCHLD. >> >> Background: >> >> As the coredump of a process may take time, in certain time-sensitive >> applications it is necessary for a parent process (e.g., a process >> manager) to be notified of a child's imminent death before the coredump >> so that the parent process can act sooner, such as re-spawning an >> application process, or initiating a control-plane fail-over. >> >> Currently there are two ways for a parent process to be notified of a >> child process's state change. One is to use the POSIX signal, and >> another is to use the kernel connector module. The specific events and >> actions are summarized as follows: >> >> Process Event POSIX Signal Connector-based >> ---------------------------------------------------------------------- >> ptrace_attach() do_notify_parent_cldstop() proc_ptrace_connector() >> SIGCHLD / CLD_STOPPED >> >> ptrace_detach() do_notify_parent_cldstop() proc_ptrace_connector() >> SIGCHLD / CLD_CONTINUED >> >> pre_coredump/ N/A proc_coredump_connector() >> get_signal() >> >> post_coredump/ do_notify_parent() proc_exit_connector() >> do_exit() SIGCHLD / exit_signal >> ---------------------------------------------------------------------- >> >> As shown in the table, the signal-based pre-coredump notification is not >> currently available. In some cases using a connector-based notification >> can be quite complicated (e.g., when a process manager is written in shell >> scripts and thus is subject to certain inherent limitations), and a >> signal-based notification would be simpler and better suited. >> >> Signed-off-by: Enke Chen >> --- >> arch/x86/kernel/signal_compat.c | 2 +- >> include/linux/sched.h | 4 ++ >> include/linux/signal.h | 5 +++ >> include/uapi/asm-generic/siginfo.h | 3 +- >> include/uapi/linux/prctl.h | 4 ++ >> kernel/fork.c | 1 + >> kernel/signal.c | 51 +++++++++++++++++++++++++ >> kernel/sys.c | 77 ++++++++++++++++++++++++++++++++++++++ >> 8 files changed, 145 insertions(+), 2 deletions(-) > > Shouldn't there also be a manpage update, and a kselftest added for this > new user/kernel api that is being created? > > thanks, > > greg k-h > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-5.cisco.com ([173.37.142.92]:9115 "EHLO alln-iport-5.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbeJPCDC (ORCPT ); Mon, 15 Oct 2018 22:03:02 -0400 Subject: Re: [PATCH] kernel/signal: Signal-based pre-coredump notification References: <20181013064023.GA28177@kroah.com> From: Enke Chen Message-ID: <37401cea-5a37-2cd9-8595-8b07dfc4de7d@cisco.com> Date: Mon, 15 Oct 2018 11:16:36 -0700 MIME-Version: 1.0 In-Reply-To: <20181013064023.GA28177@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Greg Kroah-Hartman Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Arnd Bergmann , "Eric W. Biederman" , Khalid Aziz , Kate Stewart , Helge Deller , Al Viro , Andrew Morton , Christian Brauner , Catalin Marinas , Will Deacon , Dave Martin , Mauro Carvalho Chehab , Michal Hocko , Rik van Riel , "Kirill A. Shutemov" , Roman Gushchin , Marcos Paulo de Souza , Oleg Nesterov , Dominik Brodowski , Cyrill Gorcunov , Yang Shi , Jann Horn , Kees Cook , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Victor Kamensky (kamensky)" , xe-linux-external@cisco.com, Stefan Strogin , Enke Chen Message-ID: <20181015181636.TmhRvNj58l9AKy2njd0XmGAgdqmxgfpR65r70bXuN50@z> Hi, Greg: > Shouldn't there also be a manpage update, and a kselftest added for this > new user/kernel api that is being created? > I will submit a patch for manpage update once the code is accepted. Regarding the kselftest, I am not sure. Once the prctl() is limited to self (which I will do), the logic would be pretty straightforward. Not sure if the selftest would add much value. Thanks. -- Enke On 10/12/18 11:40 PM, Greg Kroah-Hartman wrote: > On Fri, Oct 12, 2018 at 05:33:35PM -0700, Enke Chen wrote: >> For simplicity and consistency, this patch provides an implementation >> for signal-based fault notification prior to the coredump of a child >> process. A new prctl command, PR_SET_PREDUMP_SIG, is defined that can >> be used by an application to express its interest and to specify the >> signal (SIGCHLD or SIGUSR1 or SIGUSR2) for such a notification. A new >> signal code (si_code), CLD_PREDUMP, is also defined for SIGCHLD. >> >> Background: >> >> As the coredump of a process may take time, in certain time-sensitive >> applications it is necessary for a parent process (e.g., a process >> manager) to be notified of a child's imminent death before the coredump >> so that the parent process can act sooner, such as re-spawning an >> application process, or initiating a control-plane fail-over. >> >> Currently there are two ways for a parent process to be notified of a >> child process's state change. One is to use the POSIX signal, and >> another is to use the kernel connector module. The specific events and >> actions are summarized as follows: >> >> Process Event POSIX Signal Connector-based >> ---------------------------------------------------------------------- >> ptrace_attach() do_notify_parent_cldstop() proc_ptrace_connector() >> SIGCHLD / CLD_STOPPED >> >> ptrace_detach() do_notify_parent_cldstop() proc_ptrace_connector() >> SIGCHLD / CLD_CONTINUED >> >> pre_coredump/ N/A proc_coredump_connector() >> get_signal() >> >> post_coredump/ do_notify_parent() proc_exit_connector() >> do_exit() SIGCHLD / exit_signal >> ---------------------------------------------------------------------- >> >> As shown in the table, the signal-based pre-coredump notification is not >> currently available. In some cases using a connector-based notification >> can be quite complicated (e.g., when a process manager is written in shell >> scripts and thus is subject to certain inherent limitations), and a >> signal-based notification would be simpler and better suited. >> >> Signed-off-by: Enke Chen >> --- >> arch/x86/kernel/signal_compat.c | 2 +- >> include/linux/sched.h | 4 ++ >> include/linux/signal.h | 5 +++ >> include/uapi/asm-generic/siginfo.h | 3 +- >> include/uapi/linux/prctl.h | 4 ++ >> kernel/fork.c | 1 + >> kernel/signal.c | 51 +++++++++++++++++++++++++ >> kernel/sys.c | 77 ++++++++++++++++++++++++++++++++++++++ >> 8 files changed, 145 insertions(+), 2 deletions(-) > > Shouldn't there also be a manpage update, and a kselftest added for this > new user/kernel api that is being created? > > thanks, > > greg k-h >