Subject: Re: [PATCH net-next 1/2] connector/cn_proc: Handle threads for proc connector

From: Oleg Nesterov <[email-masked]>
Date: Fri, 20 Sep 2024 13:00:23 +0200

On 09/19, Anjali Kulkarni wrote:
>
> @@ -413,6 +416,10 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
>  	if (msg->len == sizeof(*pinput)) {
>  		pinput = (struct proc_input *)msg->data;
>  		mc_op = pinput->mcast_op;
> +		if (mc_op == PROC_CN_MCAST_NOTIFY) {
> +			current->exit_code = pinput->uexit_code;
> +			return;

...

> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -821,6 +821,7 @@ void __noreturn do_exit(long code)
>  {
>  	struct task_struct *tsk = current;
>  	int group_dead;
> +	__u32 uexit_code;
>  
>  	WARN_ON(irqs_disabled());
>  
> @@ -863,6 +864,8 @@ void __noreturn do_exit(long code)
>  		tty_audit_exit();
>  	audit_free(tsk);
>  
> +	uexit_code = tsk->exit_code;

I don't think you can use task_struct->exit_code. If this task is ptraced,
it can be changed/cleared in, say, ptrace_stop() after PROC_CN_MCAST_NOTIFY.

Oleg.