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]
Message-ID: <CAM_iQpVG-L=ZCDnOpDjpyDWuyPFY378JbQ5qhu9_bhzOGc9BuQ@mail.gmail.com>
Date:   Thu, 20 Oct 2016 18:12:45 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Eric Dumazet <eric.dumazet@...il.com>
Cc:     Baozeng Ding <sploving1@...il.com>,
        David Miller <davem@...emloft.net>,
        network dev <netdev@...r.kernel.org>
Subject: Re: [PATCH net] udp: must lock the socket in udp_disconnect()

On Thu, Oct 20, 2016 at 9:39 AM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> From: Eric Dumazet <edumazet@...gle.com>
>
> Baozeng Ding reported KASAN traces showing uses after free in
> udp_lib_get_port() and other related UDP functions.
>
> A CONFIG_DEBUG_PAGEALLOC=y kernel would eventually crash.
>
> I could write a reproducer with two threads doing :
>
> static int sock_fd;
> static void *thr1(void *arg)
> {
>         for (;;) {
>                 connect(sock_fd, (const struct sockaddr *)arg,
>                         sizeof(struct sockaddr_in));
>         }
> }
>
> static void *thr2(void *arg)
> {
>         struct sockaddr_in unspec;
>
>         for (;;) {
>                 memset(&unspec, 0, sizeof(unspec));
>                 connect(sock_fd, (const struct sockaddr *)&unspec,
>                         sizeof(unspec));
>         }
> }
>
> Problem is that udp_disconnect() could run without holding socket lock,
> and this was causing list corruptions.

If this is the cause of the hashlist corruption (I am still unsure about this),
then why only UDP? Don't all of those using ip4_datagram_connect()
as ->connect() and using udp_disconnect() as ->disconnect() need this fix?

For example, after your patch,

        .connect =      ip4_datagram_connect,
-       .disconnect =   udp_disconnect,
+       .disconnect =   __udp_disconnect,

Ping socket still doesn't have sock lock for ->disconnect() but has it for
->connect()? I must miss something...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ