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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 12 May 2022 21:01:08 +0300
From:   Leonard Crestez <cdleonard@...il.com>
To:     Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller" <davem@...emloft.net>
Cc:     David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: BUG: TCP timewait sockets survive across namespace creation in
 net-next

Hello,

It appears that in recent net-next versions it is possible for sockets 
in the timewait state to survive across namespace add/del. Timewait 
sockets are inserted into a global hash and only the sock_net value is 
compared when they are enumerated from interfaces like /proc/net/tcp and 
inet_diag. Old TW sockets are not cleared after namespace delete and 
namespaces are allocated from a slab and thus their pointers get reused 
a lot, when that happens timewait sockets from an old namespace will 
show up in the new one.

This can be reproduced by establishing a TCP connection over a veth pair 
between two namespaces, closing and then recreating those namespaces. 
Old timewait sockets will be visible and it happens quite reliably, 
often on the first iteration. I can try to provide a script for this.

I can't point to specific bugs outside of tests that explicitly 
enumerate timewait sockets but letting sk_net be a dangling pointer 
seems very dangerous. It also violates the idea of network namespaces 
being independent and isolated.

This does not happen in 5.17, I bisected this behavior to commit 
0dad4087a86a ("tcp/dccp: get rid of inet_twsk_purge()")

--
Regards,
Leonard

Powered by blists - more mailing lists