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]
Message-Id: <20190829165025.15750-1-efremov@linux.com>
Date:   Thu, 29 Aug 2019 19:50:15 +0300
From:   Denis Efremov <efremov@...ux.com>
To:     linux-kernel@...r.kernel.org
Cc:     Denis Efremov <efremov@...ux.com>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Anton Altaparmakov <anton@...era.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Boris Pismenny <borisp@...lanox.com>,
        "Darrick J. Wong" <darrick.wong@...cle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Dennis Dalessandro <dennis.dalessandro@...el.com>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Inaky Perez-Gonzalez <inaky.perez-gonzalez@...el.com>,
        Juergen Gross <jgross@...e.com>,
        Leon Romanovsky <leon@...nel.org>,
        Mike Marciniszyn <mike.marciniszyn@...el.com>,
        Pali Rohár <pali.rohar@...il.com>,
        Rob Clark <robdclark@...il.com>,
        Saeed Mahameed <saeedm@...lanox.com>,
        Sean Paul <sean@...rly.run>, linux-arm-msm@...r.kernel.org,
        linux-fsdevel@...r.kernel.org, linux-input@...r.kernel.org,
        linux-ntfs-dev@...ts.sourceforge.net, linux-rdma@...r.kernel.org,
        linux-wimax@...el.com, linux-xfs@...r.kernel.org,
        xen-devel@...ts.xenproject.org, netdev@...r.kernel.org,
        dri-devel@...ts.freedesktop.org, Joe Perches <joe@...ches.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Whitcroft <apw@...onical.com>
Subject: [PATCH v3 01/11] checkpatch: check for nested (un)?likely() calls

IS_ERR(), IS_ERR_OR_NULL(), IS_ERR_VALUE() and WARN*() already contain
unlikely() optimization internally. Thus, there is no point in calling
these functions and defines under likely()/unlikely().

This check is based on the coccinelle rule developed by Enrico Weigelt
https://lore.kernel.org/lkml/1559767582-11081-1-git-send-email-info@metux.net/

Signed-off-by: Denis Efremov <efremov@...ux.com>
Cc: Joe Perches <joe@...ches.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Whitcroft <apw@...onical.com>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 93a7edfe0f05..56969ce06df4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6480,6 +6480,12 @@ sub process {
 			     "Using $1 should generally have parentheses around the comparison\n" . $herecurr);
 		}
 
+# nested likely/unlikely calls
+		if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
+			WARN("LIKELY_MISUSE",
+			     "nested (un)?likely() calls, $1 already uses unlikely() internally\n" . $herecurr);
+		}
+
 # whine mightly about in_atomic
 		if ($line =~ /\bin_atomic\s*\(/) {
 			if ($realfile =~ m@...ivers/@) {
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ