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: <20170504190915.16887-1-fabf@skynet.be>
Date:   Thu,  4 May 2017 21:09:15 +0200
From:   Fabian Frederick <fabf@...net.be>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Julia Lawall <Julia.Lawall@...6.fr>
Cc:     Gilles Muller <Gilles.Muller@...6.fr>, cocci@...teme.lip6.fr,
        Jan Kara <jack@...e.com>, linux-kernel@...r.kernel.org,
        fabf@...net.be
Subject: [PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()

This script removes NULL check on kmap() and all process involved
(OOM message ...)

Thanks to Jan Kara for explanations.

Acked-by: Julia Lawall <julia.lawall@...6.fr>
Signed-off-by: Fabian Frederick <fabf@...net.be>
---
 scripts/coccinelle/misc/kmap.cocci | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 scripts/coccinelle/misc/kmap.cocci

diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci
new file mode 100644
index 0000000..9ae4a6e
--- /dev/null
+++ b/scripts/coccinelle/misc/kmap.cocci
@@ -0,0 +1,43 @@
+/// kmap never fails; remove NULL test case.
+///
+// Copyright: (C) 2017 Fabian Frederick.  GPLv2.
+// Comments: -
+// Options: --no-includes --include-headers
+
+virtual patch
+virtual org
+virtual report
+virtual context
+
+@r2 depends on patch@
+expression E;
+position p;
+@@
+
+E = kmap(...);
+- if (!E) {
+- ...
+- }
+
+@r depends on context || report || org @
+expression E;
+position p;
+@@
+
+* E = kmap(...);
+* if (@p!E) {
+* ...
+* }
+
+@...ipt:python depends on org@
+p << r.p;
+@@
+
+cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p)
+
+@...ipt:python depends on report@
+p << r.p;
+@@
+
+msg = "WARNING: NULL check on kmap() result is not needed."
+coccilib.report.print_report(p[0], msg)
-- 
2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ