Skip to contentSkip to conversation

xsm: only define XSM_MAGIC in xsm.h

PATCH In review Doug Goldstein 3 participants 5 messages Mar 16, 2016 – Mar 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 xsm: only define XSM_MAGIC in xsm.h

Rather than have XSM_MAGIC set in the global xen/config.h and set in xsm.h if it's unset, just set it once in xsm.h since its only used in files that already include xsm.h

---
CC: Daniel De Graaf <[email protected]>

---
 xen/include/xen/config.h | 1 -
 xen/include/xsm/xsm.h    | 7 +++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
xen/include/xen/config.h +0 -1
index 96f5539..3f8c53d 100644
@@ -79,7 +79,6 @@
 #define STR(...) __STR(__VA_ARGS__)
 
 #ifdef CONFIG_FLASK
-#define XSM_MAGIC 0xf97cff8c
 /* Maintain statistics on the access vector cache */
 #define FLASK_AVC_STATS 1
 #endif
xen/include/xsm/xsm.h +5 -2
index 3afed70..37a102a 100644
@@ -23,8 +23,11 @@ DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
 
 /* policy magic number (defined by XSM_MAGIC) */
 typedef u32 xsm_magic_t;
-#ifndef XSM_MAGIC
-#define XSM_MAGIC 0x00000000
+
+#ifdef CONFIG_FLASK
+#define XSM_MAGIC 0xf97cff8c
+#else
+#define XSM_MAGIC 0x0
 #endif
 
 /* These annotations are used by callers and in dummy.h to document the
Signature · 7 lines
2.7.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 2/2 xsm: move FLASK_AVC_STATS to Kconfig

Have Kconfig set CONFIG_FLASK_AVC_STATS and prefix all uses with CONFIG_ to use the Kconfig variable.

---
CC: Daniel De Graaf <[email protected]>

---
 xen/common/Kconfig          | 6 ++++++
 xen/include/xen/config.h    | 5 -----
 xen/xsm/flask/avc.c         | 4 ++--
 xen/xsm/flask/flask_op.c    | 4 ++--
 xen/xsm/flask/include/avc.h | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
xen/common/Kconfig +6 -0
index 3522ecb..ad9f7bf 100644
@@ -23,6 +23,12 @@ config FLASK
 
 	  If unsure, say N.
 
+config FLASK_AVC_STATS
+	def_bool y
+	depends on FLASK
+	---help---
+	  Maintain statistics on the access vector cache
+
 # Select HAS_DEVICE_TREE if device tree is supported
 config HAS_DEVICE_TREE
 	bool
xen/include/xen/config.h +0 -5
index 3f8c53d..ef6e5ee 100644
@@ -78,11 +78,6 @@
 #define __STR(...) #__VA_ARGS__
 #define STR(...) __STR(__VA_ARGS__)
 
-#ifdef CONFIG_FLASK
-/* Maintain statistics on the access vector cache */
-#define FLASK_AVC_STATS 1
-#endif
-
 /* allow existing code to work with Kconfig variable */
 #define NR_CPUS CONFIG_NR_CPUS
 
xen/xsm/flask/avc.c +2 -2
index 31bc702..7764379 100644
@@ -56,7 +56,7 @@ const struct selinux_class_perm selinux_class_perm = {
 #define AVC_DEF_CACHE_THRESHOLD        512
 #define AVC_CACHE_RECLAIM        16
 
-#ifdef FLASK_AVC_STATS
+#ifdef CONFIG_FLASK_AVC_STATS
 #define avc_cache_stats_incr(field)                 \
 do {                                \
     __get_cpu_var(avc_cache_stats).field++;        \
@@ -101,7 +101,7 @@ struct avc_callback_node {
 /* Exported via Flask hypercall */
 unsigned int avc_cache_threshold = AVC_DEF_CACHE_THRESHOLD;
 
-#ifdef FLASK_AVC_STATS
+#ifdef CONFIG_FLASK_AVC_STATS
 DEFINE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
 #endif
 
xen/xsm/flask/flask_op.c +2 -2
index f4f5dd1..3c9c99e 100644
@@ -469,7 +469,7 @@ static int flask_security_make_bools(void)
     return ret;
 }
 
-#ifdef FLASK_AVC_STATS
+#ifdef CONFIG_FLASK_AVC_STATS
 
 static int flask_security_avc_cachestats(struct xen_flask_cache_stats *arg)
 {
@@ -761,7 +761,7 @@ ret_t do_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_flask_op)
         rv = avc_get_hash_stats(&op.u.hash_stats);
         break;
 
-#ifdef FLASK_AVC_STATS
+#ifdef CONFIG_FLASK_AVC_STATS
     case FLASK_AVC_CACHESTATS:
         rv = flask_security_avc_cachestats(&op.u.cache_stats);
         break;
xen/xsm/flask/include/avc.h +1 -1
index 4283562..729856e 100644
@@ -108,7 +108,7 @@ struct xen_flask_hash_stats;
 int avc_get_hash_stats(struct xen_flask_hash_stats *arg);
 extern unsigned int avc_cache_threshold;
 
-#ifdef FLASK_AVC_STATS
+#ifdef CONFIG_FLASK_AVC_STATS
 DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
 #endif
 
Signature · 7 lines
2.7.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
In reply to Doug Goldstein
Quoted 33 lines · Doug Goldstein

Rather than have XSM_MAGIC set in the global xen/config.h and set in xsm.h if it's unset, just set it once in xsm.h since its only used in files that already include xsm.h

---
CC: Daniel De Graaf <[email protected]>

---
 xen/include/xen/config.h | 1 -
 xen/include/xsm/xsm.h    | 7 +++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
xen/include/xen/config.h +0 -1
index 96f5539..3f8c53d 100644
@@ -79,7 +79,6 @@
 #define STR(...) __STR(__VA_ARGS__)
 
 #ifdef CONFIG_FLASK
-#define XSM_MAGIC 0xf97cff8c
 /* Maintain statistics on the access vector cache */
 #define FLASK_AVC_STATS 1
 #endif
xen/include/xsm/xsm.h +0 -0
index 3afed70..37a102a 100644
@@ -23,8 +23,11 @@ DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
 
 /* policy magic number (defined by XSM_MAGIC) */
 typedef u32 xsm_magic_t;

xen/include/xsm/xsm.h DEFINE_XEN_GUEST_HANDLE(xsm_op_t); · line 33

Quoted 10 lines
xen/include/xsm/xsm.h +5 -2
-#ifndef XSM_MAGIC
-#define XSM_MAGIC 0x00000000
+
+#ifdef CONFIG_FLASK
+#define XSM_MAGIC 0xf97cff8c
+#else
+#define XSM_MAGIC 0x0
 #endif
 
 /* These annotations are used by callers and in dummy.h to document the

ping?

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v2 1/2
#3 lore raw
In reply to Doug Goldstein
Quoted 5 lines · Doug Goldstein

Rather than have XSM_MAGIC set in the global xen/config.h and set in xsm.h if it's unset, just set it once in xsm.h since its only used in files that already include xsm.h

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 8 lines · Daniel De Graaf
Quoted 5 lines · Doug Goldstein

Rather than have XSM_MAGIC set in the global xen/config.h and set in xsm.h if it's unset, just set it once in xsm.h since its only used in files that already include xsm.h

Both patches applied.

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel