From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 E948113777E for ; Mon, 24 Aug 2026 03:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787542451; cv=none; b=k4MnDeQ3udRUC8W/W+i5Ns3R9rq7nqa5TbpMmWdUkO+Z1AgceGBq9FhX9lQ5j3wb0AtCuSDtvAisf0dldjIPQ4x9+mgE3GmmotkQ9aSTOmKyobnfcqmjwj9Ea0nn/hafKLV0Qaps0Afm4qe/bZ9I4btVI0T/7sEW8R/HUrlO8hc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787542451; c=relaxed/simple; bh=tgc7fQo6gJe8G/SSc6IwY1kqu73qHMplp+16vVw+mgw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tlM25p33d102MugJeQA94eAjgONfx8sy+D1vw3wGFpA7UpRRjzk0Y1kJxny7UgOXrglBUW7OWOT3YCF5PGppZIDNjAApIQ00Ghz/GIpqjnRENHNQT7jA04e27okiPwKvZUW++BurI66qsTPl54/CitQ1QzXR7oefDqvd/mAbpxQ= 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=AQduA3QL; arc=none smtp.client-ip=209.85.216.53 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="AQduA3QL" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-38e42560ebcso2204926a91.1 for ; Sun, 23 Aug 2026 20:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787542449; x=1788147249; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=KXdtuihM1G2t1d7kD4Du7Ico+fC7apAYzZdayGyO9p8=; b=AQduA3QLwsfFMUbW6Tes8iwmhWZA0B2OUZAUdrtZjzc+WFQ+9DqrSvEpeafdNJ5ueb i2ii8lXPA668BeGqPXoML+6a2j9EK9cHBCP3tEGMY8glf2g03fA5apaNIw2NCGll7vJy bJW1uTkI5pW0NFFXZG7mltsTBVZHKk3Rav4ZmyovTckKa4DVC9hRrrVoNEXiSeAXxfV1 4ELHMI+1o3g5yVdSkL5sXzeRQtKz5karWVb6SKeVKHjRBIfRu+UD8M2nVSxToWe+tDWQ 4fDL+LpB13jKcGhFCbeTtTLMFovQI9yxZhs9PnTCmqE/aELhDZ07PUJcV3mfJHkgYEGV 2jmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787542449; x=1788147249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KXdtuihM1G2t1d7kD4Du7Ico+fC7apAYzZdayGyO9p8=; b=kg7wkMbIcKsGBP1mBPbY0ydTUQ4T3QPjLjASTfJn4m9q6EWVU5v3FFM6nkWYsJX9E4 sjaG2k+utn/tWuKb4lAIvoKxJc8C1eltNoi2gc0mZl3Ufx6ZG1onIT9LnUF1SUfeXHz9 jxXvJimIaRN+24hTnqG20xKNonKjqI2rCCkioEjy+g0soCkv2bXbb+xrdyu6TnHkMZrf 8EtH0boIFe/kLoJtbGjyVS0EvHaOkzmhAu/+CpmrR2L9Ru0GO8WwWj3B7MMNfNR95uS5 91qFQsjI44akyzmRkoEcMkqeVHHbsIiIm5OYKBDzCQKv4I9nsY3dPuF1CzVII8nk2tRQ Zkng== X-Forwarded-Encrypted: i=1; AHgh+RrXOcHVMm653Uveq7CN1YE5I5evruRM7TSo8qBf07FJ7/cV5hoDB3ncaldc8cbuISSvISqeJlFNbze1l/Q=@vger.kernel.org X-Gm-Message-State: AFuF++lMlDmvjeD4kwPopkOTUCDkqQ702LhYXEOQYYFigjdVT4WemQEF HBR7Zby388dnwzSLFeOzBlZpYMtvyCtxDXZGWx6cn2U3enMQmdO/UtsB X-Gm-Gg: AR+sD11DFj1zgYNN3YYoH99DXlWsfRzBNY8mmgyTkJSAwiaXD0IaCjz6Y2RypTe/9Ab 6CcE3VGfS+fYcNeJj4KiVYRE/0bLQfHsLZYNjR68ucRReD+IfcTJyNO4yz72b1cJo/TMD0tfPr5 s6Yq/PL+Bh5RI4uPq6lAtwoBNs1mHAXfpTkt3Rw28Xfzg1GzPhVhXKEh4Vp77GluJxBF0/EDbPr cMJiikjj/RZ+P0RrhkkuEJMKFWkEyk/XsGWTMFh0ihtSJ+g3yrtXiODkZpJkxcRBS1NdFxDSFiq 9c14SaUv9PRa4EywqzymSxg4j+Q/gU7QqJe050z0Oo8epv5BBnhgTUC9VNyluCet2ArL3ofD/Ej 27gpbO17Zub6dR0La0GDPSdcv5bBuVge5oV8DJdaul08VBMXHG3Ffjb0YGs4skvv7n/5B50YyUe 0wBDbp4MCc5BdFXFrG4/+ZaokWjF1A+AjifSCuefvWqbTHt2k3y/9rR8Q8gcJPk3Ib/s3bj7fq9 Ivxxf6qLFI= X-Received: by 2002:a17:90a:749:b0:395:f0e8:9e13 with SMTP id 98e67ed59e1d1-395f0e8a0c0mr15619945a91.7.1787542449255; Sun, 23 Aug 2026 20:34:09 -0700 (PDT) Received: from v4bel.. ([58.123.110.97]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-395c8fd34d9sm4227256a91.1.2026.08.23.20.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2026 20:34:08 -0700 (PDT) From: Hyunwoo Kim To: 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 Cc: 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, imv4bel@gmail.com Subject: [PATCH net v2 0/8] net: fixes for requests completing on a socket that no longer listens Date: Mon, 24 Aug 2026 12:32:44 +0900 Message-ID: <20260824033331.1084971-1-imv4bel@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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(-) -- 2.43.0