All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6: addrconf: add missing validate_link_af handler
@ 2015-02-05 13:39 Daniel Borkmann
  2015-02-05 19:11 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Borkmann @ 2015-02-05 13:39 UTC (permalink / raw)
  To: davem; +Cc: netdev, Daniel Borkmann, Jiri Pirko

We still need a validate_link_af() handler with an appropriate nla policy,
similarly as we have in IPv4 case, otherwise size validations are not being
done properly in that case.

Fixes: f53adae4eae5 ("net: ipv6: add tokenized interface identifier support")
Fixes: bc91b0f07ada ("ipv6: addrconf: implement address generation modes")
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 net/ipv6/addrconf.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f7c8bbe..dac9419 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4572,6 +4572,22 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
 	return 0;
 }
 
+static const struct nla_policy inet6_af_policy[IFLA_INET6_MAX + 1] = {
+	[IFLA_INET6_ADDR_GEN_MODE]	= { .type = NLA_U8 },
+	[IFLA_INET6_TOKEN]		= { .len = sizeof(struct in6_addr) },
+};
+
+static int inet6_validate_link_af(const struct net_device *dev,
+				  const struct nlattr *nla)
+{
+	struct nlattr *tb[IFLA_INET6_MAX + 1];
+
+	if (dev && !__in6_dev_get(dev))
+		return -EAFNOSUPPORT;
+
+	return nla_parse_nested(tb, IFLA_INET6_MAX, nla, inet6_af_policy);
+}
+
 static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
 {
 	int err = -EINVAL;
@@ -5393,6 +5409,7 @@ static struct rtnl_af_ops inet6_ops = {
 	.family		  = AF_INET6,
 	.fill_link_af	  = inet6_fill_link_af,
 	.get_link_af_size = inet6_get_link_af_size,
+	.validate_link_af = inet6_validate_link_af,
 	.set_link_af	  = inet6_set_link_af,
 };
 
-- 
1.9.3

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

* Re: [PATCH net] ipv6: addrconf: add missing validate_link_af handler
  2015-02-05 13:39 [PATCH net] ipv6: addrconf: add missing validate_link_af handler Daniel Borkmann
@ 2015-02-05 19:11 ` Jiri Pirko
  2015-02-06 20:52 ` David Miller
  2015-02-08  6:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2015-02-05 19:11 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, netdev

Thu, Feb 05, 2015 at 02:39:11PM CET, daniel@iogearbox.net wrote:
>We still need a validate_link_af() handler with an appropriate nla policy,
>similarly as we have in IPv4 case, otherwise size validations are not being
>done properly in that case.
>
>Fixes: f53adae4eae5 ("net: ipv6: add tokenized interface identifier support")
>Fixes: bc91b0f07ada ("ipv6: addrconf: implement address generation modes")
>Cc: Jiri Pirko <jiri@resnulli.us>
>Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Acked-by: Jiri Pirko <jiri@resnulli.us>

Thanks Daniel.


>---
> net/ipv6/addrconf.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
>diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>index f7c8bbe..dac9419 100644
>--- a/net/ipv6/addrconf.c
>+++ b/net/ipv6/addrconf.c
>@@ -4572,6 +4572,22 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
> 	return 0;
> }
> 
>+static const struct nla_policy inet6_af_policy[IFLA_INET6_MAX + 1] = {
>+	[IFLA_INET6_ADDR_GEN_MODE]	= { .type = NLA_U8 },
>+	[IFLA_INET6_TOKEN]		= { .len = sizeof(struct in6_addr) },
>+};
>+
>+static int inet6_validate_link_af(const struct net_device *dev,
>+				  const struct nlattr *nla)
>+{
>+	struct nlattr *tb[IFLA_INET6_MAX + 1];
>+
>+	if (dev && !__in6_dev_get(dev))
>+		return -EAFNOSUPPORT;
>+
>+	return nla_parse_nested(tb, IFLA_INET6_MAX, nla, inet6_af_policy);
>+}
>+
> static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
> {
> 	int err = -EINVAL;
>@@ -5393,6 +5409,7 @@ static struct rtnl_af_ops inet6_ops = {
> 	.family		  = AF_INET6,
> 	.fill_link_af	  = inet6_fill_link_af,
> 	.get_link_af_size = inet6_get_link_af_size,
>+	.validate_link_af = inet6_validate_link_af,
> 	.set_link_af	  = inet6_set_link_af,
> };
> 
>-- 
>1.9.3
>

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

* Re: [PATCH net] ipv6: addrconf: add missing validate_link_af handler
  2015-02-05 13:39 [PATCH net] ipv6: addrconf: add missing validate_link_af handler Daniel Borkmann
  2015-02-05 19:11 ` Jiri Pirko
@ 2015-02-06 20:52 ` David Miller
  2015-02-08  6:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-06 20:52 UTC (permalink / raw)
  To: daniel; +Cc: netdev, jiri

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu,  5 Feb 2015 14:39:11 +0100

> We still need a validate_link_af() handler with an appropriate nla policy,
> similarly as we have in IPv4 case, otherwise size validations are not being
> done properly in that case.
> 
> Fixes: f53adae4eae5 ("net: ipv6: add tokenized interface identifier support")
> Fixes: bc91b0f07ada ("ipv6: addrconf: implement address generation modes")
> Cc: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Applied and queued up for -stable, thanks.

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

* Re: [PATCH net] ipv6: addrconf: add missing validate_link_af handler
  2015-02-05 13:39 [PATCH net] ipv6: addrconf: add missing validate_link_af handler Daniel Borkmann
  2015-02-05 19:11 ` Jiri Pirko
  2015-02-06 20:52 ` David Miller
@ 2015-02-08  6:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-08  6:13 UTC (permalink / raw)
  To: daniel; +Cc: netdev, jiri

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu,  5 Feb 2015 14:39:11 +0100

> We still need a validate_link_af() handler with an appropriate nla policy,
> similarly as we have in IPv4 case, otherwise size validations are not being
> done properly in that case.
> 
> Fixes: f53adae4eae5 ("net: ipv6: add tokenized interface identifier support")
> Fixes: bc91b0f07ada ("ipv6: addrconf: implement address generation modes")
> Cc: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

A nice, old, bug.

Applied and queued up for -stable, thanks Daniel.

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

end of thread, other threads:[~2015-02-08  6:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-05 13:39 [PATCH net] ipv6: addrconf: add missing validate_link_af handler Daniel Borkmann
2015-02-05 19:11 ` Jiri Pirko
2015-02-06 20:52 ` David Miller
2015-02-08  6:13 ` 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.