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]
Date:   Fri, 3 Mar 2017 09:35:49 -0800
From:   Eric Dumazet <edumazet@...gle.com>
To:     Alexander Potapenko <glider@...gle.com>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>,
        Kostya Serebryany <kcc@...gle.com>,
        Kees Cook <keescook@...omium.org>,
        Paul Moore <paul@...l-moore.com>, sds@...ho.nsa.gov,
        LKML <linux-kernel@...r.kernel.org>,
        netdev <netdev@...r.kernel.org>, selinux@...ho.nsa.gov
Subject: Re: [PATCH] selinux: check for address length in selinux_socket_bind()

On Fri, Mar 3, 2017 at 9:23 AM, Alexander Potapenko <glider@...gle.com> wrote:
> This happens because bind() unconditionally copies |size| bytes of
> |addr| to the kernel, leaving the rest uninitialized. Then
> security_socket_bind() reads the IP address bytes, including the
> uninitialized ones, to determine the port, or e.g. pass them further to
> sel_netnode_find(), which uses them to calculate a hash.
>
> Signed-off-by: Alexander Potapenko <glider@...gle.com>
> ---
>  security/selinux/hooks.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 0a4b4b040e0a..eba54489b11b 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -4351,10 +4351,19 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
>                 u32 sid, node_perm;
>
>                 if (family == PF_INET) {
> +                       if (addrlen != sizeof(struct sockaddr_in)) {

Please take a look at inet_bind()

The correct test would be :

                     if (addrlen < sizeof(struct sockaddr_in))
                                     err = -EINVAL;
...


> +                               err = -EINVAL;
> +                               goto out;
> +                       }
>                         addr4 = (struct sockaddr_in *)address;
>                         snum = ntohs(addr4->sin_port);
>                         addrp = (char *)&addr4->sin_addr.s_addr;
> +
>                 } else {
> +                       if (addrlen != sizeof(struct sockaddr_in6)) {

Look at inet6_bind()

                    if (addrlen < SIN6_LEN_RFC2133)

> +                               err = -EINVAL;
> +                               goto out;
> +                       }
>                         addr6 = (struct sockaddr_in6 *)address;
>                         snum = ntohs(addr6->sin6_port);
>                         addrp = (char *)&addr6->sin6_addr.s6_addr;
> --
> 2.12.0.rc1.440.g5b76565f74-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ