From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795996111; b=dmKz/WVJa0uDu5+9zz9HCqx6SyaJNnbOaSA424eSbdhV+zy+QTGNvG1IVYHFIGJtuj5r IGEJbWmQeG2XGCoIkW3rjG9DG3E3Jv2bulrxeopVd3kKUCdSZO7raF2C2vwJVck/u/WgQ E1g+XE4Dn+h5C5FA/4qj1+xssMic2mWu4TXFTxTNS9a+aQ62ucWKYaZb3I1CLb7tRCCk5 Z4SZ1FCCjLJOeIr8Zew3Qd0HkRvcXhgO+tqfLi5/WBQjc+9Qq1gPnOIIy1FhndpX7VA4U ywzXHs0cacY49xb1AWb+5I1aFgxEEpiTqqaHICwarhk5Hj/m2oFNc8cx5Dm8yspn9jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795996111; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=FVoZxNA6VpobTPycmpzsQjeNMPacQa0eutgkhGThbRU=; b=FVHD64dyugRDocZWXzd4XqBXIcwanx7uLjN3K0Hb9sB1ovIT4k8vBdsOiAEcmfNdnAFy YyUa63CcoqOjrV7bw9RL+GS/VzFol0oj2SAMcCQ/0tILS4G0jUlpkGoEhwd+dcAgBvvTT CMkH3OFRr2y/xZItw4FzhN9scbbCx5gZI+/gsm9PWuDfT/EwZKkGSqBnUoUPKCXMK4zLU x6vCJ0yV+8G1VzLz4Zj45DzCwJZtrU4ss3JJaCvkqfartveTvPueoxzy0AODGfnBxy9U2 +SIO/GFFuNXG+Le+1tumugEi4rQ0HErIg/JimDCMP+kNYevkGOy0KtdiDr427MHlnKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pGRtItCY; arc=none smtp.remote-ip=209.85.216.72 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81CF7606A31C for ; Sun, 29 Nov 2026 23:48:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81CF7606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pGRtItCY Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-3b4139b7abcso8295380a91.3 for ; Sun, 29 Nov 2026 15:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795996111; x=1796600911; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FVoZxNA6VpobTPycmpzsQjeNMPacQa0eutgkhGThbRU=; b=pGRtItCYyftkYvV2SVfa94cM2+z7LVP1gS51WxicPC5DGxOsb6lBAl9Go1A0SRCWgi JEdCKaqWLRYFnRnhDnf/7X5wuOtlXm7DeF2EKV1Kys2oQimy89gdJgjnCqL4IOWoCuqr H7AJYFR+WuoVWWG3sR11diyn0I8Ot8k1jvIWYGOuyL7ZSP89pQOkYZ17nB0rCUFot+PB ES/94c30LHr8nA2PHCxFJr6y7k0UaqpqqNTLg+k1mvnJ9AaxUJ2iMaPbV98PXnb8+Xnw TYXWVblIdha6C3ETvzSCarPa4AmP9Jga+0XfUIwabweJzK47fLWrtQ7w6xsqm2AFvkva qRcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795996111; x=1796600911; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FVoZxNA6VpobTPycmpzsQjeNMPacQa0eutgkhGThbRU=; b=TL3N1X/zgw0h/pISE1Ysj8RNkpiRb52IyUX2CqL9r+WiBZHAOovUWsd6zJXd7PwL68 w4Muj/G8zQRW4swOpUlGZI7GELd6bGosJb1ziCf8r+EBfZP5t0u1MtjgjXJyS0fE9VGS aCvTEJPn9lSfprAQk5gqsHcZ/Z3uEyuf2Hlq3Rb/iMLti0A5RsYQDWmxW4O41ZwfbjTi Cf9gy9JvcA7rEy9iyuUHMQl+E4J1WkTEVIC5Gtj0/dRjTlHYM5z9/9YybIaZG+zXmNIC DVqi6kvu7izfg0UIu3OtY9THY8qeyFj92gDOPe9llSHg/czZv+thFeR+DxasqihFU/Iu ekrw== X-Forwarded-Encrypted: i=1; AL+hErGeaRjGwva3HW2mosTFUljeGlYChc/ci14/bAxhFJAFI1YDXcWF2b9DVMgbNbWME8nBG0ydq+7zTsZAy2c=@vger.kernel.org X-Gm-Message-State: APuU4Z8g6e+I/FARDVQDjGlxFLHTcDWo3efPwEfwqRf/yHJhvQAC7L0Y zH4QckAYFlHxaIYTViVWcEfuSP8bIp05ObK6PYc+vyp4mb7nvecvN9N9AC+U4iy4444y1GoVymo 08jLTXQ== X-Received: from pjbem21.prod.google.com ([2002:a17:90b:155:b0:3b1:cd53:86de]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a48:b0:3b3:c675:d923 with SMTP id 98e67ed59e1d1-3b41c908109mr29021434a91.28.1795996110632; Sun, 29 Nov 2026 15:48:30 -0800 (PST) Date: Sun, 29 Nov 2026 23:48:30 +0000 In-Reply-To: <20261124062625.264148-1-jiayuan.chen@linux.dev> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261124062625.264148-1-jiayuan.chen@linux.dev> Message-ID: Subject: Re: [PATCH net] tcp: fix CA module refcount underflow in tcp_v4_syn_recv_sock() From: Kuniyuki Iwashima To: Jiayuan Chen Cc: netdev@vger.kernel.org, Eric Dumazet , Neal Cardwell , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Florian Westphal , Daniel Borkmann , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Tue, 24 Nov 2026 14:26:24 +0800, Jiayuan Chen wrote: > Issue found by sashiko [1]. > > tcp_v4_syn_recv_sock() creates the child with tcp_create_openreq_child(), > which inherits icsk->icsk_ca_ops from the listener without taking a > reference. The reference is only taken later in tcp_ca_openreq_child(). > If inet_csk_route_child_sock() fails in between, we go to put_and_exit > and tcp_done() ends up in tcp_cleanup_congestion_control(), which puts > the reference unconditionally. The one dropped belongs to the listener. > > Seen with a listener using bbr (built as a module) and TCP_DEFER_ACCEPT: > make the route to the client prohibited once the handshake is done, then > let the client send data. > > WARNING: kernel/module/main.c:969 at module_put.part.0+0x97/0x160, CPU#1: swapper/1/0 > Modules linked in: tcp_bbr(OE) > RIP: 0010:module_put.part.0+0x97/0x160 > Call Trace: > > module_put+0x13/0x30 > tcp_cleanup_congestion_control+0xae/0xe0 > tcp_v4_destroy_sock+0x103/0x360 > inet_csk_destroy_sock+0xb7/0x1e0 > tcp_done+0x146/0x1e0 > tcp_v4_syn_recv_sock+0x73a/0x9f0 > tcp_check_req+0x351/0x1130 > tcp_v4_rcv+0xe82/0x22e0 > ip_protocol_deliver_rcu+0x5f/0x340 > ip_local_deliver_finish+0x19f/0x3a0 > ip_local_deliver+0xc9/0xf0 > ip_rcv+0x1b1/0x1c0 > __netif_receive_skb_one_core+0xc4/0xe0 > __netif_receive_skb+0x23/0xb0 > process_backlog+0x27a/0x950 > __napi_poll.constprop.0+0x61/0x2c0 > net_rx_action+0x372/0x800 > handle_softirqs+0x109/0x570 > > > Options considered: > 1. Take the reference in tcp_create_openreq_child(), see the diff below > the "---". It adds a get/put pair on the passive open path. > 2. Point the child at tcp_reno (built in, no owner) on this error path, > so the put becomes a no-op. It works but looks odd. > > Instead, clear icsk_ca_ops on this error path and make > tcp_cleanup_congestion_control() skip a socket without a CA. > > [1] https://sashiko.dev/#/message/20260606095014.2531B1F00893%40smtp.kernel.org > > Fixes: 81164413ad09 ("net: tcp: add per route congestion control") > Signed-off-by: Jiayuan Chen Reviewed-by: Kuniyuki Iwashima