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-next>] [day] [month] [year] [list]
Date:	Mon, 4 Aug 2014 13:07:47 -0400
From:	Pranith Kumar <pranith@...ech.edu>
To:	Paul McKenney <paulmck@...ux.vnet.ibm.com>,
	Peter Zijlstra <peterz@...radead.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Question regarding "Control Dependencies" in memory-barriers.txt

The section "Control Dependencies" in memory-barriers.txt has the
following text:

662 In addition, you need to be careful what you do with the local variable 'q',
663 otherwise the compiler might be able to guess the value and again remove
664 the needed conditional.  For example:
665
666         q = ACCESS_ONCE(a);
667         if (q % MAX) {
668                 barrier();
669                 ACCESS_ONCE(b) = p;
670                 do_something();
671         } else {
672                 barrier();
673                 ACCESS_ONCE(b) = p;
674                 do_something_else();
675         }
676
677 If MAX is defined to be 1, then the compiler knows that (q % MAX) is
678 equal to zero, in which case the compiler is within its rights to
679 transform the above code into the following:
680
681         q = ACCESS_ONCE(a);
682         ACCESS_ONCE(b) = p;
683         do_something_else();

Given that there is an explicit barrier() in both the branches of
if/else statement, how can the above transformation happen? The
compiler cannot just remove the barrier(), right?

I think it will transform to the following if MAX is defined to 1:

q = ACCESS_ONCE(a);
barrier();
ACCESS_ONCE(b) = p;
do_something_else();

and hence the ordering will be preserved. What am I missing here?

-- 
Pranith
--
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