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: <1426972574-12199-1-git-send-email-agimenez@sysvalve.es>
Date:	Sat, 21 Mar 2015 22:16:14 +0100
From:	L. Alberto Giménez <agimenez@...valve.es>
To:	linux-kernel@...r.kernel.org
Cc:	Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>
Subject: [PATCH] checkpatch.pl: Add warning for harmful goto labels

Issue a warning for too broad goto labels that may make the code to
follow the wrong exit path, thus causing hard to debug bugs.

Signed-off-by: L. Alberto Giménez <agimenez@...valve.es>
---
 scripts/checkpatch.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d124359..e8ce220 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -444,6 +444,11 @@ our $allowed_asm_includes = qr{(?x:
 )};
 # memory.h: ARM has a custom one
 
+our @goto_harmful_labels = qw(
+	out
+	fail
+	);
+
 # Load common spelling mistakes and build regular expression list.
 my $misspellings;
 my %spelling_fix;
@@ -2702,6 +2707,14 @@ sub process {
 			}
 		}
 
+		if ($sline =~ /goto (.*);/) {
+			my $label = $1;
+			if (grep { /^$label$/ } @goto_harmful_labels) {
+				WARN("HARMFUL_GOTO_LABEL",
+					"Goto label '$label' is considered harmful\n" . $herecurr);
+			}
+		}
+
 # discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
 		if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
 			WARN("CONFIG_EXPERIMENTAL",
-- 
2.1.4

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