Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1127588ima; Wed, 24 Oct 2018 15:04:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5fOS8f+D7TVDhwRIq7WCZZBM/aiuBwiW08Y/hYmeC39owIOCQ78R+kRcCy2ojByNqtKbuds X-Received: by 2002:a17:902:930b:: with SMTP id bc11-v6mr4143497plb.101.1540418674701; Wed, 24 Oct 2018 15:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540418674; cv=none; d=google.com; s=arc-20160816; b=amIr32+Xl+PW43mhQ+Wb4A0kAcPX/Ru5JwjJcIdvQL6jTQfZEgXZ3fnoltHif05Yik V8WYMc8YZK8AXxzgNAH17pQYaypiYhD2A0V1jB1zTpcERQAMZNWLyCGYYJNh7GtO7Oie mxZBh4xaBVwW5YKoYIqeVlhev7LX3Ihppue7FGLMsVAC5a6+kRNB5XEuMJ7ytF2OXCQ7 znKZ8oL47FwcLsQ5QdRejwUUEV9ABOCKDYrkVqghNl3a+i+kv29GeNdvXZvvLahbnSWz RcmA1Mq1h+He6ElqPu2+k3Hus9azB5DefMh1x85BO+aFpE3iuOKb6g00C3LddyU88Ni3 xQJg== 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=oFpnmQZEXVX+UE+h37EaGcGQxMBSmGAr+9CovzNRw/A=; b=P19nwt6q+mDxMJhlcLuOY0JP2w+BdG94ouvBMHC2duucjtgJmni23BxbHAWc5boFJK 24eCA+ObJk5Snc+iAe4drgPa6fTm13zodwJB1ef+B5r4IRSHS7GN1FIUjBON4sjUWVCV pAyusICsv7FmpvFDWAvir7Huz/fbqyhc2itdmAFddzZX5ITka2cbeOmAUB4NSRev06Wl Ti8TlGBp2osglG5kKdGlVsNukda+qiWw1eooH2UbpxYgjNau9t60oZlMtIti+SJJAgBu Eh4nw/gRSYsWV33EmGsYNEHIeg84xuaoCle+MHJDuDUm0paA4OlCHWWw/Q+1Hslbkp6D K7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=BTXBrpdO; 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 k5-v6si5776152pgq.413.2018.10.24.15.04.18; Wed, 24 Oct 2018 15:04:34 -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=BTXBrpdO; 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 S1726351AbeJYGcW (ORCPT + 99 others); Thu, 25 Oct 2018 02:32:22 -0400 Received: from alln-iport-2.cisco.com ([173.37.142.89]:37932 "EHLO alln-iport-2.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726019AbeJYGcV (ORCPT ); Thu, 25 Oct 2018 02:32:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2009; q=dns/txt; s=iport; t=1540418552; x=1541628152; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=/SsMWhXKMEgM4sSn8P6VxadKYcdsWlS3XGgb5Urgnzg=; b=BTXBrpdO0TAnsJleYGtNh4Pj0RODyNCRU40pgGtkqTUGXzZCqvlzTw+s n5xGxwsKOaLY5mI68G/wQ0Qe0YZDMNsHNx4WUygbK/Yh71qf+DanFgeeD dElf6cnrRJ/FOgB8+XM1QWUHfgzwVsNdOSq2jpIjMpwSS6Bktbx+44giI k=; X-IronPort-AV: E=Sophos;i="5.54,422,1534809600"; d="scan'208";a="191158926" Received: from alln-core-9.cisco.com ([173.36.13.129]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 22:02:32 +0000 Received: from [10.154.208.140] ([10.154.208.140]) by alln-core-9.cisco.com (8.15.2/8.15.2) with ESMTP id w9OM2TCG020367; Wed, 24 Oct 2018 22:02:30 GMT Subject: Re: [PATCH v3] kernel/signal: Signal-based pre-coredump notification To: Oleg Nesterov 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 , Enke Chen References: <458c04d8-d189-4a26-729a-bb1d1d751534@cisco.com> <7741efa7-a3f8-62a1-ba52-613883164643@cisco.com> <20181024140214.GG30128@redhat.com> From: Enke Chen Message-ID: Date: Wed, 24 Oct 2018 15:02:29 -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: <20181024140214.GG30128@redhat.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.140, [10.154.208.140] X-Outbound-Node: alln-core-9.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Oleg: On 10/24/18 7:02 AM, Oleg Nesterov wrote: > 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(). > Removed. > >> +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. Ok. > > Perhaps the "likely" predump_signal==0 check at the start makes sense to avoid > read_lock(tasklist). I am not sure if we should/need to deviate from the convention (locking before access the parent). In any case it may not matter as the coredump is in the exceptional code flow. > > And I'd suggest to move it into coredump.c and make it static. It won't have > another user. Ok. Thanks. -- Enke