From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id E1DD880069 for ; Mon, 23 Nov 2026 00:26:35 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AN0PLTM017837; Mon, 23 Nov 2026 03:25:21 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AN0PLTM017837 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="QV74qBPY" Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AN0PC4G017797 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 23 Nov 2026 03:25:12 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AN0PC4G017797 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6ba810fb7caso837666a12.0 for ; Sun, 22 Nov 2026 16:25:12 -0800 (PST) X-Gm-Message-State: APuU4Z/4sYgNkAyhMYYPufK0mg1ch9qCfaHvVfJhjKTjmmL0VwzXFeLV iYPyN49CZZUwed4rsIFG3txYOaoevt56yIggpYGlUGJZVD+3nrHKqTJfKxww4COfJ3e6INwQCNz NDdlzXaLDe1X9p2C2n7E+V3riPoVxFxhSeMbxQF/DHr+LQ1IZIcbGBw== X-Gm-Gg: AZFdTZcv3yweDUF8Z1JBwpANtvaHycg7CY1Ego5hVasPuKNcQpjKvHNhWfhqvItLZIq NmjwlBTIHAM9SpRXel/BGcktd9anj5Quo/YTsIn9vF8H/3Sg6ib/82rLVrPbs3rwdRlvWUX34NE zGLFA0vOmhn41CkWdX3au8v6WVAxtS5mbnSQ6WlHAgqU8Bjkp3RBlIDitL8zSB42RwQxJHJvA9V URTdfCJpnAnTrmy8nsGTs34NXbyALcQCqVuFNygAihbYnN9LQMy+rLvTDtTGH0+ZFVTYf4e9o9J OR3b2ZTzwCYfSE7kEGxZtVO4lzBpX7ddlTRwjyk+ZsjTOnhmC3RyJ8bjv37z7lDVZgsyPyfRv/j UopzM9JvQvcW0oyP4/yu1cH/Ttw== X-Received: by 2002:a05:6402:1e90:b0:6ba:9b29:696f with SMTP id 4fb4d7f45d1cf-6ba9b297525mr1673910a12.12.1795393511750; Sun, 22 Nov 2026 16:25:11 -0800 (PST) X-Received: by 2002:a05:6402:1e90:b0:6ba:9b29:696f with SMTP id 4fb4d7f45d1cf-6ba9b297525mr1673899a12.12.1795393511309; Sun, 22 Nov 2026 16:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795393511; cv=none; d=google.com; s=arc-20260327; b=lp+f6KyZRviBv/IstgJ/eUNoQZZafCmRb9/hM7BFUhdp1zvGYhvszy12lsPi31EQU3 JmwkT5kA5aGPpEC8iSnOyYLet6boGXpfjWmwjeyq79/Xj7W4l5G4KYtpgW/hLTlRzSPS dBUH7+I8k+qvuqOGOzSzuY7AmFm97vL4Zjo8Ec7Fys2Fz0OUVBf6lvk/xzNqthlQWj05 WIYTx5Rdx47hEWEj+FCZY3g4evuYPmxqHM1KSs1ujHoHXW2RwQlY6SHQEFU6X5jzVqUa 36aGAyRV2ASVYy+KSE1enPUkyW0BgAKHIsR9fcMHwZaSmftZ6+an3ytKGo4EgbN477xm VsdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=FmJEbv85vD12Sx1oUSh4mYXJ0ASgJfRSl6QP8hRCQKo=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=TaOV8MKyUlGS7L6ugwtyM5a8wNBR4m9JTOMGeYXV6gPDDFbLNOzasnyZhBzHrNWWGE sFlBVrS1+LOuDkoGJTeVdXpVOYyZbhWr5OhVr9C6YsAYT8ZmrduzZxAqI7klkkcMBS3B 6KZ/KBBitJmhU1HDHYkPSBo8OiVeFuVG+AJ1v52DLhtoq3gCHqOUo/2MtBTcoUemu9/w /3ZE3fS3XDKDtoGTBnflPTvbjWOpnQwPbi/ZyEQRoQ29vdbo0nBc4KBLV+/OAJd95S/x RHOl4EqdKFLdnhvSTQR+2BUU5M08ypIUrB4J/BQIROZVcRjYFIm0oDWhkaePpYWIVZv3 5xZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=QV74qBPY; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-6ba3739e160si8204945a12.186.2026.11.22.16.25.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 16:25:11 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=QV74qBPY; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=FmJEbv85vD12Sx1oUSh4mYXJ0ASgJfRSl6QP8hRCQKo=; b=QV74qBPYyipK +4Jy36miH7JHPyYYZfcstjre5BE28i+v9P6gGHJxxM7JAAE1H3T2WQbYG/JPZxUWjzv5L4PcaAO/g lD+6cACNvvFO2mWYqBOY1xNUwgAe71GU2NaYQs9FQoQqIaO/DJF86r14C84cYPyLvLoWYtyH5UR/i NJ3qqKyER+H4ZTTLYmmQiFyY1pr2PlWHmPZCMtEUZjPHXSZCnXEJXCgix1wI+6BaIOMIJzORoEUgv MA369LA0zDkIUU1Sn9baUm6rX2rNIHQegm7SGGs06IZRj9LzE0wECpSnsOqO5lh7pegm8jmeXcT1x ATG/n4FBQFYGmqfuoxFI4w==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xVHrj-003eek-1W; Mon, 23 Nov 2026 01:25:03 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Mon, 23 Nov 2026 02:20:23 +0200 Message-ID: <20261123002500.1652289-3-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261123002500.1652289-1-eva.kurchatova@virtuozzo.com> References: <20261123002500.1652289-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 2/4] ms/tcp: ipv6: do not read ireq->pktopts from tcp_v6_send_synack() X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Eric Dumazet When IPV6_FL_F_REFLECT is set on a listener, or the net.ipv6.flowlabel_reflect sysctl has FLOWLABEL_REFLECT_ESTABLISHED, tcp_v6_send_synack() reflects the flowlabel of the SYN packet, reading it from the skb stored in ireq->pktopts. Since commit 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table"), request sockets are processed without holding the listener lock. A cpu can then process a retransmitted SYN for a request socket, and send a SYNACK from tcp_check_req(), while another cpu receives the ACK completing the 3WHS. tcp_v6_syn_recv_sock() consumes ireq->pktopts when it wins the hashdance, and the first cpu reads a freed skb: BUG: KASAN: slab-use-after-free in tcp_v6_send_synack (include/linux/skbuff.h:3152 include/linux/ipv6.h:110 net/ipv6/tcp_ipv6.c:582) Read of size 8 at addr ffff88802b08b608 by task poc-ipv6-pktopt/5076 Call Trace: tcp_v6_send_synack (include/linux/skbuff.h:3152 include/linux/ipv6.h:110 net/ipv6/tcp_ipv6.c:582) tcp_rtx_synack (net/ipv4/tcp_output.c:4719) tcp_check_req (net/ipv4/tcp_minisocks.c:762) tcp_v6_rcv (net/ipv6/tcp_ipv6.c:1826) ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:479) ip6_input_finish (net/ipv6/ip6_input.c:534) ip6_input (include/linux/netfilter.h:325 include/linux/netfilter.h:319 net/ipv6/ip6_input.c:545) ipv6_rcv (include/net/dst.h:481 net/ipv6/ip6_input.c:119 include/linux/netfilter.h:325 include/linux/netfilter.h:319 net/ipv6/ip6_input.c:351) Freed by task 5074 on cpu 0 at 15.412249s: kmem_cache_free (include/linux/kasan.h:235 mm/slub.c:2780 mm/slub.c:6630 mm/slub.c:6757) tcp_v6_syn_recv_sock (net/ipv6/tcp_ipv6.c:1528) tcp_check_req (net/ipv4/tcp_minisocks.c:934) tcp_v6_rcv (net/ipv6/tcp_ipv6.c:1826) ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:479) ip6_input_finish (net/ipv6/ip6_input.c:534) Request socket migration has the same issue: reqsk_migrate_reset() transfers ireq->pktopts to the clone, which can be freed while another cpu holding a reference on the old request socket is still sending a SYNACK. The SYNACK timer itself is not an issue, because inet_csk_reqsk_queue_drop() calls timer_delete_sync(). Save the flowlabel of the SYN in the request socket instead, so that tcp_v6_send_synack() no longer needs ireq->pktopts. As a side effect, the flowlabel is also reflected for SYN packets reusing a TIME_WAIT socket, as ireq->pktopts is not set in this case. Fixes: e994b2f0fb92 ("tcp: do not lock listener to process SYN packets") Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table") Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.") Reported-by: Anvik Loitongbam Reported-by: Yingjie Wang Closes: https://lore.kernel.org/netdev/82c31e4d5043f3dbd11b44177cfba779d335aae3.1793599929.git.x-professor@outlook.com/ Signed-off-by: Eric Dumazet Reviewed-by: Jiayuan Chen Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20261102075441.3771550-1-edumazet@kernel.org Signed-off-by: Paolo Abeni (cherry picked from commit 8e069fd3fd396b89af417e50b359bc9892dd41cd) https://virtuozzo.atlassian.net/browse/VSTOR-156045 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- include/linux/tcp.h | 3 +++ net/ipv6/tcp_ipv6.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 6a5e08b937b3..c52d9348ef47 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -171,6 +171,9 @@ struct tcp_request_sock { u8 ao_rcv_next; bool used_tcp_ao; #endif +#if IS_ENABLED(CONFIG_IPV6) + __be32 syn_flowlabel; +#endif }; static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d572bec5cc51..aec76c54327c 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -546,8 +546,8 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst, &ireq->ir_v6_rmt_addr); fl6->daddr = ireq->ir_v6_rmt_addr; - if (inet6_test_bit(REPFLOW, sk) && ireq->pktopts) - fl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts)); + if (inet6_test_bit(REPFLOW, sk)) + fl6->flowlabel = tcp_rsk(req)->syn_flowlabel; tclass = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reflect_tos) ? (tcp_rsk(req)->syn_tos & ~INET_ECN_MASK) | @@ -798,6 +798,7 @@ static void tcp_v6_init_req(struct request_sock *req, ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; + tcp_rsk(req)->syn_flowlabel = ip6_flowlabel(ipv6_hdr(skb)); /* So that link locals have meaning */ if ((!sk_listener->sk_bound_dev_if || l3_slave) && -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel