Skip to content

dccp/tcp: Fix bhash2 issues related to WARN_ON() in inet_csk_get_port().

Kuniyuki Iwashima dccp netdev 4 versions – Applied

Status from this message: This series was applied to netdev/net.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 5 repliesApplied 4/4
  2. v34 patches 7 repliesSuperseded
  3. v24 patches 13 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch6 repliesSuperseded

Changes in v4 from the cover letter

* Patch 3
* Narrow down the bhash lock section (Joanne Koong)

Patches in v4 All 4 applied

#Subject and filesSizeRepliesApplied
1/4dccp/tcp: Reset saddr on failure after inet6?_hash_connect().net/dccp/ipv4.c net/dccp/ipv6.c net/ipv4/tcp_ipv4.c +1 more+8 -00 repliesApplied
2/4dccp/tcp: Remove NULL check for prev_saddr in inet_bhash2_update_saddr().net/ipv4/inet_hashtables.c+4 -70 repliesApplied
3/4dccp/tcp: Update saddr under bhash's lock.include/net/inet_hashtables.h net/dccp/ipv4.c net/dccp/ipv6.c +4 more+56 -861 replyApplied
4/4dccp/tcp: Fixup bhash2 bucket when connect() fails.include/net/inet_hashtables.h net/dccp/ipv4.c net/dccp/ipv6.c +5 more+41 -163 repliesApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJoanne KoongEric Dumazet
SeriesR-b
1/4A-b
2/4A-b
3/4A-b
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 net 0/4] dccp/tcp: Fix bhash2 issues related to WARN_ON() in inet_csk_get_port().

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/[email protected]/
[1]: https://lore.kernel.org/netdev/[email protected]/
[2]: https://lore.kernel.org/netdev/[email protected]/
[3]: https://lore.kernel.org/netdev/[email protected]/T/#m00aafedb29ff0b55d5e67aef0252ef1baaf4b6ee

Changes:
v4:
* Patch 3
* Narrow down the bhash lock section (Joanne Koong)

v3: https://lore.kernel.org/netdev/[email protected]/
* Patch 3
* Update saddr under the bhash's lock
* Correct Fixes tag
* Change #ifdef in inet_update_saddr() along the recent discussion [3]

v2: https://lore.kernel.org/netdev/[email protected]/
* 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: Update saddr under bhash's lock. 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    | 84 ++++++++++++++++++++++++++++++-----
 net/ipv4/tcp.c                |  3 +-
 net/ipv4/tcp_ipv4.c           | 21 +++------
 net/ipv6/tcp_ipv6.c           | 20 ++-------
 9 files changed, 96 insertions(+), 96 deletions(-)
Signature · 1 line
2.30.2