Re: [PATCH v2] kernel/signal: Signal-based pre-coredump notification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux