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] [day] [month] [year] [list]
Message-Id: <10F25D11-8FE5-4E29-BC7E-F4C95CBBC84A@scaleway.com>
Date:   Mon, 3 Dec 2018 10:14:00 +0100
From:   Alexis Bauvin <abauvin@...leway.com>
To:     Sabrina Dubroca <sd@...asysnail.net>,
        David Ahern <dsa@...ulusnetworks.com>,
        Roopa Prabhu <roopa@...ulusnetworks.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Cc:     netdev <netdev@...r.kernel.org>, akherbouche@...leway.com,
        Alexis Bauvin <abauvin@...leway.com>
Subject: Re: [PATCH v6 1/4] udp_tunnel: add config option to bind to a device

Le 30 nov. 2018 à 15:31, Sabrina Dubroca <sd@...asysnail.net> a écrit :
> 2018-11-27, 14:05:42 +0100, Alexis Bauvin wrote:
>> diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
>> index 6539ff15e9a3..dc68e15a4f72 100644
>> --- a/net/ipv4/udp_tunnel.c
>> +++ b/net/ipv4/udp_tunnel.c
>> @@ -20,6 +20,16 @@ int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
>> 	if (err < 0)
>> 		goto error;
>> 
>> +	if (cfg->bind_ifindex) {
>> +		struct net_device *dev;
>> +
>> +		dev = __dev_get_by_index(net, cfg->bind_ifindex);
> 
> Quoting from net/core/dev.c:
> 
> *	[...]                                    The device has not
> *	had its reference counter increased so the caller must be careful
> *	about locking. The caller must hold either the RTNL semaphore
> *	or @dev_base_lock.
> */
> 
> which is the case for VXLAN (and GENEVE) during ndo_open, but I don't
> think other UDP tunnels (FOU, L2TP) are holding RTNL when they call
> udp_sock_create(). dev_get_by_index() + dev_put() should be safe.
> 
> Also, I don't think it's a problem with vxlan, but this could handle
> the case where __dev_get_by_index returns NULL.

First, sorry for the (late) response, thanks for the feedback!

That’s a real issue I did not take into account when writing the patch; still
too new to kernel dev.

Fixing and spinning up v7.

>> +		err = kernel_setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
>> +					dev->name, strlen(dev->name) + 1);
>> +		if (err < 0)
>> +			goto error;
>> +	}
>> +
>> 	udp_addr.sin_family = AF_INET;
>> 	udp_addr.sin_addr = cfg->local_ip;
>> 	udp_addr.sin_port = cfg->local_udp_port;
> 
> -- 
> Sabrina

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ