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] [day] [month] [year] [list]
Message-ID: <20200813114804.GA30049@redhat.com>
Date:   Thu, 13 Aug 2020 13:48:05 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Jann Horn <jannh@...gle.com>
Subject: Re: [PATCH] task_work: only grab task signal lock when needed

On 08/12, Jens Axboe wrote:
>
> On 8/12/20 8:54 AM, Oleg Nesterov wrote:
> >
> > --- x/kernel/signal.c
> > +++ x/kernel/signal.c
> > @@ -2541,7 +2541,7 @@ bool get_signal(struct ksignal *ksig)
> >
> >  relock:
> >  	spin_lock_irq(&sighand->siglock);
> > -	current->jobctl &= ~JOBCTL_TASK_WORK;
> > +	smp_store_mb(current->jobctl, current->jobctl & ~JOBCTL_TASK_WORK);
> >  	if (unlikely(current->task_works)) {
> >  		spin_unlock_irq(&sighand->siglock);
> >  		task_work_run();
> >
>
> I think this should work when paired with the READ_ONCE() on the
> task_work_add() side.

It pairs with mb (implied by cmpxchg) before READ_ONCE. So we roughly have

	task_work_add:				get_signal:

	STORE(task->task_works, new_work);	STORE(task->jobctl);
	mb();					mb();
	LOAD(task->jobctl);			LOAD(task->task_works);

and we can rely on STORE-MB-LOAD.

> I haven't managed to reproduce badness with the
> existing one that doesn't have the smp_store_mb() here, so can't verify
> much beyond that...

Yes, the race is very unlikely. And the problem is minor, the target task
can miss the new work added by TWA_SIGNAL and return from get_signal() without
TIF_SIGPENDING.

> Are you going to send this out as a complete patch?

Jens, could you please send the patch? I am on vacation and travelling.
Feel free to add my ACK.

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ