All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net 0/4] dccp/tcp: Fix bhash2 issues related to WARN_ON() in inet_csk_get_port().
@ 2022-11-16 22:28 ` Kuniyuki Iwashima
  0 siblings, 0 replies; 36+ messages in thread
From: Kuniyuki Iwashima @ 2022-11-16 22:28 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Hideaki YOSHIFUJI, David Ahern
  Cc: Arnaldo Carvalho de Melo, Joanne Koong, Martin KaFai Lau,
	Mat Martineau, Ziyang Xuan (William),
	Stephen Hemminger, Pengfei Xu, Kuniyuki Iwashima,
	Kuniyuki Iwashima, netdev, dccp

syzkaller was hitting a WARN_ON() in inet_csk_get_port() in the 4th patch,
which was because we forgot to fix up bhash2 bucket when connect() for a
socket bound to a wildcard address fails in __inet_stream_connect().

There was a similar report [0], but its repro does not fire the WARN_ON() due
to inconsistent error handling.

When connect() for a socket bound to a wildcard address fails, saddr may or
may not be reset depending on where the failure happens.  When we fail in
__inet_stream_connect(), sk->sk_prot->disconnect() resets saddr.  OTOH, in
(dccp|tcp)_v[46]_connect(), if we fail after inet_hash6?_connect(), we
forget to reset saddr.

We fix this inconsistent error handling in the 1st patch, and then we'll
fix the bhash2 WARN_ON() issue.

Note that there is still an issue in that we reset saddr without checking
if there are conflicting sockets in bhash and bhash2, but this should be
another series.

See [1][2] for the previous discussion.

[0]: https://lore.kernel.org/netdev/0000000000003f33bc05dfaf44fe@google.com/
[1]: https://lore.kernel.org/netdev/20221029001249.86337-1-kuniyu@amazon.com/
[2]: https://lore.kernel.org/netdev/20221103172419.20977-1-kuniyu@amazon.com/


Changes:
  v2:
    * Add patch 2-4

  v1: [2]


Kuniyuki Iwashima (4):
  dccp/tcp: Reset saddr on failure after inet6?_hash_connect().
  dccp/tcp: Remove NULL check for prev_saddr in
    inet_bhash2_update_saddr().
  dccp/tcp: Don't update saddr before unlinking sk from the old bucket
  dccp/tcp: Fixup bhash2 bucket when connect() fails.

 include/net/inet_hashtables.h |  3 +-
 net/dccp/ipv4.c               | 23 +++---------
 net/dccp/ipv6.c               | 24 +++---------
 net/dccp/proto.c              |  3 +-
 net/ipv4/af_inet.c            | 11 +-----
 net/ipv4/inet_hashtables.c    | 70 ++++++++++++++++++++++++++++++-----
 net/ipv4/tcp.c                |  3 +-
 net/ipv4/tcp_ipv4.c           | 21 +++--------
 net/ipv6/tcp_ipv6.c           | 20 ++--------
 9 files changed, 85 insertions(+), 93 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2022-11-18 19:58 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 22:28 [PATCH v2 net 0/4] dccp/tcp: Fix bhash2 issues related to WARN_ON() in inet_csk_get_port() Kuniyuki Iwashima
2022-11-16 22:28 ` Kuniyuki Iwashima
2022-11-16 22:28 ` [PATCH v2 net 1/4] dccp/tcp: Reset saddr on failure after inet6?_hash_connect() Kuniyuki Iwashima
2022-11-16 22:28   ` Kuniyuki Iwashima
2022-11-17  0:11   ` Joanne Koong
2022-11-17  0:11     ` Joanne Koong
2022-11-17  0:20     ` Kuniyuki Iwashima
2022-11-17  0:20       ` Kuniyuki Iwashima
2022-11-17  0:43       ` Joanne Koong
2022-11-17  0:43         ` Joanne Koong
2022-11-16 22:28 ` [PATCH v2 net 2/4] dccp/tcp: Remove NULL check for prev_saddr in inet_bhash2_update_saddr() Kuniyuki Iwashima
2022-11-16 22:28   ` Kuniyuki Iwashima
2022-11-17  0:07   ` Joanne Koong
2022-11-17  0:07     ` Joanne Koong
2022-11-16 22:28 ` [PATCH v2 net 3/4] dccp/tcp: Don't update saddr before unlinking sk from the old bucket Kuniyuki Iwashima
2022-11-16 22:28   ` Kuniyuki Iwashima
2022-11-17 21:32   ` Joanne Koong
2022-11-17 21:32     ` Joanne Koong
2022-11-17 23:59   ` Kuniyuki Iwashima
2022-11-18  0:06     ` Kuniyuki Iwashima
2022-11-18  0:55     ` Joanne Koong
2022-11-18  0:55       ` Joanne Koong
2022-11-18  1:08       ` Kuniyuki Iwashima
2022-11-18  1:08         ` Kuniyuki Iwashima
2022-11-18 18:56   ` Joanne Koong
2022-11-18 19:02     ` Joanne Koong
2022-11-18 19:58     ` Kuniyuki Iwashima
2022-11-18 19:58       ` Kuniyuki Iwashima
2022-11-16 22:28 ` [PATCH v2 net 4/4] dccp/tcp: Fixup bhash2 bucket when connect() fails Kuniyuki Iwashima
2022-11-16 22:28   ` Kuniyuki Iwashima
2022-11-17  2:23   ` Pengfei Xu
2022-11-17  2:23     ` Pengfei Xu
2022-11-17  3:20     ` Kuniyuki Iwashima
2022-11-17  3:20       ` Kuniyuki Iwashima
2022-11-17  4:56   ` Pengfei Xu
2022-11-17  5:02     ` Pengfei Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.