[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7cd5312-f743-cf57-7945-c2964026f652@cisco.com>
Date: Tue, 23 Oct 2018 14:40:10 -0700
From: Enke Chen <enkechen@...co.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Arnd Bergmann <arnd@...db.de>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Khalid Aziz <khalid.aziz@...cle.com>,
Kate Stewart <kstewart@...uxfoundation.org>,
Helge Deller <deller@....de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Christian Brauner <christian@...uner.io>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Dave Martin <Dave.Martin@....com>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Michal Hocko <mhocko@...nel.org>,
Rik van Riel <riel@...riel.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Roman Gushchin <guro@...com>,
Marcos Paulo de Souza <marcos.souza.org@...il.com>,
Dominik Brodowski <linux@...inikbrodowski.net>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Yang Shi <yang.shi@...ux.alibaba.com>,
Jann Horn <jannh@...gle.com>,
Kees Cook <keescook@...omium.org>, x86@...nel.org,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
"Victor Kamensky (kamensky)" <kamensky@...co.com>,
xe-linux-external@...co.com, Stefan Strogin <sstrogin@...co.com>,
Enke Chen <enkechen@...co.com>
Subject: Re: [PATCH v2] kernel/signal: Signal-based pre-coredump notification
Hi, Oleg:
On 10/23/18 12:43 PM, Enke Chen wrote:
>>
>>> --- a/fs/coredump.c
>>> +++ b/fs/coredump.c
>>> @@ -546,6 +546,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
>>> struct cred *cred;
>>> int retval = 0;
>>> int ispipe;
>>> + bool notify;
>>> struct files_struct *displaced;
>>> /* require nonrelative corefile path and be extra careful */
>>> bool need_suid_safe = false;
>>> @@ -590,6 +591,15 @@ void do_coredump(const kernel_siginfo_t *siginfo)
>>> if (retval < 0)
>>> goto fail_creds;
>>>
>>> + /*
>>> + * Send the pre-coredump signal to the parent if requested.
>>> + */
>>> + read_lock(&tasklist_lock);
>>> + notify = do_notify_parent_predump(current);
>>> + read_unlock(&tasklist_lock);
>>> + if (notify)
>>> + cond_resched();
>>
>> Hmm. I do not understand why do we need cond_resched(). And even if we need it,
>> why we can't call it unconditionally?
>
> Remember the goal is to allow the parent (e.g., a process manager) to take early
> action. The "yield" before doing coredump will help.
>
> The yield is made conditional because the notification is conditional.
> Is that ok?
Given this is in do_coredump(), it is ok to make it unconditional for simplicity.
>>
>>> +bool do_notify_parent_predump(struct task_struct *tsk)
>>> +{
>>> + struct sighand_struct *sighand;
>>> + struct kernel_siginfo info;
>>> + struct task_struct *parent;
>>> + unsigned long flags;
>>> + pid_t pid;
>>> + int sig;
>>> +
>>> + parent = tsk->parent;
>>> + sighand = parent->sighand;
>>> + pid = task_tgid_vnr(tsk);
>>> +
>>> + spin_lock_irqsave(&sighand->siglock, flags);
>>> + sig = parent->signal->predump_signal;
>>> + if (!valid_predump_signal(sig)) {
>>> + spin_unlock_irqrestore(&sighand->siglock, flags);
>>> + return false;
>>> + }
>>
>> Why do we need to check parent->signal->predump_signal under ->siglock?
>> This complicates the code for no reason, afaics.
Will simplify.
Thanks. -- Enke
Powered by blists - more mailing lists