Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp639635ima; Wed, 24 Oct 2018 07:03:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5fGU64J2YJFBAgqpXAZ781dNd3wUgkfRhm5+cOWS4LNs2y+11tpqa74zjYSn5g2EN//P/OC X-Received: by 2002:a65:4683:: with SMTP id h3mr2542975pgr.225.1540389792337; Wed, 24 Oct 2018 07:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540389792; cv=none; d=google.com; s=arc-20160816; b=Sz6mR1R/gUdaknAhMrGpfsPxt6n3UyCcxlk/ftNSw+Rb3Ul5kgj0ydQrBqUfzKUee5 zfaJzTXaFw9MlUpu6eWUVDH3fI/7SJsG75BplleF/XYrOrvJ67ULhFByFHAiN9HY6qEC rFZvg6QxhrkDYDwHcSVQNW5Rf9MAFdklzydX+odoNOgdbk54VHUIwZNvtwS+R5eBrc00 rS38IuhPpa0ilkK+f+oywRgsRYbF7jy7F0NDIn+JWL0Y5ssdw/5wKKpvQRTaWVs6UB4j fawZDnQvBycbso11B4egqfiL1122/wyMgsylLRCxcu9X9QTe7kvP+/m8oBu30uleVWS9 woug== 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; bh=0bihnbF1Jdbn9uLw/UdWsSzDM+kAeHXC064rlmxfA3M=; b=NUaZ9qJTdbKjBOl4r0+PoGdf5fp24CzjcOWhrpEFyO/FICo/bEj405jhksP0/ovPF0 V5lQsAHEeCbjKkNhUInB5ZqiodsbL9RWmEg4LA3ZIskpea1/aRNe8ZuaipUPAXAzkJCg Ct/QOXLg1vdgI98RqP9D234xNXjJjIB5HC/b3+7bDa3rItMs0DYrshS2zw9zWJtfKIjl PzPmPkLT++IjwPKW8QGnyDKcvhJK2QVzQFyE+/OznznlW/ef0DgBdYv7MdyYWDiuTKT+ dgVKwJbLpGBWp5qJiYw0Tc83rsBTCzJPAbSPW9njCs08qmSdrjHFrErlg9xghdlsdi16 HwRA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8-v6si4292012pgq.296.2018.10.24.07.02.53; Wed, 24 Oct 2018 07:03:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbeJXWaj (ORCPT + 99 others); Wed, 24 Oct 2018 18:30:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726433AbeJXWaj (ORCPT ); Wed, 24 Oct 2018 18:30:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D17DF308421B; Wed, 24 Oct 2018 14:02:22 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.106]) by smtp.corp.redhat.com (Postfix) with SMTP id 4508B60921; Wed, 24 Oct 2018 14:02:16 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 24 Oct 2018 16:02:22 +0200 (CEST) Date: Wed, 24 Oct 2018 16:02:15 +0200 From: Oleg Nesterov To: Enke Chen Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Arnd Bergmann , "Eric W. Biederman" , 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 , Dominik Brodowski , Cyrill Gorcunov , Yang Shi , Jann Horn , Kees Cook , x86@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Victor Kamensky (kamensky)" , xe-linux-external@cisco.com, Stefan Strogin Subject: Re: [PATCH v3] kernel/signal: Signal-based pre-coredump notification Message-ID: <20181024140214.GG30128@redhat.com> References: <458c04d8-d189-4a26-729a-bb1d1d751534@cisco.com> <7741efa7-a3f8-62a1-ba52-613883164643@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7741efa7-a3f8-62a1-ba52-613883164643@cisco.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 24 Oct 2018 14:02:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23, Enke Chen wrote: > > --- a/fs/coredump.c > +++ b/fs/coredump.c > @@ -590,6 +590,12 @@ void do_coredump(const kernel_siginfo_t *siginfo) > if (retval < 0) > goto fail_creds; > > + /* > + * Send the pre-coredump signal to the parent if requested. > + */ > + do_notify_parent_predump(); > + cond_resched(); I am still not sure cond_resched() makes any sense here... > @@ -1553,6 +1553,9 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) > tty_audit_fork(sig); > sched_autogroup_fork(sig); > > + /* Clear the pre-coredump signal for the child */ > + sig->predump_signal = 0; No need, copy_signal() does zalloc(). > +void do_notify_parent_predump(void) > +{ > + struct sighand_struct *sighand; > + struct kernel_siginfo info; > + struct task_struct *parent; > + unsigned long flags; > + int sig; > + > + read_lock(&tasklist_lock); > + parent = current->parent; > + sig = parent->signal->predump_signal; > + if (sig != 0) { > + clear_siginfo(&info); > + info.si_pid = task_tgid_vnr(current); > + info.si_signo = sig; > + if (sig == SIGCHLD) > + info.si_code = CLD_PREDUMP; > + > + sighand = parent->sighand; > + spin_lock_irqsave(&sighand->siglock, flags); > + __group_send_sig_info(sig, &info, parent); > + spin_unlock_irqrestore(&sighand->siglock, flags); You can just use do_send_sig_info() and remove sighand/flags/spin_lock_irqsave. Perhaps the "likely" predump_signal==0 check at the start makes sense to avoid read_lock(tasklist). And I'd suggest to move it into coredump.c and make it static. It won't have another user. Oleg.