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 12DFD80064 for ; Thu, 26 Nov 2026 06:28:33 +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 6AQ6RIe5007813; Thu, 26 Nov 2026 09:27:19 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AQ6RIe5007813 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="gaNYI4ut" 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 6AQ6QuKB007726 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 26 Nov 2026 09:26:56 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AQ6QuKB007726 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c505eecba6cso528404266b.1 for ; Wed, 25 Nov 2026 22:26:56 -0800 (PST) X-Gm-Message-State: APuU4Z+M+0RdNhB92p6OdRiJVYUSuowRLDZlha0jUhqz8L0d031iq3gs /UumFOo6fu75p5pvTueLZnOYFb1KTRno/U38/yoe2culJDKBBF5g4wurTT3eEcsXsEyLGh/Yx9i Mj0XJtc0zniqaCopH0xfSw0G/xGissrRzo/88JTHWTIkVfQYaf/i60Q== X-Gm-Gg: AZFdTZdxXNYrAiEQQffeTUUMqoXod1xUNMKtWvoAoSd6N092yOvGR/el4jUAR+uJpTN n0nlbIPHob3xlNwQX8cS6fJoKHytMriK1fWZ5h22Lm2HXWdAI8/zdKc/RHqNq3ZCCuFJydmenBH 573reuCuhxRgGCvAQKHA96pwu5aS8vHATxXjfOKfwDPLdJyzlaKi7Id5nkso8w/rif8poCZXHX/ DmsRVHNPY8L/cORi9QM1luw3tULGbOEwjl6VwPHf0wvqRgobjK/62Q02cG/ejxDRe6CQnmXZbC4 EPV43TKdXt2Nb2sc8QJz0Dwd3tO/2ae0X3hGsR0DZUgaBwHkioynfVexTELPYYyNxkLQOibUrWN nQcrgFH2mhcIres2qEGJUTvzlrg== X-Received: by 2002:a05:6402:400f:b0:6b8:f674:e099 with SMTP id 4fb4d7f45d1cf-6ba37eb3c34mr14170830a12.34.1795674416181; Wed, 25 Nov 2026 22:26:56 -0800 (PST) X-Received: by 2002:a05:6402:400f:b0:6b8:f674:e099 with SMTP id 4fb4d7f45d1cf-6ba37eb3c34mr14170815a12.34.1795674415669; Wed, 25 Nov 2026 22:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795674415; cv=none; d=google.com; s=arc-20260327; b=hWaKfJuLz0LQxbwUzRGQfuyYugYoQKeMZJPgxfw8QKtKZeVD3/mdxNkgn0uqhRB5/L UGzWSEfMPz30N0gRGbSzk528Wtrdgmb09aDSoKkgiw9QziuFtbFGURFGy0ifyLJEGD5H Sq7dzCvsvxy/ZzPTRvYGyQX3B0zkMALr6Ea5oRw3ZaCsyL1h5ImdHoGLGli3uBvZWqwg 9dcOX+JLfNWPVsNNf43LxUMf0VeD0mh4SfhGLm2+nYbsdVz2rbNV/dEEXvU4zAyUMVpT 8Up54+T/mv4dXqOyTj9sCkWbKf5Do5xWRgvs2zdfi6nHDa9X/ZOMdOSVFcOdAgpCOYQB 9n2Q== 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=PDR8IJP5gFvo3Nt0jxlAYMsALlDY+xqr27Drb2qTwHV2QMXwJCcVbVzdfCM6f28J8U jTclfdGKPeIPSLl+kCs2GL6Q3gzX4huq0wOIhdwg1thH6WwP/VsBlMRnkwzYIEikuPS2 +o8+rGkChqfkn24Vd5xR2vhtu4bN+DjMy4yHAyXznD/mI/tvkgaPmB4jpA9OPKwOyPdi zrpAyGXBJqR0sTBp1fjKn/lkkzFps3curRFV43nzyCeW29JnDCO+SzOsOu+68bWodBLW x0zhj5ZO6qo8/WwNYSCcVjLYCmfgXM/A3BH2vmkpZCWXzkbuAODqPB+dRrPjpqQhYTH7 uIpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=gaNYI4ut; 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-6bb34158dcbsi2709750a12.131.2026.11.25.22.26.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 22:26:55 -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=gaNYI4ut; 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=gaNYI4utNXwC BQ9w8FmREMv27Phb5pH2u+g+Qd5i5TlIi0NfgVpniki/2v+aOGffeoFeAgIEgWx8iMEWQKTvc9k7k P5VJNlF1n6lf64OEd/61oXiqakoEYCJ5hgrTBEi7GsA8mW3h1a6v9FjeZw3Avuf1kCUGdbWiaBXem 9fqGsKSLhohNcEm/X7XxFAqucfaGo2MvnAJI0H+Ym4SQsYGZjUdpNziy4FrNMKlUs+O/+kYDriiY4 1D1YwMbR1vgvCpKYduyuKzu9FVqyOYOtG+WoHvAbrwDHZnKYQ8k681wp48wESpCD9RVsmOsIAO2XI fJk0Xs2pPDb49C11/GCVCw==; 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 1xWSwM-00EFGZ-2w; Thu, 26 Nov 2026 07:26:53 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Thu, 26 Nov 2026 08:11:05 +0200 Message-ID: <20261126062617.2133758-7-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126062617.2133758-2-eva.kurchatova@virtuozzo.com> References: <20261126062617.2133758-2-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v3 05/10] 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