From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796123126; b=4mCayB29CfqgV5SCdnC+6s4uX+VWNzdjQNtKUdX4IdWFaOKmDxBoynBPe2xeg5KPGBYv KOnMbZNG1R8fNkcRwRdgOWQZXLSHWOb2fc4bo65f/1/2bDIJWCvWPJQPEB3Li6T94is13 gdku8DgJLR2nMjbJXR2PHAdPbmJ1tWg3C1g6dXrQPXnFQY9R7ZF1gMQxf4LXABKP+D01W a4aDeBcXQUjnygFeGmvWPZFpWWrwWaKYKyCGcrYSfXpF8EDMCv3SVW4pqkLa7zmSCJyx1 fy6UpmRibwlSfYwpz/f+J08Mbgo4230w4QArM6BHf+qr4o1Z6xGg/J/VadMOBCnpe1w== 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-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=vD/P7cGLfhfiCwziELKSINUKfhj9Qu9PixH3YSiTsK88NNWZNK1fl2gyQmms4ogp19bI jXmCgImg2hfHiQbu0l5YfJa3F/XvBClS3tiOkaAEUCp0ErSetZpIUcMaFz5doJ/PwaqJh 1nOGNe4yJvOaLveaa7jjlT58cRrQy9p/6FczsOpac4vJshyC+UiyAqB4MYpKcJSrPdT// IO4apEyW2+vtuDAywOLUtZmteCcyW7T694MtrNpOrOrfGfDT74M+dimuJWu8ih73G2s4u 5mrfSYyQUneMhZi49d6AY3/i0EnSLDVdIt5O22FHWqm2yalZ7QNSojLko6foVohREGQ== 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.181 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 9BFB8606A320 for ; Tue, 1 Dec 2026 11:05:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9BFB8606A320 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-f181.google.com with SMTP id d9443c01a7336-2f0621eec70so83827625ad.2 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=ENhRJ4gNtmXDht8iQGlNiRJJTEYgGC14PUb4eSvt1/YPjJ8MTu42tBBUiQmb/Tm2qV J/1SKAa3tgSenVkw06AWnUgRprQFVCB51vK9o0joyJKaUX/SstewqPn/B59dU8tm/E/m EIPVxy8hMhlLrpOjU6Ay+wcWmdCZIZfeNUKH/6nv9Z3ZUHlXiIIQwh4T33y6EQGlnHb7 8tttYlH8D+FosfYmwgzzkdSQqNwXa+sl3ZsBedZYeE7KKfIpRHwO1TFsS0Q0I1I6foow 7TMEoxgCR2Rgc6QaLtdRTZJ/0Wief+Pr5k2RGTG8v2/fxHOe7k8PCxr3mtYPlLEuylpK efTA== X-Gm-Message-State: APuU4Z/LXYDVe1baU52O2JYEeGLGkR1yHX/d7j2WJySiG7K5p5l7XH2/ HCsDPNeCvfSfal9gZ6u+PpH8cc28c/fGXoNdRqXZF9PrCK++iLnpU0eC X-Gm-Gg: AZFdTZcvB8k6T5pHRNmsxB/YgYX0DJPTFOuUSdSfV2W3uRDV7XfpTN8mse8C9tBFJ7m plmR+nlQoSXsmsDKRcjv4U6Q3STpQAx3ZoO3/UUkcYu8BusIeFrUipBMWnFbNY/KsRLv+I4l+Sa nQrhc6AMhD3JsOJiA1JttUW+voszvEH2NTTYh9DII1vn813XhqK8EqIVgks1Ty/Xx/GnrWfKQt0 B2e45a3lNnexnEy5Gpo8V6jXnSfuTKGBBDYIoaQf8ywtqNorKmLGhqwuWPrXPcTzj4xlQPp/XqH MbE+7d1NtVKdrLfcw1bh2VkMzm5hfVROFo1xdgnumJPf7ZP6uUZfrvj6WWrr8/lWSgI613+rxtm N1dgXPTHc1UsR6+yb/jqBXcKsulA5C9wP7WQy7p2yWE33eOgNEZyPTbNHLUJkNZL2jIq3JEFq8r qLuRY5Nd9kjoDUm3oq2BvB3vqaNRkeVVzqndSU+PCQnCieNJOYAUthjhwH45fkI3CQwrZfFYhsi 2JeZX3HBu/nYQqjUBj/HbiQZ5TyCEssRPZJ2Jvg9aiQ3Qu6XF6dVn3HGpHAo0mwWIwDY7g6jI5k XD30Yae2oeX7zgIs3dbLHfvcNKQaopCoRiVS5pkwjjrRLEhU7sOwBlPPHlUY7hj0pAZkKDoxBg= = 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: netdev@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