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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Nov 2017 11:32:12 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     James Morse <james.morse@....com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: get_online_cpus() from a  preemptible() context (bug?)

On Fri, Nov 03, 2017 at 02:45:45PM +0000, James Morse wrote:
> Hi Thomas, Peter,
> 
> I'm trying to work out what stops a thread being pre-empted and migrated between
> calling get_online_cpus() and put_online_cpus().
> 
> According to __percpu_down_read(), its the pre-empt count:
> >  * Due to having preemption disabled the decrement happens on
> >  * the same CPU as the increment, avoiding the
> >  * increment-on-one-CPU-and-decrement-on-another problem.
> 
> 
> So this:
> > void cpus_read_lock(void)
> > {
> >        percpu_down_read(&cpu_hotplug_lock);
> > +
> > +       /* Can we migrated before we release this per-cpu lock? */
> > +       WARN_ON(preemptible());
> >  }
> 
> should never fire?

It should.. You're reading a comment on __percpu_down_read() and using
percpu_down_read(), _not_ the same function ;-)

If you look at percpu_down_read(), you'll note it'll disable preemption
before calling __percpu_down_read().

And yes, that whole percpu-rwsem code is fairly magical :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ