Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4579665rwb; Tue, 17 Jan 2023 02:45:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXs4oLC4Db++iuxHZc/01s5RyxC7msbWxU3hj8cdBGXMVcPCN8DVmRZl35vPkenZBQA6RO1U X-Received: by 2002:a17:90a:fc91:b0:226:a617:44c1 with SMTP id ci17-20020a17090afc9100b00226a61744c1mr2556074pjb.13.1673952337277; Tue, 17 Jan 2023 02:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673952337; cv=none; d=google.com; s=arc-20160816; b=jCyJA7A+yLrfKmz+q/c6P6fR8qm7LmT3cEMS0ErFtomQvsHsUb/pxLTEho+/6E2tMh J0cPZhPePrlZQ7D2Sjqv6jOL55n2UV88uP+RBKVXjOHSeiqMbn0xAk/GMuzQ36zFTM16 2RtoWzLQ+Cv5LQ7edMFyBO2duohQEAK0kwDf8PohIMcWlvm7ZceQo5qgybMwQ/Vw5PcR PfqR6zbYNhW82oHnXtmg8EPlQHQSsWf4YIsgOGtmbqfUqgQHvPYnXYyVv2EWPQPufZAA qU+Bk11/dOYeqr69VM2OlNs8MAfLFpCXCJixvsKnfZe8/5FwazbBCn/8JbaO0RbVr94f M2NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=QEdYja+spAQRgI3ocatVF5aB4j8EGJYrwOlz+aS8qnc=; b=H3hQMGiJT2AQdbJQCGXqRtPnyF0QgrC602x2XUcPI8sZiiMnsxf2OkxdVCaET+QqZ4 EQwM/SCywKTqe6bNkR4xBLe2op001gYH91FfsGs3Qpzukzmzr1NJaX1c93ZMFA9RHHTc 9hz5MNSAUuHTWhPVZve4jlUngCudJpeMADJ1hQ8eZ7DpGXHNE2FaEtjbWJsoBRnrqVPS zj/wymet+lImz3pzCfTB445fDfqRkKVXW6EgeO7vLpjlwWh8UR2dsWv3WHilYF0FiHMZ NJEl5lW+RAK11rJqAFyIUXSQ67bLQjL9ye8r0sezqNQ81RgLE4VuqCR5HUaFEwBlNj2D bZAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SmVr9iMA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a63d151000000b004785d1e2b7bsi31284528pgj.514.2023.01.17.02.45.30; Tue, 17 Jan 2023 02:45:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SmVr9iMA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236592AbjAQKWk (ORCPT + 51 others); Tue, 17 Jan 2023 05:22:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236569AbjAQKWd (ORCPT ); Tue, 17 Jan 2023 05:22:33 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0144326584 for ; Tue, 17 Jan 2023 02:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673950905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEdYja+spAQRgI3ocatVF5aB4j8EGJYrwOlz+aS8qnc=; b=SmVr9iMAUwDVXxgrgv5anTXm0OTJGWq7gT3t+95gEZD7NzTfbCni5EeruPQkc6UtNlUT7U oUeZUMx+lgwnEqPZNwn+lrZB7mAuo4Ud90ylNX5+LU7IfNOOTGS4qFfyaIIuNI1bO4YfRT AReHh+JpKzfq7NYchXoP+JGQzbnLY3k= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-20-edahQMHIOGyxMMegnvgs-Q-1; Tue, 17 Jan 2023 05:21:43 -0500 X-MC-Unique: edahQMHIOGyxMMegnvgs-Q-1 Received: by mail-qk1-f198.google.com with SMTP id h13-20020a05620a244d00b006fb713618b8so22478674qkn.0 for ; Tue, 17 Jan 2023 02:21:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QEdYja+spAQRgI3ocatVF5aB4j8EGJYrwOlz+aS8qnc=; b=QUKuZXy96/VDyOzuvrKod7MI1FVuxw3PR69aV/zi0y9R8aQ3m6DHkF0l3CXfwNTs0W eMTjJFiIgIO+G44MK6JVdix5KXphGOECgRWQQYS+vP4BZKqYvjRjb6ImcCnWz6mFIFXE ZZcknPIfvnJLsX0qluNBAntVxiCfag6fxbahF5i1XmSueU/kVFkGSs/J9zLC7uCVLizV 6mYgmJHPtTjp/EyPgRhwUxr34G7NLk+CYkZB/teXs4kCpTG0dmCFZyN4auYCB0Uy+7c2 oePE94ct/T/TjjkMMJ9UAj7cJJzIxOH2ygVeRmm2yFE/JAT3OOdLi1/g4uSKaSO2GEBb PhHw== X-Gm-Message-State: AFqh2kqsaMrhReZnRSssYgMp8otGWl7NPX0Jd+RPKeobFhB2LylhfcBT mdT+1xUVR5DsQYl87iKRz1/YSiuY/O41IMCjOfAwtjxYo/GvbHgJjtYECp04bEzMieXDdcMujPE rR+6+rbfrEynPHoivUjQCiKWT X-Received: by 2002:a05:6214:5cc6:b0:535:2539:f6f5 with SMTP id lk6-20020a0562145cc600b005352539f6f5mr3569720qvb.19.1673950903264; Tue, 17 Jan 2023 02:21:43 -0800 (PST) X-Received: by 2002:a05:6214:5cc6:b0:535:2539:f6f5 with SMTP id lk6-20020a0562145cc600b005352539f6f5mr3569707qvb.19.1673950903011; Tue, 17 Jan 2023 02:21:43 -0800 (PST) Received: from gerbillo.redhat.com (146-241-115-179.dyn.eolo.it. [146.241.115.179]) by smtp.gmail.com with ESMTPSA id t11-20020a05620a034b00b006fa31bf2f3dsm19675388qkm.47.2023.01.17.02.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 02:21:42 -0800 (PST) Message-ID: Subject: Re: [PATCH net-next v3] inet: fix fast path in __inet_hash_connect() From: Paolo Abeni To: Pietro Borrello , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Hideaki YOSHIFUJI , David Ahern Cc: Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel , Kuniyuki Iwashima , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 17 Jan 2023 11:21:39 +0100 In-Reply-To: <20230112-inet_hash_connect_bind_head-v3-1-b591fd212b93@diag.uniroma1.it> References: <20230112-inet_hash_connect_bind_head-v3-1-b591fd212b93@diag.uniroma1.it> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2023-01-14 at 13:11 +0000, Pietro Borrello wrote: > __inet_hash_connect() has a fast path taken if sk_head(&tb->owners) is > equal to the sk parameter. > sk_head() returns the hlist_entry() with respect to the sk_node field. > However entries in the tb->owners list are inserted with respect to the > sk_bind_node field with sk_add_bind_node(). > Thus the check would never pass and the fast path never execute. >=20 > This fast path has never been executed or tested as this bug seems > to be present since commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), thus > remove it to reduce code complexity. >=20 > Signed-off-by: Pietro Borrello > --- > Changes in v3: > - remove the fast path to reduce code complexity > - Link to v2: https://lore.kernel.org/r/20230112-inet_hash_connect_bind_h= ead-v2-1-5ec926ddd985@diag.uniroma1.it >=20 > Changes in v2: > - nit: s/list_entry/hlist_entry/ > - Link to v1: https://lore.kernel.org/r/20230112-inet_hash_connect_bind_h= ead-v1-1-7e3c770157c8@diag.uniroma1.it > --- > net/ipv4/inet_hashtables.c | 12 +----------- > 1 file changed, 1 insertion(+), 11 deletions(-) >=20 > diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c > index d039b4e732a3..b832e7a545d4 100644 > --- a/net/ipv4/inet_hashtables.c > +++ b/net/ipv4/inet_hashtables.c > @@ -994,17 +994,7 @@ int __inet_hash_connect(struct inet_timewait_death_r= ow *death_row, > u32 index; > =20 > if (port) { > - head =3D &hinfo->bhash[inet_bhashfn(net, port, > - hinfo->bhash_size)]; > - tb =3D inet_csk(sk)->icsk_bind_hash; > - spin_lock_bh(&head->lock); > - if (sk_head(&tb->owners) =3D=3D sk && !sk->sk_bind_node.next) { > - inet_ehash_nolisten(sk, NULL, NULL); > - spin_unlock_bh(&head->lock); > - return 0; > - } > - spin_unlock(&head->lock); > - /* No definite answer... Walk to established hash table */ > + local_bh_disable(); > ret =3D check_established(death_row, sk, port, NULL); > local_bh_enable(); > return ret; LGTM, thanks! Eric, do you have any additional comment? Cheers, Paolo