Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4568945imm; Mon, 15 Oct 2018 17:55:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV6084F1krOJcprNdooIWEUPFl4XApSZGyRJ1JweUS1EHxtHsDFvHQyfjNlhZrRO3tTI5Y3mT X-Received: by 2002:a63:6781:: with SMTP id b123-v6mr18282538pgc.151.1539651325134; Mon, 15 Oct 2018 17:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539651325; cv=none; d=google.com; s=arc-20160816; b=K7D63VXI1hNBJZW0p//DZUbDUBiXpUixx1Q4NklW+MLz+RodBPrpS5VWs1H3RzVroz GEhpcVNke0M9q7V0S6zAWmYXFQbASZObjAYHUCvyuWJ4meaYYhT2U3zG09dp8Ym4Lkcz Q58fmRbrBi75VoK7hHFetJ22EHYIXm3BHqsSmt571HWhlTIy70h1m5ka7YFuNspPB3t6 CX0NNDwn0MnAt6DfA5guOhblfbYaQyBbJXS1s5uUjS6cDqkSXfBMxdAh3Cuv9YFNUuTN 5i0AInLWIp64U89M4VflXbON6q8wtS3uF/iQBYajswu2uKu2OMgMBEOUbwX4IW3NwAtC fVkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3zC0hmA8kPCqodOlunRHq2tTTzWbGnNjzBIlWOgBRuQ=; b=U0Vfg6nxICKfo+5YGOAVoNvfni5dyc95EQ9AeIoQVomrCRG60aGCFBSRftaBggeAWw m2Lf5uYUlCxdt5oO5+RPBxpp9LfNsEN9gWOiM5TrE5p+hFYThqiRgGO11XPxnIPC/+CW mKncPUNrRDv0hv6jmVXJtZtf7idSB6Hudp4g5vYZk5MkLxD9I/AcTLOxHq7XolMP5s9U tMioPpn93BL7mDnbu0oiedm+blQMCte+wiHXs+4h39L1uylrQm5eW52fqCY38Wgz6OZK UcUnx+Lt/x7KqS3BolIIiYFLIJoDIYw8yHvRDWiWlJjm1Z0keP2DD8rh2QmZoMxhRudR nWGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b="V67bTpn/"; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11-v6si11170841pgi.241.2018.10.15.17.55.09; Mon, 15 Oct 2018 17:55:25 -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=@cisco.com header.s=iport header.b="V67bTpn/"; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbeJPImd (ORCPT + 99 others); Tue, 16 Oct 2018 04:42:33 -0400 Received: from rcdn-iport-1.cisco.com ([173.37.86.72]:39119 "EHLO rcdn-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbeJPImd (ORCPT ); Tue, 16 Oct 2018 04:42:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2554; q=dns/txt; s=iport; t=1539651288; x=1540860888; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Wxt6zpQuAM3odC+kaqJBM3BXxWKcUizGUsiWYNNcI2Q=; b=V67bTpn/VLv7N9XSvF1VII43rFImVCsBvqVzVa9xHXnEg+TZEvEjRw7H nV1s4JXp6bpVrl3Cotpc+p/5F5qIQBGHRNtShc2lruXWEfNU14FytRrsh usKuoDysSrELsUDCkM6jASmX5kiwi5fFJHu516CYJwH9vI6tdTaMaJELp o=; X-IronPort-AV: E=Sophos;i="5.54,386,1534809600"; d="scan'208";a="466859805" Received: from rcdn-core-8.cisco.com ([173.37.93.144]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 00:54:47 +0000 Received: from [10.154.208.167] ([10.154.208.167]) by rcdn-core-8.cisco.com (8.15.2/8.15.2) with ESMTP id w9G0sha4000557; Tue, 16 Oct 2018 00:54:43 GMT Subject: Re: [PATCH] kernel/signal: Signal-based pre-coredump notification To: "Eric W. Biederman" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Arnd Bergmann , Khalid Aziz , Kate Stewart , Helge Deller , Greg Kroah-Hartman , 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 References: <87va62lri4.fsf@xmission.com> From: Enke Chen Message-ID: <6211eeaa-ce07-a909-e4c2-172618ddfb95@cisco.com> Date: Mon, 15 Oct 2018 17:54:43 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87va62lri4.fsf@xmission.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.154.208.167, [10.154.208.167] X-Outbound-Node: rcdn-core-8.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Eric: On 10/15/18 4:28 PM, Eric W. Biederman wrote: > Enke Chen writes: > >> 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. > > You talk about time senstive and then you talk about bash scripts. > I don't think your definition of time-sensitive and my definition match. It's certainly not my preference to have a process manager (or one for each application) written in bash scripts. But they do work, and are deployed. > > With that said I think the best solution would be to figure out how to > allow the coredump to run in parallel with the usual exit signal, and > exit code reaping of the process> > That would solve the problem for everyone, and would not introduce any > new complicated APIs. That would certainly help. But given the huge deployment of Linux, I don't think it would be feasible to change this fundamental behavior (signal post coredump). > > Short of that having the prctl in the process that receives the signals > they you are doing is the right way to go. Thanks for for the encouragement. > > You are however calling do_notify_parent_predump from the wrong > function, and frankly with the wrong locking. There are multiple paths > to the do_coredump function so you really want this notification from > do_coredump. This makes two - Oleg also suggested doing it in do_coredump(). I will look into it, perhaps also relocated proc_coredump_connector(). > > But I still think it would be better to solve the root cause problem and > change the coredump logic to be able to run in parallel with the normal > exit notification and zombie reaping logic. Then the problem you are > trying to solve goes away and everyone's code gets simpler. > > Eric > Thanks. -- Enke