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:   Sun, 21 Mar 2021 11:06:25 -0600
From:   David Ahern <dsahern@...il.com>
To:     Riccardo Paolo Bestetti <pbl@...tov.io>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        David Ahern <dsahern@...nel.org>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ipv4/raw: support binding to nonlocal addresses

On 3/20/21 6:20 PM, Riccardo Paolo Bestetti wrote:
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index 50a73178d63a..734c0332b54b 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -717,6 +717,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
>  {
>  	struct inet_sock *inet = inet_sk(sk);
>  	struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
> +	struct net *net = sock_net(sk);
>  	u32 tb_id = RT_TABLE_LOCAL;
>  	int ret = -EINVAL;
>  	int chk_addr_ret;
> @@ -732,7 +733,8 @@ static int raw_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
>  					    tb_id);
>  
>  	ret = -EADDRNOTAVAIL;
> -	if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
> +	if (!inet_can_nonlocal_bind(net, inet) &&
> +	    addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
>  	    chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
>  		goto out;
>  	inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
> 


Please add test cases to ipv4_addr_bind and ipv6_addr_bind in
tools/testing/selftests/net/fcnal-test.sh. The latter will verify if
IPv6 works the same or needs a change.

Also, this check duplicates the ones in __inet_bind and __inet6_bind; it
would be good to use an inline helper to reduce the duplication.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ