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]
Message-ID: <20240708184814.GD27299@noisy.programming.kicks-ass.net>
Date: Mon, 8 Jul 2024 20:48:14 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Pavel Begunkov <asml.silence@...il.com>
Cc: Oleg Nesterov <oleg@...hat.com>, io-uring@...r.kernel.org,
	Jens Axboe <axboe@...nel.dk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Christian Brauner <brauner@...nel.org>,
	Tycho Andersen <tandersen@...flix.com>,
	Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
	Julian Orth <ju.orth@...il.com>, Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH 2/2] kernel: rerun task_work while freezing in
 get_signal()

On Mon, Jul 08, 2024 at 04:40:07PM +0100, Pavel Begunkov wrote:

> > > --- a/kernel/signal.c
> > > +++ b/kernel/signal.c
> > > @@ -2694,6 +2694,10 @@ bool get_signal(struct ksignal *ksig)
> > >   	try_to_freeze();
> > >   relock:
> > > +	clear_notify_signal();
> > > +	if (unlikely(task_work_pending(current)))
> > > +		task_work_run();
> > > +
> > >   	spin_lock_irq(&sighand->siglock);
> > 
> > Well, but can't we kill the same code at the start of get_signal() then?
> > Of course, in this case get_signal() should check signal_pending(), not
> > task_sigpending().
> 
> Should be fine, but I didn't want to change the
> try_to_freeze() -> __refrigerator() path, which also reschedules.
> 
> > Or perhaps something like the patch below makes more sense? I dunno...
> 
> It needs a far backporting, I'd really prefer to keep it
> lean and without more side effects if possible, unless
> there is a strong opinion on that.

It's been a minute since I dug my way through the signal code, but I
think I slightly favour Oleg's version for not duplicating that
task_work_run().


> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 1f9dd41c04be..e2ae85293fbb 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -2676,6 +2676,7 @@ bool get_signal(struct ksignal *ksig)
> >   	struct signal_struct *signal = current->signal;
> >   	int signr;
> > +start:
> >   	clear_notify_signal();
> >   	if (unlikely(task_work_pending(current)))
> >   		task_work_run();
> > @@ -2760,10 +2761,11 @@ bool get_signal(struct ksignal *ksig)
> >   			if (current->jobctl & JOBCTL_TRAP_MASK) {
> >   				do_jobctl_trap();
> >   				spin_unlock_irq(&sighand->siglock);
> > +				goto relock;
> >   			} else if (current->jobctl & JOBCTL_TRAP_FREEZE)
> >   				do_freezer_trap();
> > -
> > -			goto relock;
> > +				goto start;
> > +			}
> >   		}
> >   		/*
> > 
> 
> -- 
> Pavel Begunkov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ