* [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 8:53 Thomas Graf
2016-10-26 8:56 ` Johannes Berg
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Thomas Graf @ 2016-10-26 8:53 UTC (permalink / raw)
To: davem; +Cc: johannes, daniel, netdev, linux-wireless
Wrap several common instances of:
kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
include/net/netlink.h | 10 ++++++++++
net/sched/act_bpf.c | 4 +---
net/sched/cls_bpf.c | 4 +---
net/wireless/nl80211.c | 3 +--
4 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 254a0fc..a34f53a 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1191,6 +1191,16 @@ static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla)
}
/**
+ * nla_memdup - duplicate attribute memory (kmemdup)
+ * @src: netlink attribute to duplicate from
+ * @gfp: GFP mask
+ */
+static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp)
+{
+ return kmemdup(nla_data(src), nla_len(src), gfp);
+}
+
+/**
* nla_nest_start - Start a new level of nested attributes
* @skb: socket buffer to add attributes to
* @attrtype: attribute type of container
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index 1d39600..9ff06cf 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -226,9 +226,7 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
return PTR_ERR(fp);
if (tb[TCA_ACT_BPF_NAME]) {
- name = kmemdup(nla_data(tb[TCA_ACT_BPF_NAME]),
- nla_len(tb[TCA_ACT_BPF_NAME]),
- GFP_KERNEL);
+ name = nla_memdup(tb[TCA_ACT_BPF_NAME], GFP_KERNEL);
if (!name) {
bpf_prog_put(fp);
return -ENOMEM;
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index bb1d5a4..52dc85a 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -369,9 +369,7 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
return PTR_ERR(fp);
if (tb[TCA_BPF_NAME]) {
- name = kmemdup(nla_data(tb[TCA_BPF_NAME]),
- nla_len(tb[TCA_BPF_NAME]),
- GFP_KERNEL);
+ name = nla_memdup(tb[TCA_BPF_NAME], GFP_KERNEL);
if (!name) {
bpf_prog_put(fp);
return -ENOMEM;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c510810..7bfe1e0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10638,8 +10638,7 @@ static int handle_nan_filter(struct nlattr *attr_filter,
i = 0;
nla_for_each_nested(attr, attr_filter, rem) {
- filter[i].filter = kmemdup(nla_data(attr), nla_len(attr),
- GFP_KERNEL);
+ filter[i].filter = nla_memdup(attr, GFP_KERNEL);
filter[i].len = nla_len(attr);
i++;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 8:56 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 8:56 UTC (permalink / raw)
To: Thomas Graf, davem; +Cc: daniel, netdev, linux-wireless
On Wed, 2016-10-26 at 10:53 +0200, Thomas Graf wrote:
> Wrap several common instances of:
> kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
Makes sense
Acked-by: Johannes Berg <johannes@sipsolutions.net>
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 8:56 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 8:56 UTC (permalink / raw)
To: Thomas Graf, davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: daniel-FeC+5ew28dpmcu3hnIyYJQ, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
On Wed, 2016-10-26 at 10:53 +0200, Thomas Graf wrote:
> Wrap several common instances of:
> kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
Makes sense
Acked-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
2016-10-26 8:53 [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr Thomas Graf
2016-10-26 8:56 ` Johannes Berg
@ 2016-10-26 8:57 ` Daniel Borkmann
2016-10-26 8:59 ` Johannes Berg
2016-10-29 18:57 ` David Miller
3 siblings, 0 replies; 11+ messages in thread
From: Daniel Borkmann @ 2016-10-26 8:57 UTC (permalink / raw)
To: Thomas Graf, davem; +Cc: johannes, netdev, linux-wireless
On 10/26/2016 10:53 AM, Thomas Graf wrote:
> Wrap several common instances of:
> kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Thanks!
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 8:59 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 8:59 UTC (permalink / raw)
To: Thomas Graf, davem; +Cc: daniel, netdev, linux-wireless
> /**
> + * nla_memdup - duplicate attribute memory (kmemdup)
> + * @src: netlink attribute to duplicate from
> + * @gfp: GFP mask
Actually, is there any point in passing a GFP mask? None of the current
users need it, and it seems fairly unlikely to be needed since this is
typically used on the netlink input path, where you surely shouldn't
need GFP_ATOMIC or so?
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 8:59 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 8:59 UTC (permalink / raw)
To: Thomas Graf, davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: daniel-FeC+5ew28dpmcu3hnIyYJQ, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
> /**
> + * nla_memdup - duplicate attribute memory (kmemdup)
> + * @src: netlink attribute to duplicate from
> + * @gfp: GFP mask
Actually, is there any point in passing a GFP mask? None of the current
users need it, and it seems fairly unlikely to be needed since this is
typically used on the netlink input path, where you surely shouldn't
need GFP_ATOMIC or so?
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
2016-10-26 8:59 ` Johannes Berg
(?)
@ 2016-10-26 9:52 ` Thomas Graf
2016-10-26 10:18 ` Johannes Berg
-1 siblings, 1 reply; 11+ messages in thread
From: Thomas Graf @ 2016-10-26 9:52 UTC (permalink / raw)
To: Johannes Berg; +Cc: davem, daniel, netdev, linux-wireless
On 10/26/16 at 10:59am, Johannes Berg wrote:
>
> > /**
> > + * nla_memdup - duplicate attribute memory (kmemdup)
> > + * @src: netlink attribute to duplicate from
> > + * @gfp: GFP mask
>
> Actually, is there any point in passing a GFP mask? None of the current
> users need it, and it seems fairly unlikely to be needed since this is
> typically used on the netlink input path, where you surely shouldn't
> need GFP_ATOMIC or so?
I'm fine either way. I didn't want to make assumptions which need
later changes. It's not hurting either and the function prototype
is very small.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 10:18 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 10:18 UTC (permalink / raw)
To: Thomas Graf; +Cc: davem, daniel, netdev, linux-wireless
On Wed, 2016-10-26 at 11:52 +0200, Thomas Graf wrote:
> On 10/26/16 at 10:59am, Johannes Berg wrote:
> >
> >
> > >
> > > /**
> > > + * nla_memdup - duplicate attribute memory (kmemdup)
> > > + * @src: netlink attribute to duplicate from
> > > + * @gfp: GFP mask
> >
> > Actually, is there any point in passing a GFP mask? None of the
> > current
> > users need it, and it seems fairly unlikely to be needed since this
> > is
> > typically used on the netlink input path, where you surely
> > shouldn't
> > need GFP_ATOMIC or so?
>
> I'm fine either way. I didn't want to make assumptions which need
> later changes. It's not hurting either and the function prototype
> is very small.
Yeah, I don't really care much - just wondered.
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-26 10:18 ` Johannes Berg
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2016-10-26 10:18 UTC (permalink / raw)
To: Thomas Graf
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, daniel-FeC+5ew28dpmcu3hnIyYJQ,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
On Wed, 2016-10-26 at 11:52 +0200, Thomas Graf wrote:
> On 10/26/16 at 10:59am, Johannes Berg wrote:
> >
> >
> > >
> > > /**
> > > + * nla_memdup - duplicate attribute memory (kmemdup)
> > > + * @src: netlink attribute to duplicate from
> > > + * @gfp: GFP mask
> >
> > Actually, is there any point in passing a GFP mask? None of the
> > current
> > users need it, and it seems fairly unlikely to be needed since this
> > is
> > typically used on the netlink input path, where you surely
> > shouldn't
> > need GFP_ATOMIC or so?
>
> I'm fine either way. I didn't want to make assumptions which need
> later changes. It's not hurting either and the function prototype
> is very small.
Yeah, I don't really care much - just wondered.
johannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-29 18:57 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2016-10-29 18:57 UTC (permalink / raw)
To: tgraf; +Cc: johannes, daniel, netdev, linux-wireless
From: Thomas Graf <tgraf@suug.ch>
Date: Wed, 26 Oct 2016 10:53:16 +0200
> Wrap several common instances of:
> kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Applied.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr
@ 2016-10-29 18:57 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2016-10-29 18:57 UTC (permalink / raw)
To: tgraf-G/eBtMaohhA
Cc: johannes-cdvu00un1VgdHxzADdlk8Q, daniel-FeC+5ew28dpmcu3hnIyYJQ,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
From: Thomas Graf <tgraf-G/eBtMaohhA@public.gmane.org>
Date: Wed, 26 Oct 2016 10:53:16 +0200
> Wrap several common instances of:
> kmemdup(nla_data(attr), nla_len(attr), GFP_KERNEL);
>
> Signed-off-by: Thomas Graf <tgraf-G/eBtMaohhA@public.gmane.org>
Applied.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-10-29 18:57 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26 8:53 [PATCH net-next] netlink: Add nla_memdup() to wrap kmemdup() use on nlattr Thomas Graf
2016-10-26 8:56 ` Johannes Berg
2016-10-26 8:56 ` Johannes Berg
2016-10-26 8:57 ` Daniel Borkmann
2016-10-26 8:59 ` Johannes Berg
2016-10-26 8:59 ` Johannes Berg
2016-10-26 9:52 ` Thomas Graf
2016-10-26 10:18 ` Johannes Berg
2016-10-26 10:18 ` Johannes Berg
2016-10-29 18:57 ` David Miller
2016-10-29 18:57 ` David Miller
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.