[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20200709.130838.1280141169142103459.davem@davemloft.net>
Date: Thu, 09 Jul 2020 13:08:38 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: cpaasch@...le.com
Cc: netdev@...r.kernel.org, kuba@...nel.org, weiwan@...gle.com,
edumazet@...gle.com
Subject: Re: [PATCH v2 net] tcp: make sure listeners don't initialize
congestion-control state
From: Christoph Paasch <cpaasch@...le.com>
Date: Wed, 08 Jul 2020 16:18:34 -0700
> syzkaller found its way into setsockopt with TCP_CONGESTION "cdg".
> tcp_cdg_init() does a kcalloc to store the gradients. As sk_clone_lock
> just copies all the memory, the allocated pointer will be copied as
> well, if the app called setsockopt(..., TCP_CONGESTION) on the listener.
> If now the socket will be destroyed before the congestion-control
> has properly been initialized (through a call to tcp_init_transfer), we
> will end up freeing memory that does not belong to that particular
> socket, opening the door to a double-free:
...
> Wei Wang fixed a part of these CDG-malloc issues with commit c12014440750
> ("tcp: memset ca_priv data to 0 properly").
>
> This patch here fixes the listener-scenario: We make sure that listeners
> setting the congestion-control through setsockopt won't initialize it
> (thus CDG never allocates on listeners). For those who use AF_UNSPEC to
> reuse a socket, tcp_disconnect() is changed to cleanup afterwards.
>
> (The issue can be reproduced at least down to v4.4.x.)
>
> Cc: Wei Wang <weiwan@...gle.com>
> Cc: Eric Dumazet <edumazet@...gle.com>
> Fixes: 2b0a8c9eee81 ("tcp: add CDG congestion control")
> Signed-off-by: Christoph Paasch <cpaasch@...le.com>
Applied and queued up for -stable, thanks.
Powered by blists - more mailing lists