From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796123126; b=N5IFDeKxiI5ecgGra+W7h6pVRveR/Rt8wDh2dsTnZoozBSQxJ7b/AnpCxiFqo1M0+oRF qFv1meRm004eUmzPMWFOGJ5TT1YM3QiID23z5HXNFxeJsa8dZ9GRukIhzo8a8CUr6YQ7F OGuW3/eRmUeTepweG3bdh7xqY3h1tZGean/ikPr1zI79JVUT42vmOply/DAbiceOdqcyl U0qadOCGupSA/HpHvhkQpGKNIiBlC2L43+rE3nPlNzqVf/MKxIMl3f10z6NqMfi14gjNH Q+nEf/223k/D+V83yUAxPmPGcTZCLMXrGfZ2s9d1Pz5WOd3Ap9R+68vTCTFED4R/KeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796123126; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=MBlrnzGq1MMTWxnnq/7lY8yf1KLqphiyTxQFvM0kWYA=; b=MypPE/r41ju5J7y9vnSktprBAfuP1FUNv8KBP2DlLfumxHEsfOo9WUZ2djPhIkvyI7Va 1d7DP9/2wPIVFkgdqAHvDj53vamFDaAyRVQkHRy4rYmCB/nzesmbzonfIeFJYLVGeeEnu 8aA2DtdZRZwIbIYOp9yP+YNaPbVF1nJI1wdfuWQcMw6bV6vpv61ljwzIQ2MRUZ3wQwAbJ U47D+aGsQ10Hsa1e9V/9Ea5qFDDMaKDRm+9Ex//C815+F19pp/7e6tqJZ1dJ2MBSPhmDq vm0FGi625fvEBKJMMLfZemfyOavhCJ3+teW1CMWMt9rvvj7fgCNBZFUNaF4K+bOquGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=roq04QLs; arc=none smtp.remote-ip=209.85.214.179 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 990CF606A31A for ; Tue, 1 Dec 2026 11:05:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 990CF606A31A 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.a=rsa-sha256 header.s=20260707 header.b=roq04QLs Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2f037bc348dso90801235ad.0 for ; Tue, 01 Dec 2026 03:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796123125; x=1796727925; 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=MBlrnzGq1MMTWxnnq/7lY8yf1KLqphiyTxQFvM0kWYA=; b=roq04QLsqOIlrGD230T9FyKFGyjHMRueOKDE8Gfbq05wVy90tJakoipmGpi2AiEJ5w 5CsZJp29OwDwHOSKKv9LMyEQiUNCxgyF4L2wov9MwTgMRN3ozOIh3esr3Ta5+2mt3aH7 IFCAw8k+qiZFXtMO7kuaiDCVJ91Sp2oJUgDXty95ERj3sLsS1pF72xoXLjboxfB69se9 8u8NYTOLLfhTWaanjYguepJvA8YpEM2tDT7hSuFZnrqM1YDU83/M3mT5LhfLvFMxbuec M5jQxWcC8YX81fNVC95b1Zi3W32Mm4/Gmd20uZ2tbdtsQOJ1Q3eFcxcb6In/hRARW5nc AHQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796123125; x=1796727925; 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=MBlrnzGq1MMTWxnnq/7lY8yf1KLqphiyTxQFvM0kWYA=; b=aE8U324xueaUN9YpeFwI9SrbLxpM5cnAu7pOP/g6M9lIAr2Q7dDhaMPhOxHWSTx4ZQ M9dQUetZdQ+Lm535fZM43ZI8GnwHyKH5vPUVULS9f+2559xmZhK/hmCO+iRZ4bVqVFyU PdhiKIolP5otVc91tp+uHaWCEs0nAgyAnWnxl96hRiySrhSxxRN7iOHHD8zSPmoEefqf px4q/SNJ+ZiyS9CQ4Z4FyvpB/EoGB7v91B24BItvASOc07CUCfpe5o9KxRthSShZGF4A Fk9R6akGsDoxZtzExsKBq/qUYfNtwP4rLCTX0geErNLUK9YBFaZXUkLG1a5W3DUEiITE g3Vw== X-Forwarded-Encrypted: i=1; AL+hErFMzX6wTtd0hcEWRjtolXMMawgphaAAgn4ZzlDku3kYYww3XNRT2ohcRIOkITlanwWm49JN6tYrvsk=@vger.kernel.org X-Gm-Message-State: APuU4Z8Y5j19pzQNDuN1Irc+804x++tBmg/Hq6B1Z+iaYfMRTEGAaA4y Kl3/aBJnqtfcz6IxPdi/wlm9m0KU1ZrSbi3XJEnvnsElritWRKn0PKTc X-Gm-Gg: AZFdTZfvjdPvzldtMTHVHOj3FN+8HbnXwe6hetX9sS2Qz0I7jEP7kYKC6zmdks0tfTb bpNMUMm/gC0eoHepUCtcwKaKC5zaCfPgAtZMxd0rhctJ3MNL9vSMVRDpx5tcarZ7JRJxLQTVYlS j+PAwgCYcmjToeiVYDTlfMVGUWMBRbDg7bD6os0R0ztD54q8qrdkx7QjY0DdtPV0lK8mn9Tar/4 oTVAc9bqVDXWW8ZOGcU9aWQopUaYRbnqfE6+1LDr3oQL/utDbW7wCn3WCvQGl9PKRMdEez5bTC6 ruW8ZssKrgqofK+5Hlm9d8iRurQHCyvcrAzVQ/OKvPCE3Wvqxl/CI1jUghOIg4F+UO/BtS34tUt RsuzuBAQhwiChd9+Y3+wBc6thd8e9m70b1dhz2eDIOHlmeiv/58JRbxLoT132u7zw5j3eV3cN/i wHX0+OGovcgZTY9rqFNfSrl1fYvx2ZHfNnabt7RMYP3QJ1PIoGv0lbLwsoo3d7mpyQc0yrzoUdQ OybQVS+1GpYGqJbtbLivPyC7QGy5ILt6F8FjbHwVCnNrHIP5tyLZBAt6xtY7h/Dkar2LL3LG4c2 CzKzY/FTMaxEnLdlamXb02Ps+rkYjuKmjR0IORSsbXaPz33LHJvbrOyktwLHd6MHCnfb1kqm0w= = X-Received: by 2002:a17:902:cccc:b0:2f0:d976:651d with SMTP id d9443c01a7336-2f0d9767d6amr210757785ad.14.1796123124311; Tue, 01 Dec 2026 03:05:24 -0800 (PST) Received: from [127.0.0.1] ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f16e685d36sm2925465ad.48.2026.12.01.03.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 03:05:23 -0800 (PST) From: zhuorao yang To: Simon Horman , Julian Anastasov , Pablo Neira Ayuso , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [PATCH net] ipvs: adjust non-SYNC hashing after late destination binding Date: Tue, 1 Dec 2026 19:00:12 +0800 Message-ID: <20261201110012.77694-1-alex000young@gmail.com> X-Mailer: git-send-email 2.56.0 X-Mailing-List: lvs-devel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ip_vs_try_bind_dest() can bind a destination to an already hashed connection without IP_VS_CONN_F_SYNC. The non-SYNC branch of ip_vs_bind_dest() changes the forwarding method directly instead of calling ip_vs_conn_change_fwd_mask(). A change between MASQ and non-MASQ changes whether hn1 is linked. The resulting stale or missing hash node can be accessed by connection lookup, resizing, or expiration after ip_vs_conn has been freed. Move the hashed-connection update outside the SYNC-only branch so both late-binding paths use the existing helper. Fixes: f20c73b0460d ("ipvs: use more keys for connection hashing") Signed-off-by: zhuorao yang --- Vulnerability report Affected versions: Linux 7.4-rc5 and 7.4-rc4; vulnerable generations are kernels with IPVS double hashing introduced by f20c73b0460d (v7.1-rc1). Trigger conditions: IPVS backup synchronization must be enabled, ip_vs_ftp must be loaded, and a TCP:21 service must have a DR/TUN real server. An unauthenticated sync datagram and FTP PASV flow can create and then late-bind a hashed non-SYNC connection with dest == NULL. Configuring IPVS and the service requires CAP_NET_ADMIN; injecting the remote sync datagram itself does not. Related work: 712d2993bea5 added ip_vs_conn_change_fwd_mask() for the SYNC late-binding branch; this patch covers the remaining non-SYNC branch. Reproducer status: Same-version Linux 7.4-rc5 KASAN QEMU: unpatched kernel produced 15 slab-use-after-free reports (13 reads and 2 writes) in conn_resize_work_handler/ip_vs_conn_hashkey_conn. With this patch, bind removed hn1, expiration and forced resize completed without KASAN, and the kernel powered down normally. The test harness drives real IPVS connection and destination-binding code; the final network- only FTP/sync injection chain has not yet been demonstrated end to end. Reproducer material is intentionally withheld from this public message. AI assistance: DeepSeek identified the issue and drafted the patch. The submitter reviewed the code and certified the Developer Certificate of Origin. net/netfilter/ipvs/ip_vs_conn.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 83d8a9153a34..ad3671288b3b 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1134,17 +1134,16 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) /* connections inherit forwarding method from dest */ flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); flags |= conn_flags; - /* Changing forwarding method for hashed conn can - * happen only under locks - */ - if (cp->flags & IP_VS_CONN_F_HASHED) - ip_vs_conn_change_fwd_mask(cp, flags); - else - cp->flags = flags; } else { flags |= conn_flags; - cp->flags = flags; } + /* Changing forwarding method for hashed conn can + * happen only under locks. + */ + if (cp->flags & IP_VS_CONN_F_HASHED) + ip_vs_conn_change_fwd_mask(cp, flags); + else + cp->flags = flags; cp->dest = dest; IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d " -- 2.56.0