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 5DE2F80067 for ; Wed, 25 Nov 2026 06:23:01 +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 6AP6LnWg016530; Wed, 25 Nov 2026 09:21:50 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AP6LnWg016530 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="nzbo+hV8" Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AP6Lb41016477 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 25 Nov 2026 09:21:38 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AP6Lb41016477 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c505ee61160so528742866b.0 for ; Tue, 24 Nov 2026 22:21:38 -0800 (PST) X-Gm-Message-State: APuU4Z96+BdKnQaJvy25z2Xa71eO9i6S7WVZhSACZAJg8Qo0xxnRrk/1 fle5Aif0TuDN5Lwolx5rjaefuvcahiMia0+N7WGFIJnMTb7Los++ormci1e56OtlhiVIyBwc8+z duwBWOGQ2Z5wUQ7bmkVk8hLTKRMTBhAb+fcln5agiubKy6jDWrOgckw== X-Gm-Gg: AZFdTZdlXIGxqH0jrzAyGtT2ppTN4P9ldPswZZJ0Ak3XGwLPyeFSFQ+vxRULzHBG6pr ef3rDN6GysdDe290LHAazw0/jWqI8hKtwZpYoFGbdGY4+HNkLo4b7xiZxOWOYSigVYVmMoEaemV uYHoiCryTNWZnX8ogJj8e97jPB1DqUDDRPjEfmvE3SFj5KTX3P+rN8DZAD3pgrZppMSgfer79Td XSZf0at8RInwiz9P4XiRYda/e1ns5sJA2COiQNeikukovG5wGBuNDCM6SweycH/daAnRd0dJwDx xHiqfJwgiiFlWVrwuGiiDbEHdprRVJCpwDGwScyyz5hU72Clie8einRCcTu/vC8s53W0AQsK489 ZBjuF/y6FAD3crAQmtZepiGUL X-Received: by 2002:a17:906:c59:b0:c46:5973:2a1d with SMTP id a640c23a62f3a-c513aad1251mr1023351266b.43.1795587697599; Tue, 24 Nov 2026 22:21:37 -0800 (PST) X-Received: by 2002:a17:906:c59:b0:c46:5973:2a1d with SMTP id a640c23a62f3a-c513aad1251mr1023350166b.43.1795587697052; Tue, 24 Nov 2026 22:21:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795587697; cv=none; d=google.com; s=arc-20260327; b=R4yQ8xBRQ6lwlq1XCY0NlCW+PqbJizDkOq5mqEU1IgtFYVxXqEz0OHr31HbTmFomj/ qASkpH+pnoQrE2XHbelmR4DutzBIpNmbaugowZ5ZdWp1zfa/qnkE6bsDAndUUwPPFZ+t mBCVnEoLzVkIDfWvZF437Ywa/d0b8cn+k0BgMfEmoY0RmeIT0NSYvn44BzIr2eecuA/f vTD7jWwVayHEHv4sXcekFO12skXLEeQ5SW4VccmJcwN2zQ/YOjTQZvX8wzf8ksVXB+XG YaFm+AS757TydS/GIl5otz9IcocObs2f+vYnkutsZSoqrYJ2HdhKyCueh4doJp1EuBvm hMlA== 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=ABB0j6Rp+NtAhU7UGsHox6J9rTLF6OjZbUDI+BUtFw0=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=Ktg05DpNYQM+rWv2ENYv+hD3BMCLBX16ra/mXZjXakNU0Ff1Nk/pOGFhaWCFcZwktt F1QL223CvV0RNDeg6LABIhOkjTPOaGxMAPpujPqDuKDMykvacjzTr1amXlClhxX9auFq NQmMe2/jRDlgwdXunmpj1Y9GXSIQi+EuSTb0puVdgzLnQSBEmC1QYeyM5yHOZoOW+CEE A79IKuFHHzKcGU/2IbNE7PdoKruEcXoFyjDnDJ3nLqASGJwuuvioIz/Bl8ZUeOVNsHDg HaPHJy1xJv1RahUxjofW5LpCfPjaCE6kostqvMG7k8EKTWKrwje7Jk1pQnLXTB4PUrO2 XjRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=nzbo+hV8; 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 a640c23a62f3a-c513afea6a6si1079082966b.102.2026.11.24.22.21.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 22:21:37 -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=nzbo+hV8; 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=ABB0j6Rp+NtAhU7UGsHox6J9rTLF6OjZbUDI+BUtFw0=; b=nzbo+hV83N5J 9RXBLb2AZf/t/libIN/Tp8SLaz8BlXHdCoefzFc9eUWrjczQi1HD9v/h9CWfJETJE6oBGBH8WFLID aH61ZqqEij5B5rpUY0KcZew4/5sQxrrYHweGU8Oi1UK2eZgVGEAXPu3bxcG12E2GjjODov1U4Aj3G llqGvYmhdCFAMzR7XdWFALS9y7+xnAG0K8oaaycbA9XL0Zj854+Cr3eu1KkSbXGLHDdQo77cp/wCF LogmF7fBl4K3VDBdOkK8gQTMF8L5lKwB1l6Hnlf5ZScReKjhsUUwz61NzXrWWdpnSxuxiNxBnzziw KNdARf55OuiZ/lEQ6h+Juw==; 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 1xW6Nh-006mb7-2R; Wed, 25 Nov 2026 07:21:36 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Wed, 25 Nov 2026 08:14:13 +0200 Message-ID: <20261125062128.1996509-4-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125062128.1996509-1-eva.kurchatova@virtuozzo.com> References: <20261125062128.1996509-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 3/8] 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 Reviewed-by: Sashiko --- 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