summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2017-01-16 00:42:26 -0800
committerJohn Johansen <john.johansen@canonical.com>2017-01-16 01:18:23 -0800
commit57e36bbd67bd1509f550311b162be78cadfe887b (patch)
tree6aa7348311891865a045cd46f9846e74dab88dbf /security
parent92b6d8eff55f8dca57ade26e1dde2c3b6acdae02 (diff)
downloadlinux-57e36bbd67bd1509f550311b162be78cadfe887b.tar.bz2
apparmor: add macro for bug asserts to check that a lock is held
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/include/lib.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
index 4699c2b43fa0..61dedd7333df 100644
--- a/security/apparmor/include/lib.h
+++ b/security/apparmor/include/lib.h
@@ -19,6 +19,17 @@
#include "match.h"
+/* Provide our own test for whether a write lock is held for asserts
+ * this is because on none SMP systems write_can_lock will always
+ * resolve to true, which is what you want for code making decisions
+ * based on it, but wrong for asserts checking that the lock is held
+ */
+#ifdef CONFIG_SMP
+#define write_is_locked(X) !write_can_lock(X)
+#else
+#define write_is_locked(X) (1)
+#endif /* CONFIG_SMP */
+
/*
* DEBUG remains global (no per profile flag) since it is mostly used in sysctl
* which is not related to profile accesses.