Patchwork bridge: Fix possibly wrong MLD queries' ethernet source address

login
register
mail settings
Submitter Linus Lüssing
Date March 22, 2011, 9:40 p.m.
Message ID <1300830032-6727-2-git-send-email-linus.luessing@web.de>
Download mbox | patch
Permalink /patch/87961/
State Accepted
Delegated to: David Miller
Headers show

Comments

Linus Lüssing - March 22, 2011, 9:40 p.m.
The ipv6_dev_get_saddr() is currently called with an uninitialized
destination address. Although in tests it usually seemed to nevertheless
always fetch the right source address, there seems to be a possible race
condition.

Therefore this commit changes this, first setting the destination
address and only after that fetching the source address.

Reported-by: Jan Beulich <JBeulich@novell.com>
Signed-off-by: Linus Lüssing <linus.luessing@web.de>
---
 net/bridge/br_multicast.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
David Miller - March 23, 2011, 2:26 a.m.
From: Linus Lüssing <linus.luessing@web.de>
Date: Tue, 22 Mar 2011 22:40:32 +0100

> The ipv6_dev_get_saddr() is currently called with an uninitialized
> destination address. Although in tests it usually seemed to nevertheless
> always fetch the right source address, there seems to be a possible race
> condition.
> 
> Therefore this commit changes this, first setting the destination
> address and only after that fetching the source address.
> 
> Reported-by: Jan Beulich <JBeulich@novell.com>
> Signed-off-by: Linus Lüssing <linus.luessing@web.de>

Applied, thank you!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 030a002..f61eb2e 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -445,9 +445,9 @@  static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br,
 	ip6h->payload_len = htons(8 + sizeof(*mldq));
 	ip6h->nexthdr = IPPROTO_HOPOPTS;
 	ip6h->hop_limit = 1;
+	ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
 	ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
 			   &ip6h->saddr);
-	ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
 	ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
 
 	hopopt = (u8 *)(ip6h + 1);