Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1611694imm; Fri, 12 Oct 2018 23:42:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RvC+sAMhp43+qj69mntSNI1ZL856r7Rvv85Ai3zx4SgKHRE9a6kN+zZ3MQX3F8lOPffcP X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr778605pfc.195.1539412942469; Fri, 12 Oct 2018 23:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539412942; cv=none; d=google.com; s=arc-20160816; b=N2FiUsMzdIf3+pDeTBi2N8+XkC7/siDahV8gH5Zy9rCcLHr94OgTehUtFTTARH2Y5Q Lf2FTSLKZZtFR64dJmSmUE0gFeKKSYrRchs7W84OLoZYNUUfNycvTqz71w0ppsYhnDCn z4iCaCu7z5kLNOkNI+Fv2UWyriBLB/v9qXV2paGaR7ttZHoRBQe7l46epX1m/jIcn3jM HHvYkdqrkc6xfjDGwxcwOGSGYUD6+ZOzY0YjZ9SG/90HRV+tnw7zt0jsBzdDZR6n5TX7 E03S02hkkEb3fUOYDzqLF77qUd89+04ybm6sWVOb0xFINSLMDWad3ZiFddRZAZ7qfLIE Kuvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BR6J0/0Ws+I7wEBdHYZEInOiMlpGLRLdfmjEdC4PPSc=; b=fvT4QSsaK5p524u69oQmN0ueV5LIEH+ESPP8hq1bGfxL86Q8cpLwFEN7oqt2D9jY7Y jJGaitrQ+NBMiB6yVz1yaD5UW7kz6MP/LlFO6qgh7hpAP2BbTip00k62ylv1Wdqtw3Cb WGRGyVf/ajXWxXOpkXaECVE21E3nzDUut8wevCVnKS2MPtqdnfsPh3D8NV6p2IzjYHIV QDQP4HW4sL9fAEI5BDVbV5i6fpwei3wM311stjPDYOFzbvGB0pSpKz6Lf1W/2RH6zK9y E0zLLy71LuJ7OvDujxyS5J8bgOR80tdyy+Pw4ns2TEjHm/uVp7mDZmDQJ+pTMeWonCq2 cMIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dzr0mVbi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23-v6si3499989plr.127.2018.10.12.23.41.30; Fri, 12 Oct 2018 23:42:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dzr0mVbi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbeJMOQX (ORCPT + 99 others); Sat, 13 Oct 2018 10:16:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbeJMOQW (ORCPT ); Sat, 13 Oct 2018 10:16:22 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75B61205C9; Sat, 13 Oct 2018 06:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539412826; bh=fwsRFWSwCJBasfStUyw3Uh+/7yyN0ASQwDc5TZlMQFk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dzr0mVbisFs4BwFD16wok84W9hjx+Vtf4lNFEM7DXD0qKACqlO8sHbQqENBcrCd1Q GP3zX+ziTHq1j+/wtWefQDuyLMkNelUTl7pv4JjvyQuaCFwRcQ7xe7Y9850unNEhbx lhML9NGiKSMUS5GD8jSihMtqw/HCP/RHSxqejvWE= Date: Sat, 13 Oct 2018 08:40:23 +0200 From: Greg Kroah-Hartman To: Enke Chen 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 Subject: Re: [PATCH] kernel/signal: Signal-based pre-coredump notification Message-ID: <20181013064023.GA28177@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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