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, 1 Jun 2020 12:02:39 +0800
From:   Hangbin Liu <liuhangbin@...il.com>
To:     network dev <netdev@...r.kernel.org>
Cc:     John Haxby <john.haxby@...cle.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Alexey Kuznetsov <kuznet@....inr.ac.ru>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        Jakub Kicinski <kuba@...nel.org>, stable@...r.kernel.org,
        Frantisek Hrbata <fhrbata@...hat.com>
Subject: Re: [PATCH net] ipv6: fix IPV6_ADDRFORM operation logic

cc Frantisek

On Mon, 1 Jun 2020 at 12:00, Hangbin Liu <liuhangbin@...il.com> wrote:
>
> Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present.
> Previously the checking logic looks like:
> if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
>         do_some_check;
> else if (sk->sk_protocol != IPPROTO_TCP)
>         break;
>
> After commit b6f6118901d1 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP
> was blocked as the logic changed to:
> if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
>         do_some_check;
> else if (sk->sk_protocol == IPPROTO_TCP)
>         do_some_check;
>         break;
> else
>         break;
>
> Then after commit 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation")
> UDP/UDPLITE were blocked as the logic changed to:
> if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
>         do_some_check;
> if (sk->sk_protocol == IPPROTO_TCP)
>         do_some_check;
>
> if (sk->sk_protocol != IPPROTO_TCP)
>         break;
>
> Fix it by using Eric's code and simply remove the break in TCP check, which
> looks like:
> if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
>         do_some_check;
> else if (sk->sk_protocol == IPPROTO_TCP)
>         do_some_check;
> else
>         break;
>
> Fixes: 82c9ae440857 ("ipv6: fix restrict IPV6_ADDRFORM operation")
> Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
> ---
>  net/ipv6/ipv6_sockglue.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index 18d05403d3b5..5af97b4f5df3 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -183,14 +183,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
>                                         retv = -EBUSY;
>                                         break;
>                                 }
> -                       }
> -                       if (sk->sk_protocol == IPPROTO_TCP &&
> -                           sk->sk_prot != &tcpv6_prot) {
> -                               retv = -EBUSY;
> +                       } else if (sk->sk_protocol == IPPROTO_TCP) {
> +                               if (sk->sk_prot != &tcpv6_prot) {
> +                                       retv = -EBUSY;
> +                                       break;
> +                               }
> +                       } else {
>                                 break;
>                         }
> -                       if (sk->sk_protocol != IPPROTO_TCP)
> -                               break;
> +
>                         if (sk->sk_state != TCP_ESTABLISHED) {
>                                 retv = -ENOTCONN;
>                                 break;
> --
> 2.25.4
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ