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

Reply via email to