Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp684253imd; Fri, 26 Oct 2018 15:24:30 -0700 (PDT) X-Google-Smtp-Source: AJdET5eCX605AeubFkjssKg47Kk1EzYMhHgvQKQ6hVX3a9lqyOfqAJ8AWS8Srw+gz1BdFrCFThLd X-Received: by 2002:a63:8d44:: with SMTP id z65mr5202114pgd.57.1540592670860; Fri, 26 Oct 2018 15:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540592670; cv=none; d=google.com; s=arc-20160816; b=WDlcWXQGz/zKHVWmNupyIwzD0EwTFlfO+BbGXxgD3Ej7bWvVKVeH3Sf55oXmdx66Gp A4IhshFUHoOp2255ECEEPPmlYLmKga4STO++25Z4ChGB9/PzS6Baa6F7310HhjO5FLqZ 8sr+M/E3ymrjrrBADLsPUgN3bIkhm6VW7vtxFj59m6ndrjlD/YkYtnfCthOzlIcfA2Jc QlVI/R4W19q6EYtBxr3E/99a2oF0miafy4nwiRNVcpVwsAqwPuLATezvwwyVHl3+zO65 wvtVpvydQd+xo5HIVnax5VhZpWD/1xugQA7N9LXfMvq+ZgdNsU9f/0/yeaZ8TDlJOA9H 5d7A== 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=z0ae1Ohcgx87rhdLTPQMWghep7+oMTp2MlHXWF4AMHI=; b=oG/jrgpy7s5/zPxW+pxa0pVPFtLIQVfccDgMMMkySxJef5DJnSAaIzmz9yqLoEycpC k8uarmMf9kxaCer4iQhhWKjinktaNPn3V0I3/dUs/RnPlR23QjeVsvrb8nnPJXZV/OK+ fmk9OESHPf/CkKOuLfg1VpN0nU3UvEKRmAWZBRtujnM7VgFH008wlpMVw1rYspo2XHnt oXO4IhLs8h8PfoUBPcT+kVOTljQuNyQDObPSVOxFd4a2Nu5SgTs/ysMHh44pii1eMkmK +s8sN+ef/YZ6TU+ujTwBJPvTJaeQcqDwsysbwUxzvW/SkLhz9jg49yr6B8B/t1nO5+tv THTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b="L/yNWk9R"; 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 f19-v6si12503320pgj.334.2018.10.26.15.24.15; Fri, 26 Oct 2018 15:24:30 -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="L/yNWk9R"; 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 S1728127AbeJ0HCl (ORCPT + 99 others); Sat, 27 Oct 2018 03:02:41 -0400 Received: from rcdn-iport-1.cisco.com ([173.37.86.72]:58951 "EHLO rcdn-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeJ0HCl (ORCPT ); Sat, 27 Oct 2018 03:02:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1433; q=dns/txt; s=iport; t=1540592634; x=1541802234; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=dybwRxN6THhqGj8y2Nt1RBZyImREVM3irDVgNYejHgI=; b=L/yNWk9R0mODrEJJugxydeesA4+EUoT5uWpE6p7hTvNqjqK1oYS4vR3y 1jKBvcD8z+9J5SYWijQTfy4ckmv1i4UasNQQ1T+r9nErrD3/uNUgdP9jx Gzz4dnn+9q8nFHdLXji1T8mfYfacSZ3NeRkTBEuDTwP2FwQAd7ApABOm2 0=; X-IronPort-AV: E=Sophos;i="5.54,429,1534809600"; d="scan'208";a="472115087" Received: from rcdn-core-7.cisco.com ([173.37.93.143]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 22:23:53 +0000 Received: from [10.154.208.99] ([10.154.208.99]) by rcdn-core-7.cisco.com (8.15.2/8.15.2) with ESMTP id w9QMNpN6003834; Fri, 26 Oct 2018 22:23:51 GMT Subject: Re: [PATCH v4] 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> <84460a77-a111-404e-4bad-88104a6e246e@cisco.com> <20181026082812.GA10581@redhat.com> From: Enke Chen Message-ID: <21f678a8-4001-df36-c26e-e96cf203b1b1@cisco.com> Date: Fri, 26 Oct 2018 15:23:47 -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: <20181026082812.GA10581@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.99, [10.154.208.99] X-Outbound-Node: rcdn-core-7.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Olge: This is really a good idea given that "parent" is declared as RCU-protected. Just a bit odd, though, that the "parent" has not been accessed this way in the code base. So just to confirm: the revised code would look like the following: static void do_notify_parent_predump(void) { struct task_struct *parent; int sig; rcu_read_lock(); parent = rcu_dereference(current->parent); sig = parent->signal->predump_signal; if (sig != 0) do_send_sig_info(sig, SEND_SIG_NOINFO, parent, PIDTYPE_TGID); rcu_read_unlock(); } Thank you so much for your help during this review. I would like to ack your contribution in the "Reviewed-by:" field. -- Enke On 10/26/18 1:28 AM, Oleg Nesterov wrote: > On 10/25, Enke Chen wrote: >> >> +static void do_notify_parent_predump(void) >> +{ >> + struct task_struct *parent; >> + int sig; >> + >> + read_lock(&tasklist_lock); >> + parent = current->parent; >> + sig = parent->signal->predump_signal; >> + if (sig != 0) >> + do_send_sig_info(sig, SEND_SIG_NOINFO, parent, PIDTYPE_TGID); >> + read_unlock(&tasklist_lock); > > Ah. It is strange I didn't think about this before... Please, do not take > tasklist_lock, use rcu_read_lock() instead. do_send_sig_info() uses the > rcu-friendly lock_task_sighand(), so rcu_dereference(parent) should work > fine. > > Oleg. >