All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] backports: add backport for nla_memdup()
@ 2016-11-12 20:18 Arend van Spriel
  2016-11-12 20:18 ` [PATCH 2/3] backports: add backport for genl_family_attrbuf() function Arend van Spriel
  2016-11-12 20:18 ` [PATCH 3/3] backports: empty define for __ro_after_init Arend van Spriel
  0 siblings, 2 replies; 6+ messages in thread
From: Arend van Spriel @ 2016-11-12 20:18 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Arend van Spriel

New helper function was introduced in netlink so a backport is needed.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 backport/backport-include/net/netlink.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
index 40160b5..b836a4b 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -189,4 +189,17 @@ static inline __le64 nla_get_le64(const struct nlattr *nla)
 }
 #endif /* < 4.4 */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
+/**
+ * nla_memdup - duplicate attribute memory (kmemdup)
+ * @src: netlink attribute to duplicate from
+ * @gfp: GFP mask
+ */
+#define nla_memdump LINUX_BACKPORT(nla_memdup)
+static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp)
+{
+	return kmemdup(nla_data(src), nla_len(src), gfp);
+}
+#endif /* < 4.9 */
+
 #endif /* __BACKPORT_NET_NETLINK_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] backports: add backport for genl_family_attrbuf() function
  2016-11-12 20:18 [PATCH 1/3] backports: add backport for nla_memdup() Arend van Spriel
@ 2016-11-12 20:18 ` Arend van Spriel
  2016-11-12 20:18 ` [PATCH 3/3] backports: empty define for __ro_after_init Arend van Spriel
  1 sibling, 0 replies; 6+ messages in thread
From: Arend van Spriel @ 2016-11-12 20:18 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Arend van Spriel

The function genl_family_attrbuf() was added to the kernel. This
backport caries the warning for parallel ops, but it does not
assert the genl_mutex as it does not have access to it.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 backport/backport-include/net/genetlink.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h
index cf3e67c..f81b825 100644
--- a/backport/backport-include/net/genetlink.h
+++ b/backport/backport-include/net/genetlink.h
@@ -158,4 +158,24 @@ backport_genlmsg_multicast_allns(struct genl_family *family,
 #define GENL_UNS_ADMIN_PERM	GENL_ADMIN_PERM
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
+/**
+ * genl_family_attrbuf - return family's attrbuf
+ * @family: the family
+ *
+ * Return the family's attrbuf, while validating that it's
+ * actually valid to access it.
+ *
+ * You cannot use this function with a family that has parallel_ops
+ * and you can only use it within (pre/post) doit/dumpit callbacks.
+ */
+#define genl_family_attrbuf LINUX_BACKPORT(genl_family_attrbuf)
+static inline struct nlattr **genl_family_attrbuf(struct genl_family *family)
+{
+	WARN_ON(family->parallel_ops);
+
+	return family->attrbuf;
+}
+#endif
+
 #endif /* __BACKPORT_NET_GENETLINK_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] backports: empty define for __ro_after_init
  2016-11-12 20:18 [PATCH 1/3] backports: add backport for nla_memdup() Arend van Spriel
  2016-11-12 20:18 ` [PATCH 2/3] backports: add backport for genl_family_attrbuf() function Arend van Spriel
@ 2016-11-12 20:18 ` Arend van Spriel
  2016-11-12 21:07   ` Johannes Berg
  1 sibling, 1 reply; 6+ messages in thread
From: Arend van Spriel @ 2016-11-12 20:18 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: backports, Arend van Spriel

nl80211 now uses section qualifier __ro_after_init. However, this
is not available in kernels before v4.6. Neither is the section
itself hence adding an empty define in backports.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 backport/backport-include/linux/cache.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 backport/backport-include/linux/cache.h

diff --git a/backport/backport-include/linux/cache.h b/backport/backport-include/linux/cache.h
new file mode 100644
index 0000000..9ea4a96
--- /dev/null
+++ b/backport/backport-include/linux/cache.h
@@ -0,0 +1,11 @@
+#ifndef _BACKPORT_CACHE_H
+#define _BACKPORT_CACHE_H
+
+#include_next <linux/cache.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
+#define __ro_after_init
+#endif
+
+#endif /* _BACKPORT_CACHE_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] backports: empty define for __ro_after_init
  2016-11-12 20:18 ` [PATCH 3/3] backports: empty define for __ro_after_init Arend van Spriel
@ 2016-11-12 21:07   ` Johannes Berg
  2016-11-14 18:59     ` Luis R. Rodriguez
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2016-11-12 21:07 UTC (permalink / raw)
  To: Arend van Spriel, Luis R. Rodriguez; +Cc: backports

On Sat, 2016-11-12 at 20:18 +0000, Arend van Spriel wrote:
> nl80211 now uses section qualifier __ro_after_init. However, this
> is not available in kernels before v4.6. Neither is the section
> itself hence adding an empty define in backports.

> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
> +#define __ro_after_init
> +#endif

Due to how __ro_after_init works, it *has* to be a macro originally, so
you could just ifndef on itself:

#ifndef __ro_after_init
#define __ro_after_init
#endif

and be slightly more compatible in case somebody ever backports it.

Don't think it really matters much, but why not.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] backports: empty define for __ro_after_init
  2016-11-12 21:07   ` Johannes Berg
@ 2016-11-14 18:59     ` Luis R. Rodriguez
  2016-11-14 19:26       ` Arend Van Spriel
  0 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2016-11-14 18:59 UTC (permalink / raw)
  To: Johannes Berg, Kees Cook; +Cc: Arend van Spriel, Luis R. Rodriguez, backports

On Sat, Nov 12, 2016 at 10:07:22PM +0100, Johannes Berg wrote:
> On Sat, 2016-11-12 at 20:18 +0000, Arend van Spriel wrote:
> > nl80211 now uses section qualifier __ro_after_init. However, this
> > is not available in kernels before v4.6. Neither is the section
> > itself hence adding an empty define in backports.
> 
> > +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
> > +#define __ro_after_init
> > +#endif
> 
> Due to how __ro_after_init works, it *has* to be a macro originally, so
> you could just ifndef on itself:
> 
> #ifndef __ro_after_init
> #define __ro_after_init
> #endif
> 
> and be slightly more compatible in case somebody ever backports it.

Agreed.

> Don't think it really matters much, but why not.

Distributions that do wish to backport the __ro_after_init
mechanism will have this defined, so indeed what you suggest
seems appropriate.

When backporting things like these please try to Cc the original
authors as they can easily provide feedback about issues they can think
of if you backport things one way or another. I've Cc'd Kees but
I think this backport is straight forward -- for older kernels we
just cannot backport this for modules running old kernels where we
cannot modify the kernels, making this a no-op for old kernels
is the best we can then.

  Luis
--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] backports: empty define for __ro_after_init
  2016-11-14 18:59     ` Luis R. Rodriguez
@ 2016-11-14 19:26       ` Arend Van Spriel
  0 siblings, 0 replies; 6+ messages in thread
From: Arend Van Spriel @ 2016-11-14 19:26 UTC (permalink / raw)
  To: Luis R. Rodriguez, Johannes Berg, Kees Cook; +Cc: backports

On 14-11-2016 19:59, Luis R. Rodriguez wrote:
> On Sat, Nov 12, 2016 at 10:07:22PM +0100, Johannes Berg wrote:
>> On Sat, 2016-11-12 at 20:18 +0000, Arend van Spriel wrote:
>>> nl80211 now uses section qualifier __ro_after_init. However, this
>>> is not available in kernels before v4.6. Neither is the section
>>> itself hence adding an empty define in backports.
>>
>>> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0))
>>> +#define __ro_after_init
>>> +#endif
>>
>> Due to how __ro_after_init works, it *has* to be a macro originally, so
>> you could just ifndef on itself:
>>
>> #ifndef __ro_after_init
>> #define __ro_after_init
>> #endif
>>
>> and be slightly more compatible in case somebody ever backports it.
> 
> Agreed.

Agree as well hence I posted a V2 yesterday ;-)

Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-14 19:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-12 20:18 [PATCH 1/3] backports: add backport for nla_memdup() Arend van Spriel
2016-11-12 20:18 ` [PATCH 2/3] backports: add backport for genl_family_attrbuf() function Arend van Spriel
2016-11-12 20:18 ` [PATCH 3/3] backports: empty define for __ro_after_init Arend van Spriel
2016-11-12 21:07   ` Johannes Berg
2016-11-14 18:59     ` Luis R. Rodriguez
2016-11-14 19:26       ` Arend Van Spriel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.