netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net] ipv6: Fix MLD Query message check
@ 2014-06-27  1:57 Hangbin Liu
  2014-06-27  2:11 ` YOSHIFUJI Hideaki/吉藤英明
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hangbin Liu @ 2014-06-27  1:57 UTC (permalink / raw)
  To: David Miller; +Cc: network dev, Hangbin Liu

Based on RFC3810 6.2, we also need to check the hop limit and router alert
option besides source address.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/mcast.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 08b367c..617f095 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1301,8 +1301,17 @@ int igmp6_event_query(struct sk_buff *skb)
 	len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr);
 	len -= skb_network_header_len(skb);
 
-	/* Drop queries with not link local source */
-	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
+	/* RFC3810 6.2
+	 * Upon reception of an MLD message that contains a Query, the node
+	 * checks if the source address of the message is a valid link-local
+	 * address, if the Hop Limit is set to 1, and if the Router Alert
+	 * option is present in the Hop-By-Hop Options header of the IPv6
+	 * packet.  If any of these checks fails, the packet is dropped.
+	 */
+	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL) ||
+	    ipv6_hdr(skb)->hop_limit != 1 ||
+	    !(IP6CB(skb)->flags & IP6SKB_ROUTERALERT) ||
+	    IP6CB(skb)->ra != htons(IPV6_OPT_ROUTERALERT_MLD))
 		return -EINVAL;
 
 	idev = __in6_dev_get(skb->dev);
-- 
1.8.1.4

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

* Re: [PATCH v3 net] ipv6: Fix MLD Query message check
  2014-06-27  1:57 [PATCH v3 net] ipv6: Fix MLD Query message check Hangbin Liu
@ 2014-06-27  2:11 ` YOSHIFUJI Hideaki/吉藤英明
  2014-06-27  7:05 ` Hannes Frederic Sowa
  2014-06-27  7:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: YOSHIFUJI Hideaki/吉藤英明 @ 2014-06-27  2:11 UTC (permalink / raw)
  To: Hangbin Liu, David Miller
  Cc: hideaki.yoshifuji, network dev, YOSHIFUJI Hideaki

Hangbin Liu wrote:
> Based on RFC3810 6.2, we also need to check the hop limit and router alert
> option besides source address.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

> ---
>   net/ipv6/mcast.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index 08b367c..617f095 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -1301,8 +1301,17 @@ int igmp6_event_query(struct sk_buff *skb)
>   	len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr);
>   	len -= skb_network_header_len(skb);
>   
> -	/* Drop queries with not link local source */
> -	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
> +	/* RFC3810 6.2
> +	 * Upon reception of an MLD message that contains a Query, the node
> +	 * checks if the source address of the message is a valid link-local
> +	 * address, if the Hop Limit is set to 1, and if the Router Alert
> +	 * option is present in the Hop-By-Hop Options header of the IPv6
> +	 * packet.  If any of these checks fails, the packet is dropped.
> +	 */
> +	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL) ||
> +	    ipv6_hdr(skb)->hop_limit != 1 ||
> +	    !(IP6CB(skb)->flags & IP6SKB_ROUTERALERT) ||
> +	    IP6CB(skb)->ra != htons(IPV6_OPT_ROUTERALERT_MLD))
>   		return -EINVAL;
>   
>   	idev = __in6_dev_get(skb->dev);
> 

--yoshfuji

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

* Re: [PATCH v3 net] ipv6: Fix MLD Query message check
  2014-06-27  1:57 [PATCH v3 net] ipv6: Fix MLD Query message check Hangbin Liu
  2014-06-27  2:11 ` YOSHIFUJI Hideaki/吉藤英明
@ 2014-06-27  7:05 ` Hannes Frederic Sowa
  2014-06-27  7:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Hannes Frederic Sowa @ 2014-06-27  7:05 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: David Miller, network dev

On Fr, 2014-06-27 at 09:57 +0800, Hangbin Liu wrote:
> Based on RFC3810 6.2, we also need to check the hop limit and router alert
> option besides source address.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Yep, looks good

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Thanks!

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

* Re: [PATCH v3 net] ipv6: Fix MLD Query message check
  2014-06-27  1:57 [PATCH v3 net] ipv6: Fix MLD Query message check Hangbin Liu
  2014-06-27  2:11 ` YOSHIFUJI Hideaki/吉藤英明
  2014-06-27  7:05 ` Hannes Frederic Sowa
@ 2014-06-27  7:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-06-27  7:22 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Fri, 27 Jun 2014 09:57:53 +0800

> Based on RFC3810 6.2, we also need to check the hop limit and router alert
> option besides source address.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2014-06-27  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-27  1:57 [PATCH v3 net] ipv6: Fix MLD Query message check Hangbin Liu
2014-06-27  2:11 ` YOSHIFUJI Hideaki/吉藤英明
2014-06-27  7:05 ` Hannes Frederic Sowa
2014-06-27  7:22 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).