lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 25 Jun 2024 14:34:44 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Tejun Heo <tj@...nel.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/17] coredump: Consolidate the work to allow SIGKILL
 during coredumps

On 06/18, Eric W. Biederman wrote:
>
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -366,18 +366,17 @@ static int zap_process(struct task_struct *start, int exit_code)
>  	struct task_struct *t;
>  	int nr = 0;
>
> -	/* Allow SIGKILL, see prepare_signal() */
>  	start->signal->flags = SIGNAL_GROUP_EXIT;
>  	start->signal->group_exit_code = exit_code;
>  	start->signal->group_stop_count = 0;
>
>  	for_each_thread(start, t) {
>  		task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
> -		if (t != current && !(t->flags & PF_POSTCOREDUMP)) {
> +		if (!(t->flags & PF_POSTCOREDUMP)) {
>  			sigaddset(&t->pending.signal, SIGKILL);
>  			signal_wake_up(t, 1);
> -			nr++;
>  		}
> +		nr += (t != current) && !(t->flags & PF_POSTCOREDUMP);
>  	}
>
>  	return nr;
> @@ -393,9 +392,12 @@ static int zap_threads(struct task_struct *tsk,
>  	if (!(signal->flags & SIGNAL_GROUP_EXIT) && !signal->group_exec_task) {
>  		signal->core_state = core_state;
>  		nr = zap_process(tsk, exit_code);
> +		atomic_set(&core_state->nr_threads, nr);
> +
> +		/* Allow SIGKILL, see prepare_signal() */
>  		clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
> +		sigdelset(&tsk->pending.signal, SIGKILL);
>  		tsk->flags |= PF_DUMPCORE;
> -		atomic_set(&core_state->nr_threads, nr);
>  	}
>  	spin_unlock_irq(&tsk->sighand->siglock);
>  	return nr;

I fail to understand... Why do we want to add SIGKILL to the current task
in zap_process() and then clear it in the caller?

Perhaps I need to read the next patches to understand the purpose, but this
looks very confusing.

And even if this makes sense after the next patches, to me

	nr += (t != current) && !(t->flags & PF_POSTCOREDUMP);

doesn't look very nice. Say, zap_process() could just do

	for_each_thread(start, t) {
		task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
		if (!(t->flags & PF_POSTCOREDUMP)) {
			sigaddset(&t->pending.signal, SIGKILL);
			signal_wake_up(t, 1);
			nr++;
		}
	}

and in zap_threads()

	-	atomic_set(&core_state->nr_threads, nr);
	+	atomic_set(&core_state->nr_threads, nr - 1);




-------------------------------------------------------------------------------
And this reminds me that zap_process() doesn't look very nice after the commit
0258b5fd7c7124b87e18 ("coredump: Limit coredumps to a single thread group"),
I'll send a simple cleanup today...

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ