Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753679AbdLMSwd (ORCPT ); Wed, 13 Dec 2017 13:52:33 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:42702 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752932AbdLMSwc (ORCPT ); Wed, 13 Dec 2017 13:52:32 -0500 Date: Wed, 13 Dec 2017 13:52:30 -0500 (EST) Message-Id: <20171213.135230.1372200104380913073.davem@davemloft.net> To: cernekee@chromium.org Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, andrew@lunn.ch, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: igmp: Use correct source address on IGMPv3 reports From: David Miller In-Reply-To: <20171211191345.104136-1-cernekee@chromium.org> References: <20171211191345.104136-1-cernekee@chromium.org> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 13 Dec 2017 10:52:31 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1842 Lines: 56 From: Kevin Cernekee Date: Mon, 11 Dec 2017 11:13:45 -0800 > Closing a multicast socket after the final IPv4 address is deleted > from an interface can generate a membership report that uses the > source IP from a different interface. The following test script, run > from an isolated netns, reproduces the issue: > > #!/bin/bash > > ip link add dummy0 type dummy > ip link add dummy1 type dummy > ip link set dummy0 up > ip link set dummy1 up > ip addr add 10.1.1.1/24 dev dummy0 > ip addr add 192.168.99.99/24 dev dummy1 > > tcpdump -U -i dummy0 & > socat EXEC:"sleep 2" \ > UDP4-DATAGRAM:239.101.1.68:8889,ip-add-membership=239.0.1.68:10.1.1.1 & > > sleep 1 > ip addr del 10.1.1.1/24 dev dummy0 > sleep 5 > kill %tcpdump > > RFC 3376 specifies that the report must be sent with a valid IP source > address from the destination subnet, or from address 0.0.0.0. Add an > extra check to make sure this is the case. > > Signed-off-by: Kevin Cernekee ... > + return htonl(INADDR_ANY); > +} > + > static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu) > { > struct sk_buff *skb; > @@ -368,7 +386,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu) > pip->frag_off = htons(IP_DF); > pip->ttl = 1; > pip->daddr = fl4.daddr; > - pip->saddr = fl4.saddr; > + pip->saddr = igmpv3_get_srcaddr(dev, &fl4); > pip->protocol = IPPROTO_IGMP; > pip->tot_len = 0; /* filled in later */ > ip_select_ident(net, skb, NULL); Ok, and I checked that MC source address validation on the receiver will pass because: if (ipv4_is_zeronet(saddr)) { if (!ipv4_is_local_multicast(daddr)) return -EINVAL; that check in ip_mc_validate_source() won't trigger.