From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C30332ED6 for ; Mon, 24 Aug 2026 08:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787560254; cv=none; b=o42zhC6Oj6LE4RPNYCiRG3Z4GbVVv1tSh1VZQnM/gw9ewUPbcAk20DpGrBWKGUPkpeXuxXURABjL4TL0Bkfz8gmkdobiebuKKKV+TO1NAmP+52MlOwmo8d14x6xLsiCRYD9lCcmaatNyniXe1/S3Dps6KhbaTemGgwAnxYL16tM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787560254; c=relaxed/simple; bh=NtQOIzywrQYZKh4TH1+rGY8JS9R261fEuDoFEh7TB+Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kmvfVumBf8h1a45x64ut38XnlKPRMCirgLU2S+g5HeOkH2ExPbBp/6L9ebTwfyAFC4bjNPlNqwKKSMKCcXaJJgMCLxreu83AO/XnR8qvqGwlu7tsjubsScAFhOo5ryo939QPQ94SiOWHikUOJmMbOF+Pka4xuAiZkMWeWJX7vII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=csepg2Lj; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="csepg2Lj" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-476a130c138so3161107f8f.0 for ; Mon, 24 Aug 2026 01:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787560251; x=1788165051; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=kOkT3X+8KY9WWJ0TJEDnmjUbILoTSgAuXbLKWjGkcEs=; b=csepg2LjDxDlBk/5bqGJQC1GA7vzgMQIqyRMBNGTEr8rMoK0Hlb9ojSP02404jRqpI gZdKGIM52wVIoRMpGETPwuwo7dHRig1Mtl4EZn+2UhNt9r9W5qxd4pzGZiSQO0chxE92 HDKDHo8aGudypZRdQcazRT8UsGCT/2YJAYDQBymI/109BDCAcNPpqnQxcBeett5qMeOE p0UxFTljvL7Rm9vih5lT8msHZkCWhheoZ1wu1fyGd5NxWuNWBHldNkVlsYLpHu7yg0Gq /LrPmsEhhkol6XwaALlre4JGIjE1LTKcIbswe8pXDrheJQIctO54h1ppI1HbtLNJ+zjO DznA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787560251; x=1788165051; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kOkT3X+8KY9WWJ0TJEDnmjUbILoTSgAuXbLKWjGkcEs=; b=VT+ZczcXbWy3oxOyxXliUsNP9ymglj7pr6RE5FrZjs6IMSp9/e6cF+qKKEfxLxcT+v 9oriXBs69TcI73072yk4s22/JXbavTzoQSYBiiHkaDks1v9MID8eNGa2qurqm9msx42u kFks664EKdrYQGp67vuaXEQ2jUgZ2rwZYT2fRWR7wwBGFlAoGySS/4++twvryTFRRWL1 wpQpZDTvepOxMNp58jYM0mFMktFdQOPVuBIYDT/RU+dG6Qh9D/c9ex9XAoBgN7YDDfkN iEdC6/JdULpue7V3p69u7LV8gQLAjX/6a5Yln0W8KiSu3PFl3iEuu0xG+oedQagKAS6F Ev5w== X-Forwarded-Encrypted: i=1; AHgh+RoBqTAfd1DBP0J/vAc2VMSFRnSM56Gr4rLr3MNiBMZSeDIp0kpirAnoBQeK7zdTt1CFZGHZYxeGfEpKEac=@vger.kernel.org X-Gm-Message-State: AFuF++k7n2aHWqA71QAg/8Q+n9AahBM5NssBWE1Zb2DFvy2xh67o01Xm p6wU+oIdt1W3TADvC4rb2ts+/StTj8hU4S0CycM3OxXgenDU8xbJagaM X-Gm-Gg: AR+sD10XOBr6Djo6LaD7Wue54+hiUaPI0XHbv0riBSyQe1XidDxOYcQJwj3i/8SlXOn BRAFm+uaOlbSBaRgl43fGsCIBlZbkuwe0fVVdKIehsPIg5WxXu8AMa521bqBU24J+y7oC15PItm jnUX4ZXlwNJfO1TRJA0SRfZ3EQCCYm2hstI3wVkMUt/ij4leoR7ndABSP6c7xqPzCb9rtmDPPmz LdJfeQCw5ee4ge7PKqPUh2gR6wZw5t1AsGha2dPbQ1osaV9ry86jN6dZbT2Rw3h0LPoisvg6wxN g1Cls4ND0ldmX81IqsPcNxea3q3Fb6E+ZyIPhcWbPwZMApm2vXCW8dW2rYr7dokPqCWPgrGHNdq SXeRcNp/r4cMjC3744KJiDnhfM/nQ6S3PhNIEcEZsqc+vdm4n4aVXv0D3mz9bNC2GuyGhKTCscM lCzbnDOzQG3PBAlbhs2FwVAn5a+z1iCRg/JRhCVPmSFapUR8JFaZTD+nw7WEgsbxVbVPB4ujmQd V1Lv7VEfjD9e0ZpmGpMnCSEip5y9hDI7LhA X-Received: by 2002:a05:6000:1884:b0:47f:9557:8d77 with SMTP id ffacd0b85a97d-482c0b97893mr30928360f8f.10.1787560249259; Mon, 24 Aug 2026 01:30:49 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482c9b855cdsm7224725f8f.16.2026.08.24.01.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 01:30:46 -0700 (PDT) Date: Mon, 24 Aug 2026 09:30:44 +0100 From: David Laight To: Hyunwoo Kim Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ncardwell@google.com, dsahern@kernel.org, idosch@nvidia.com, kuniyu@google.com, horms@kernel.org, willemb@google.com, andrew+netdev@lunn.ch, kees@kernel.org, jiayuan.chen@linux.dev, kerneljasonxing@gmail.com, ij@kernel.org, martin.lau@kernel.org, shakeel.butt@linux.dev, matttbe@kernel.org, martineau@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net v2 0/8] net: fixes for requests completing on a socket that no longer listens Message-ID: <20260824093044.595dd0fc@pumpkin> In-Reply-To: <20260824033331.1084971-1-imv4bel@gmail.com> References: <20260824033331.1084971-1-imv4bel@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 24 Aug 2026 12:32:44 +0900 Hyunwoo Kim wrote: > connect(AF_UNSPEC) and listen() move a socket back and forth between > listener and active session. IPV6_ADDRFORM on top of that turns an > AF_INET6 socket into an AF_INET one. Is it even valid to call connect() after listen()? David > > Two things follow. One is that what the socket had before the change is > left behind: requests still in the ehash, and parent fields a child > inherits. The other is that the socket is used while it is changing. > tcp_check_req() does not hold the listener lock, and tcp_v{4,6}_rcv() > reads sk_state twice without it on the listener path. > > Patch 2 is neither. After a reuseport migration the listener that counted > a request and the listener the count is decremented on are not the same. > It goes with patch 3 because patch 3 needs it. Nothing ever resets that > count, so patch 3 on its own has a check that can be bypassed. > > Patches 2, 6, 7 and 8 are new in v2. > > Hyunwoo Kim (8): > tcp: fix use-after-free of the listener's ipv6_pinfo after > IPV6_ADDRFORM > tcp: fix imbalanced icsk_accept_queue count in tcp_check_req() > ipv6: fix request socket use-after-free after IPV6_ADDRFORM > net: fix out-of-bounds write in sk_clone() racing with IPV6_ADDRFORM > tcp: do not inherit out_of_order_queue from parent > tcp: fix use-after-free in the lockless listener path > net: clear sk_tsq_flags in sk_clone() > tcp: do not inherit retransmit state from parent > > include/net/tcp.h | 2 ++ > net/core/sock.c | 3 +- > net/ipv4/tcp_input.c | 64 +++++++++++++++++++++++----------------- > net/ipv4/tcp_ipv4.c | 52 ++++++++++++++++++++++++++++++-- > net/ipv4/tcp_minisocks.c | 9 +++++- > net/ipv6/af_inet6.c | 4 +++ > net/ipv6/ipv6_sockglue.c | 15 ++++++++++ > net/ipv6/tcp_ipv6.c | 44 +++++++++++++++++++++++++-- > 8 files changed, 160 insertions(+), 33 deletions(-) >