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]
Message-ID: <4A38A719.2030709@kernel.org>
Date:	Wed, 17 Jun 2009 17:19:37 +0900
From:	Tejun Heo <tj@...nel.org>
To:	cl@...ux-foundation.org
CC:	linux-kernel@...r.kernel.org, David Howells <dhowells@...hat.com>,
	Ingo Molnar <mingo@...e.hu>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Eric Dumazet <dada1@...mosbay.com>, davem@...emloft.net
Subject: Re: [this_cpu_xx 01/11] Introduce this_cpu_ptr() and generic this_cpu_*
 operations

Hello,

cl@...ux-foundation.org wrote:
> +#ifndef this_cpu_write
> +# define this_cpu_write(pcp, val)	__this_cpu_write((pcp), (val))
> +#endif

Is this safe?  Write itself would always be atomic but this means that
a percpu variable may change its value while a thread is holding the
processor by disabling preemption.  ie,

0. v contains A for cpu0

1. task0 on cpu0 does this_cpu_write(v, B), looks up cpu but gets
   preemted out.

2. task1 gets scheduled on cpu1, disables preemption and does
   __this_cpu_read(v) and gets A and goes on with preemtion disabled.

3. task0 gets scheduled on cpu1 and executes the assignment.

4. task1 does __this_cpu_read(v) again and oops gets B this time.

Please note that this can also happen between addition or other
modifying ops and cause incorrect result.

Also, these macros depricate percpu_OP() macros, right?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ