From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE3273806DA for ; Thu, 25 Jun 2026 08:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782375920; cv=none; b=lN1yqUWhJNOC2RBaHU7XqI35rkbRTk99iTzOa6a2MB+ymiUf5tCW2fc6gj3zPU1XDs8jWeEDjh36+3hxbdWtUEwhaox+eNTgUjqg+D50xqrN9oTcUjGbYHnrP+BAQF2myJdWLgyt3ZHWkdpBQWKLBwtOSqeWPWPB0yrOc4AwG+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782375920; c=relaxed/simple; bh=N5soKUtSuwwQrMT2T7V6ESS7YgqojhHhVowe5dyJBfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=puu1tmdGCrXQDXMEzwxxKmDRdL85oPwIkYHQ93Vf2WulsxcZ0onoTLa2ceipcfqccjI9vyDZK2r2o0rL06jU+1MCxeKoXuY5OE48dZCuc17faN+hQiTfoDKGJj4Ldt5VhrAv6tegEmMYzBBM7c7Qq4l+bfaJdSfibknz/Q3li94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BM9QD2FS; arc=none smtp.client-ip=209.85.208.181 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.b="BM9QD2FS" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-396771119c4so18302821fa.0 for ; Thu, 25 Jun 2026 01:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782375917; x=1782980717; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HDCoYVBjQzZ+2LVFbZQGc2v/ECMbMCzgWa8ygBvGziA=; b=BM9QD2FS0fNbB+1yZP0H7rtV4vPiPh462laUpaxOcOK+VwgG3s3e7XmeeHZp+nljhk nCytwEuSQYb1FinforY0l4H9tbCTRIy+vk2wkqPCqXWqCIRGu2RfmphGaFGZpcfGwFej w7rqMhV1z4xxpDFRn93baKBhXAQvnCMTogM9ekBcv3tnrjuJDvb7DAGMffDdjJtDvS4A 18zKTFQ9cW8Wes44aCTyFnPphoSnv4b4/YwV0EUMz+1VXhpXkBfnvdWKG0b/mK5iuqCp d4yx1oGxXU6qD1TrC02cha5OCc8/vvOp353Bygu7TmZMlZ09KX+MPlXvfxd1ZCR/N9f0 93ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782375917; x=1782980717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HDCoYVBjQzZ+2LVFbZQGc2v/ECMbMCzgWa8ygBvGziA=; b=Ie/Tp0g/xKls2/kFioVmQ5gbEaQKNuwWvWLy2o4W1eglk3q3Hgzc8dfC1W9kkCquPA FNoTyj4YqyZj3nIoXN2NcwGZoWx7H1o9DwawxVbihiNoAoChh/7zasDgrGsFj19MGd9a izUVwnzK6+CnE8YYNqK6boCUK7hC+/5XJBAUzbC9P2EbkqxiQhIhxb1gpzOYpJObFr9H UI1RsWFLKzWCoPClToYIeq0i4JOdSIR1dJt8bSSMILIcGYZV3TxUAeBvAb6WyK3Uzsi/ smKcNGfqTiNKc+JG5pF3SpzuUF6UlKj8ix88IUmMfljWbcNHou5T6mp1nhk1cXhGS+zm Tueg== X-Forwarded-Encrypted: i=1; AHgh+Rpotv99t6srw89QHW1ZSkGXarWMlpbavj8gKKse0RjUkS28kcL5KT28q4wL+M564gsCdQaaZmshV7cCxns=@vger.kernel.org X-Gm-Message-State: AOJu0YzVAZQOmaRegEQ2X61sTgelEPMZfqJdcRh/OUFjN4XppWhIVic7 YEMfpG3VhILN+nby7w3kUucG/50q1sPtx4KGDEuFeT+iwGwW/U9O90BY X-Gm-Gg: AfdE7ckCh+mr1CA0LMUAWMrLLbq1U206FBRQbQJ+jq1KpY3mEfv3FB71RRmyPaSmoRK aKNgAfNCjyqSRr7zxA89sPXFs1ytDPj4NR16Bp2wqOi4AsntCs9WokEGaYhvhFlHIBx+9Ac56ur xpTtLNpj/jFfKP4AeDrSo41oI/KS7xAblRSlxehEl7GetwYPmhsOGAuifP1ZnfnF7XWuf96HDh6 +SCoXfB7tN0U8VBIoSagJwvP2p7hFrgtBXoAeG9ov96GiOeCUQZrhxN898TuCt0z3kLIJNr+f7D qujo1nwo3Huer+Fzc4JcGT/U735pcaa2Ccx/iTEF0TQ2pQRpvGYDcbjLSDzD1iUBy83N4uhqgLD ziSJry4XKm+5KQn1IXEIPiCJxeTZSVqU6aFon40fFA/Chy4vR7VEoyikj+7tpZDWXezdMYQSaQg 642Tm2hyG9DtXni9xXfPy4u0HIHya9xFxreh/odos= X-Received: by 2002:a2e:a547:0:b0:399:876b:3a9c with SMTP id 38308e7fff4ca-39acb69d932mr3596731fa.16.1782375916764; Thu, 25 Jun 2026 01:25:16 -0700 (PDT) Received: from grower.astra-academy.ru ([185.32.135.49]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-39ad31a81adsm566391fa.28.2026.06.25.01.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2026 01:25:16 -0700 (PDT) From: Alexander Martyniuk To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Alexander Martyniuk , Marcelo Ricardo Leitner , Xin Long , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Weiming Shi , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6.12 2/2] sctp: disable BH before calling udp_tunnel_xmit_skb() Date: Thu, 25 Jun 2026 11:24:42 +0300 Message-ID: <20260625082442.96390-3-alexevgmart@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260625082442.96390-1-alexevgmart@gmail.com> References: <20260625082442.96390-1-alexevgmart@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Xin Long commit 2cd7e6971fc2787408ceef17906ea152791448cf upstream. udp_tunnel_xmit_skb() / udp_tunnel6_xmit_skb() are expected to run with BH disabled. After commit 6f1a9140ecda ("add xmit recursion limit to tunnel xmit functions"), on the path: udp(6)_tunnel_xmit_skb() -> ip(6)tunnel_xmit() dev_xmit_recursion_inc()/dec() must stay balanced on the same CPU. Without local_bh_disable(), the context may move between CPUs, which can break the inc/dec pairing. This may lead to incorrect recursion level detection and cause packets to be dropped in ip(6)_tunnel_xmit() or __dev_queue_xmit(). Fix it by disabling BH around both IPv4 and IPv6 SCTP UDP xmit paths. In my testing, after enabling the SCTP over UDP: # ip net exec ha sysctl -w net.sctp.udp_port=9899 # ip net exec ha sysctl -w net.sctp.encap_port=9899 # ip net exec hb sysctl -w net.sctp.udp_port=9899 # ip net exec hb sysctl -w net.sctp.encap_port=9899 # ip net exec ha iperf3 -s - without this patch: # ip net exec hb iperf3 -c 192.168.0.1 --sctp [ 5] 0.00-10.00 sec 37.2 MBytes 31.2 Mbits/sec sender [ 5] 0.00-10.00 sec 37.1 MBytes 31.1 Mbits/sec receiver - with this patch: # ip net exec hb iperf3 -c 192.168.0.1 --sctp [ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec sender [ 5] 0.00-10.00 sec 3.14 GBytes 2.69 Gbits/sec receiver Fixes: 6f1a9140ecda ("net: add xmit recursion limit to tunnel xmit functions") Fixes: 046c052b475e ("sctp: enable udp tunneling socks") Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Link: https://patch.msgid.link/c874a8548221dcd56ff03c65ba75a74e6cf99119.1776017727.git.lucien.xin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Alexander Martyniuk --- net/sctp/ipv6.c | 2 ++ net/sctp/protocol.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index b4c321bad033..b45cc51dfc35 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -261,9 +261,11 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t) skb_set_inner_ipproto(skb, IPPROTO_SCTP); label = ip6_make_flowlabel(sock_net(sk), skb, fl6->flowlabel, true, fl6); + local_bh_disable(); udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, &fl6->daddr, tclass, ip6_dst_hoplimit(dst), label, sctp_sk(sk)->udp_port, t->encap_port, false); + local_bh_enable(); return 0; } diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 39ca5403d4d7..6ea15361088b 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1086,9 +1086,11 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t) skb_reset_inner_mac_header(skb); skb_reset_inner_transport_header(skb); skb_set_inner_ipproto(skb, IPPROTO_SCTP); + local_bh_disable(); udp_tunnel_xmit_skb(dst_rtable(dst), sk, skb, fl4->saddr, fl4->daddr, dscp, ip4_dst_hoplimit(dst), df, sctp_sk(sk)->udp_port, t->encap_port, false, false); + local_bh_enable(); return 0; } -- 2.43.0