From: Christoph Paasch <cpaa...@apple.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 <wei...@google.com>
> Cc: Eric Dumazet <eduma...@google.com>
> Fixes: 2b0a8c9eee81 ("tcp: add CDG congestion control")
> Signed-off-by: Christoph Paasch <cpaa...@apple.com>

Applied and queued up for -stable, thanks.

Reply via email to