[ovs-dev] [PATCH] datapath: compat: Fix compilation issue with grsecurity patch

Yi-Hung Wei yihung.wei at gmail.com
Wed Oct 10 23:21:57 UTC 2018


Grsecurity patch enables GCC's constify plugin so that it will
automatically constify a class of type that contains only function
pointers.  However, if the type is also specified by __read_mostly, it
will put the constify object into the read_mostly section that results
in compilation error.  This patch works around the compilation issue by
disabling __ready_mostly when grsecurity patch is applied.

Tested with 4.14.33 kernel with grsecurity patch.

Signed-off-by: Yi-Hung Wei <yihung.wei at gmail.com>
---
 datapath/compat.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/datapath/compat.h b/datapath/compat.h
index 98b68640a372..b820251a4767 100644
--- a/datapath/compat.h
+++ b/datapath/compat.h
@@ -28,6 +28,13 @@
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 #include <net/netfilter/nf_conntrack_count.h>
 
+/* Fix grsecurity patch compilation issue. */
+#ifdef CONSTIFY_PLUGIN
+#include <linux/cache.h>
+#undef __read_mostly
+#define __read_mostly
+#endif
+
 /* Even though vanilla 3.10 kernel has grp->id, RHEL 7 kernel is missing
  * this field. */
 #ifdef HAVE_GENL_MULTICAST_GROUP_WITH_ID
-- 
2.7.4



More information about the dev mailing list