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:	Thu, 27 Aug 2015 16:57:13 -0400
From:	Chuck Ebbert <cebbert.lkml@...il.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH -next] static-keys: Better error checking for
 static_key_enable/disable

The  warnings for static_key_enable/disable don't catch common
errors. For example, starting with a default enabled key and
calling enable doesn't cause a warning until the next enable
or disable. Check explicitly for zero or one instead of allowing
both values in every case. Generated code should be smaller too.

Signed-off-by: Chuck Ebbert <cebbert.lkml@...il.com>

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 7f653e8..ba9ca0c 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -225,7 +225,7 @@ static inline void static_key_enable(struct static_key *key)
 {
 	int count = static_key_count(key);
 
-	WARN_ON_ONCE(count < 0 || count > 1);
+	WARN_ON_ONCE(count);
 
 	if (!count)
 		static_key_slow_inc(key);
@@ -235,7 +235,7 @@ static inline void static_key_disable(struct static_key *key)
 {
 	int count = static_key_count(key);
 
-	WARN_ON_ONCE(count < 0 || count > 1);
+	WARN_ON_ONCE(count != 1);
 
 	if (count)
 		static_key_slow_dec(key);
--
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