backports: don't use __ro_after_init with genl families on <=4.9
authorJohannes Berg <johannes.berg@intel.com>
Thu, 9 Feb 2017 13:50:24 +0000 (14:50 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 9 Feb 2017 13:52:26 +0000 (14:52 +0100)
4.9 introduced __ro_after_init, but generic netlink family
registration was only changed to allow it in 4.10, otherwise
deregistration will crash due to writing to the RO memory.

Unfortunately, spatch doesn't handle this, so manually patch
the families to replace __ro_after_init with __genl_ro_after_init
which is defined to nothing on kernel version <= 4.9.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/net/genetlink.h
patches/0077-genl-ro-after-init/hwsim.patch [new file with mode: 0644]
patches/0077-genl-ro-after-init/nl80211.patch [new file with mode: 0644]

index 0a1ff6edb395ce5c4cae46d79c61943c01598910..a46ac6037eba647efd9608efebed4de50839cd97 100644 (file)
@@ -172,6 +172,10 @@ static inline struct nlattr **genl_family_attrbuf(struct genl_family *family)
 
        return family->attrbuf;
 }
+
+#define __genl_ro_after_init
+#else
+#define __genl_ro_after_init __ro_after_init
 #endif
 
 #endif /* __BACKPORT_NET_GENETLINK_H */
diff --git a/patches/0077-genl-ro-after-init/hwsim.patch b/patches/0077-genl-ro-after-init/hwsim.patch
new file mode 100644 (file)
index 0000000..5599069
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/drivers/net/wireless/mac80211_hwsim.c
++++ b/drivers/net/wireless/mac80211_hwsim.c
+@@ -3244,7 +3244,7 @@ static const struct genl_ops hwsim_ops[] = {
+       },
+ };
+-static struct genl_family hwsim_genl_family __ro_after_init = {
++static struct genl_family hwsim_genl_family __genl_ro_after_init = {
+       .name = "MAC80211_HWSIM",
+       .version = 1,
+       .maxattr = HWSIM_ATTR_MAX,
diff --git a/patches/0077-genl-ro-after-init/nl80211.patch b/patches/0077-genl-ro-after-init/nl80211.patch
new file mode 100644 (file)
index 0000000..bd50213
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -12823,7 +12823,7 @@ static const struct genl_ops nl80211_ops[] = {
+       },
+ };
+-static struct genl_family nl80211_fam __ro_after_init = {
++static struct genl_family nl80211_fam __genl_ro_after_init = {
+       .name = NL80211_GENL_NAME,      /* have users key off the name instead */
+       .hdrsize = 0,                   /* no private header */
+       .version = 1,                   /* no particular meaning now */