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: <498869868.209.1596640956570.JavaMail.zimbra@efficios.com>
Date:   Wed, 5 Aug 2020 11:22:36 -0400 (EDT)
From:   Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     linux-kernel <linux-kernel@...r.kernel.org>,
        Will Deacon <will@...nel.org>, paulmck <paulmck@...nel.org>,
        Nicholas Piggin <npiggin@...il.com>,
        Andy Lutomirski <luto@...capital.net>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC PATCH 2/2] sched: membarrier: cover kthread_use_mm

----- On Aug 5, 2020, at 6:59 AM, Peter Zijlstra peterz@...radead.org wrote:

> On Tue, Aug 04, 2020 at 07:01:53PM +0200, peterz@...radead.org wrote:
>> On Tue, Aug 04, 2020 at 10:59:33AM -0400, Mathieu Desnoyers wrote:
>> > ----- On Aug 4, 2020, at 10:51 AM, Peter Zijlstra peterz@...radead.org wrote:
>> > > On Tue, Jul 28, 2020 at 12:00:10PM -0400, Mathieu Desnoyers wrote:
>> 
>> > >>  	task_lock(tsk);
>> > >> +	/*
>> > >> +	 * When a kthread stops operating on an address space, the loop
>> > >> +	 * in membarrier_{private,global}_expedited() may not observe
>> > >> +	 * that tsk->mm, and not issue an IPI. Membarrier requires a
>> > >> +	 * memory barrier after accessing user-space memory, before
>> > >> +	 * clearing tsk->mm.
>> > >> +	 */
>> > >> +	smp_mb();
>> > >>  	sync_mm_rss(mm);
>> > >>  	local_irq_disable();
>> > > 
>> > > Would it make sense to put the smp_mb() inside the IRQ disable region?
>> > 
>> > I've initially placed it right after task_lock so we could eventually
>> > have a smp_mb__after_non_raw_spinlock or something with a much better naming,
>> > which would allow removing the extra barrier when it is implied by the
>> > spinlock.
>> 
>> Oh, right, fair enough. I'll go think about if smp_mb__after_spinlock()
>> will work for mutexes too.
>> 
>> It basically needs to upgrade atomic*_acquire() to smp_mb(). So that's
>> all architectures that have their own _acquire() and an actual
>> smp_mb__after_atomic().
>> 
>> Which, from the top of my head are only arm64, power and possibly riscv.
>> And if I then git-grep smp_mb__after_spinlock, all those seem to be
>> covered.
>> 
>> But let me do a better audit..
> 
> All I could find is csky, which, afaict, defines a superfluous
> smp_mb__after_spinlock.
> 
> The relevant architectures are indeed power, arm64 and riscv, they all
> have custom acquire/release and all define smp_mb__after_spinlock()
> appropriately.
> 
> Should we rename it to smp_mb__after_acquire() ?

As discussed over IRC, smp_mb__after_atomic_acquire() would be better, because
load_acquire and spin_lock have different semantic.

We could keep a define of smp_mb__after_spinlock to smp_mb__after_atomic_acquire
to make the transition simpler.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ