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:	Sat, 6 Aug 2016 10:45:48 +0530
From:	Amitoj Kaur Chawla <amitoj1606@...il.com>
To:	Julia.Lawall@...6.fr, Gilles.Muller@...6.fr, nicolas.palix@...g.fr,
	mmarek@...e.com, cocci@...teme.lip6.fr,
	linux-kernel@...r.kernel.org
Subject: [PATCH v3] Coccinelle: Script to replace NULL test with IS_ERR test
 for devm_ioremap_resource

This script detects cases which have incorrect error handling for
devm_ioremap_resource function, employing a NULL test instead of an
IS_ERR() test.

Acked-by: Julia Lawall <julia.lawall@...6.fr>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@...il.com>
---
Changes in v2:
        -Changed script to correct error handling instead of just
         detecting cases of incorrect error handling
Changes in v3:
        -Reverted to original script in v1 to ensure no error in
         modifying inconsistent paths.

 .../null/devm_ioremap_resource_test.cocci          | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 scripts/coccinelle/null/devm_ioremap_resource_test.cocci

diff --git a/scripts/coccinelle/null/devm_ioremap_resource_test.cocci b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci
new file mode 100644
index 0000000..734dbd3
--- /dev/null
+++ b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci
@@ -0,0 +1,38 @@
+/// Correct error handling for devm_ioremap_resource
+///
+// Confidence: High
+// Copyright: (C) 2016 Amitoj Kaur Chawla
+// Keywords: devm,devm_ioremap_resource
+
+virtual context
+virtual org
+virtual report
+
+// ----------------------------------------------------------------------------
+
+@err depends on context || org || report@
+statement S;
+expression e;
+position j0;
+@@
+
+  e = devm_ioremap_resource(...);
+* if (!e@j0) S
+// ----------------------------------------------------------------------------
+
+@...ipt:python err_org depends on org@
+j0 << err.j0;
+@@
+
+msg = "Incorrect error handling."
+coccilib.org.print_todo(j0[0], msg)
+
+// ----------------------------------------------------------------------------
+
+@...ipt:python err_report depends on report@
+j0 << err.j0;
+@@
+
+msg = "Incorrect error handling."
+coccilib.report.print_report(j0[0], msg)
+
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ