/* Performs checks and sets PT_PTRACED. Should be used by all ptrace implementations for PTRACE_TRACEME.  */
int ptrace_traceme(void)
/* Performs checks and sets PT_PTRACED. Should be used by all ptrace implementations for PTRACE_TRACEME.  */
int ptrace_traceme(void)
{
	int ret = -EPERM;
	write_lock_irq(&tasklist_lock);
	if (!current->ptrace) {
		ret = security_ptrace_traceme(current->parent);
		if (!ret && !(current->real_parent->flags & PF_EXITING)) {
			current->ptrace = PT_PTRACED;
			__ptrace_link(current, current->real_parent);
		}
	}
	write_unlock_irq(&tasklist_lock);
	return ret;
}