lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 01 Jun 2015 23:11:42 +0300
From:	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:	Shawn Bohrer <shawn.bohrer@...il.com>, netdev@...r.kernel.org
CC:	"Yurij M. Plotnikov" <Yurij.Plotnikov@...etlabs.ru>,
	Alexandra.Kossovsky@...etlabs.ru,
	Eric Dumazet <eric.dumazet@...il.com>,
	Oliver Graff <oliver.e.graff@...il.com>, davem@...emloft.net,
	Shawn Bohrer <sbohrer@...advisors.com>
Subject: Re: [PATCH] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux()

Hello.

On 06/01/2015 07:34 PM, Shawn Bohrer wrote:

> From: Shawn Bohrer <sbohrer@...advisors.com>

> 421b3885bf6d56391297844f43fb7154a6396e12 "udp: ipv4: Add udp early
> demux" introduced a regression that allowed sockets bound to INADDR_ANY
> to receive packets from multicast groups that the socket had not joined.
> For example a socket that had joined 224.168.2.9 could also receive
> packets from 225.168.2.9 despite not having joined that group if
> ip_early_demux is enabled.

> Fix this by calling ip_check_mc_rcu() in udp_v4_early_demux() to verify
> that the multicast packet is indeed ours.

> Signed-off-by: Shawn Bohrer <sbohrer@...advisors.com>
> Reported-by: Yurij M. Plotnikov <Yurij.Plotnikov@...etlabs.ru>
> ---
>   net/ipv4/udp.c | 18 +++++++++++++-----
>   1 file changed, 13 insertions(+), 5 deletions(-)

> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index d10b7e0..17d31f5 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
[...]
> @@ -1971,10 +1972,17 @@ void udp_v4_early_demux(struct sk_buff *skb)
>   	uh = udp_hdr(skb);
>
>   	if (skb->pkt_type == PACKET_BROADCAST ||
> -	    skb->pkt_type == PACKET_MULTICAST)
> -		sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
> -						   uh->source, iph->saddr, dif);
> -	else if (skb->pkt_type == PACKET_HOST)
> +	    skb->pkt_type == PACKET_MULTICAST) {
> +		struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
> +
> +		if (in_dev) {
> +			int our = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr,
> +						  iph->protocol);
> +			if (our)
> +				sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
> +								   uh->source, iph->saddr, dif);
> +		}
> +	} else if (skb->pkt_type == PACKET_HOST)
>   		sk = __udp4_lib_demux_lookup(net, uh->dest, iph->daddr,
>   					     uh->source, iph->saddr, dif);
>   	else

    Must add {} around all branches of the *if* statement if you're adding 
them around just one; see Documentation/CodingStyle.

WBR, Sergei

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ