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>] [day] [month] [year] [list]
Message-Id: <1460972897-20833-1-git-send-email-Julia.Lawall@lip6.fr>
Date:	Mon, 18 Apr 2016 11:48:17 +0200
From:	Julia Lawall <Julia.Lawall@...6.fr>
To:	Julia Lawall <Julia.Lawall@...6.fr>
Cc:	kernel-janitors@...r.kernel.org,
	Gilles Muller <Gilles.Muller@...6.fr>,
	Nicolas Palix <nicolas.palix@...g.fr>,
	Michal Marek <mmarek@...e.com>, cocci@...teme.lip6.fr,
	linux-kernel@...r.kernel.org
Subject: [PATCH] coccinelle: api: use READ_ONCE or WRITE_ONCE instead of ACCESS_ONCE

Suggested by Joe Perches.

Signed-off-by: Julia Lawall <Julia.Lawall@...6.fr>

---
 scripts/coccinelle/api/access_once.cocci |   73 +++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/scripts/coccinelle/api/access_once.cocci b/scripts/coccinelle/api/access_once.cocci
new file mode 100644
index 0000000..f463aff
--- /dev/null
+++ b/scripts/coccinelle/api/access_once.cocci
@@ -0,0 +1,73 @@
+/// Use READ_ONCE or WRITE_ONCE instead of ACCESS_ONCE.
+///
+// Confidence: High
+// Contact: Joe Perches <joe@...ches.com>
+// Options: --no-includes --include-headers
+
+virtual patch
+virtual context
+virtual org
+virtual report
+
+@...tten depends on patch && !context && !org && !report@
+expression e1;
+expression e2;
+@@
+
+-       ACCESS_ONCE(e1) = e2
++       WRITE_ONCE(e1, e2)
+
+@...d depends on patch && !context && !org && !report@
+expression e1;
+@@
+
+-       ACCESS_ONCE(e1)
++       READ_ONCE(e1)
+
+// ----------------------------------------------------------------------------
+
+@...tten_context depends on !patch && (context || org || report)@
+expression e1, e2;
+position j0;
+@@
+
+*        ACCESS_ONCE@j0(e1) = e2
+
+@...d_context depends on !patch && (context || org || report)@
+expression e1;
+position j0;
+@@
+
+*        ACCESS_ONCE@j0(e1)
+
+// ----------------------------------------------------------------------------
+
+@...ipt:python written_org depends on org@
+j0 << written_context.j0;
+@@
+
+msg = "Use WRITE_ONCE for an ACCESS_ONCE that is written."
+coccilib.org.print_todo(j0[0], msg, color="ovl-face2")
+
+@...ipt:python read_org depends on org@
+j0 << read_context.j0;
+@@
+
+msg = "Use READ_ONCE for an ACCESS_ONCE that is read."
+coccilib.org.print_todo(j0[0], msg)
+
+// ----------------------------------------------------------------------------
+
+@...ipt:python written_report depends on report@
+j0 << written_context.j0;
+@@
+
+msg = "Use WRITE_ONCE for an ACCESS_ONCE that is written."
+coccilib.report.print_report(j0[0], msg)
+
+@...ipt:python read_report depends on report@
+j0 << read_context.j0;
+@@
+
+msg = "Use READ_ONCE for an ACCESS_ONCE that is read."
+coccilib.report.print_report(j0[0], msg)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ