From patchwork Thu Jun 2 16:50:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 12868002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4DB3CCA478 for ; Thu, 2 Jun 2022 16:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237301AbiFBQxG (ORCPT ); Thu, 2 Jun 2022 12:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237284AbiFBQxE (ORCPT ); Thu, 2 Jun 2022 12:53:04 -0400 Received: from 66-220-155-178.mail-mxout.facebook.com (66-220-155-178.mail-mxout.facebook.com [66.220.155.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEA627ED80 for ; Thu, 2 Jun 2022 09:53:03 -0700 (PDT) Received: by devbig010.atn6.facebook.com (Postfix, from userid 115148) id AE255D2E57CB; Thu, 2 Jun 2022 09:52:35 -0700 (PDT) From: Joanne Koong To: netdev@vger.kernel.org Cc: edumazet@google.com, kafai@fb.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, Joanne Koong Subject: [PATCH net-next v2 0/2] Update bhash2 when socket's rcv saddr changes Date: Thu, 2 Jun 2022 09:50:59 -0700 Message-Id: <20220602165101.3188482-1-joannelkoong@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org As syzbot noted [1], there is an inconsistency in the bhash2 table in the case where a socket's rcv saddr changes after it is binded. (For more details, please see the commit message of the first patch) This patchset fixes that and adds a test that triggers the case where the sk's rcv saddr changes. The subsequent listen() call should succeed. [1] https://lore.kernel.org/netdev/0000000000003f33bc05dfaf44fe@google.com/ --- v1 -> v2: v1: https://lore.kernel.org/netdev/20220601201434.1710931-1-joannekoong@fb.com/ * Mark __inet_bhash2_update_saddr as static Joanne Koong (2): net: Update bhash2 when socket's rcv saddr changes selftests/net: Add sk_bind_sendto_listen test include/net/inet_hashtables.h | 6 +- include/net/ipv6.h | 2 +- net/dccp/ipv4.c | 10 ++- net/dccp/ipv6.c | 4 +- net/ipv4/af_inet.c | 7 +- net/ipv4/inet_hashtables.c | 70 ++++++++++++++-- net/ipv4/tcp_ipv4.c | 8 +- net/ipv6/inet6_hashtables.c | 4 +- net/ipv6/tcp_ipv6.c | 4 +- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 1 + .../selftests/net/sk_bind_sendto_listen.c | 82 +++++++++++++++++++ 12 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 tools/testing/selftests/net/sk_bind_sendto_listen.c