From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062958; b=B3GH9Wcs5NF2jpBPMvNR3Sa3kL4kYrt3AkzLfFCnEUGcAl3x1cP78lz1LiuoSrJzKkYh uGtMrrorSoVp6W3zTvFcEv7O/H2wQu4Ki4jprqY02usJG2qLKuPw3q0bp3AB280D3Kw3P 9o1tXqxnt4FOdclZqV3e0fm4E87iT+jz+aF1tWZzFmSNi9NI9TPJ+/GPb6QEIaNPYIPux HmzThpOdgwQ9LR+QN1itnsv1S4+z2wLkZznuOmg9latUoz6CeZMh5q5Y/YjRO5pYJn3gK QqxbLAdr7JSeakHfbg5XPiaedIgzqUW4StwXcxCFqNIrDzo3PfrV8Vi+q1mHHmh48SQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062958; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=XcUkNkR5LdYqoiyx1GUgYSWOWv9rS3Uu1u1zxHtjvWY=; b=LeDfnJUQZ6KjyUAEOpxcbojQALVNR1YlKLCuoJxpjbykUzeQkcFmjXxG/9gBkhQwnc/J SLfw/RusoXzcGR0NPbKiTs5EN0Dm8JgeBAN2EJ7YXScu3ZsW1ocVp+eSD9soBYtxhjOGq FBWwmNPbq6c1PE2N6wqPYuZmyB3pHJp44aqhY697iPIRRMaV36+a9fhy6Og0sZaEE8v+T TpfDO+YPFT78JgB1OfS/Sgl2lRF+rVgAVg8X2SJgPGFD+hri6zCphJb/NaLAOi3iYLGXw wZ2phHfuSWVTnfoXqk4pluab4Hz2o2Q9oJrD+NbpgH6J+56bv/tlHaLD8WA+HHJ678w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass header.d=trailofbits.com header.i=@trailofbits.com header.a=rsa-sha256 header.s=google header.b=C7ZU6GOb; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (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 918E9606A32C for ; Mon, 30 Nov 2026 18:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 918E9606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.a=rsa-sha256 header.s=google header.b=C7ZU6GOb Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1b589050416so4353362c88.0 for ; Mon, 30 Nov 2026 10:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1796062957; x=1796667757; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XcUkNkR5LdYqoiyx1GUgYSWOWv9rS3Uu1u1zxHtjvWY=; b=C7ZU6GObIRoIpcwGMNORoqurtMsUB9+o/EfKO4DKIts0OHj4imw9OMnxxX076UWyER YALaQxB4O5dGwDNFK8YLqbYqr2NAPGJWWVV9c0TS66H4c3wwwnWugbKMqsPsfjD5w3uo EmKGU4gU6PQLZnITLx45QSMYWfDWVYqoYmLaaMSHhszmYe9OKtKiCqv1iL9td7FSn7H1 o7SEMyMMmyJ/qk5Mty8OV2Y38hz9EPLe10iySjMa015ebre2eV6GlPJT0JLtisL0ImzF it144ZLSe9/RUJbyNbK53LuyHt3Bv50r2iQ64Qtnj6tgJFEplhn3KZhAYTWKIGx+4/Hs vY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796062957; x=1796667757; h=content-transfer-encoding:content-type: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 :content-type; bh=XcUkNkR5LdYqoiyx1GUgYSWOWv9rS3Uu1u1zxHtjvWY=; b=u3AuNAnH+h3HkcR/IQkwsJMGd6WFTNUUhLraK2e6P4soPgX6sTwyqZk5xagnDmhplv GrIfvxF5l8JFYXAwYRlAZ3BSeiJ2YW0enpwsjcQo5TTjL8izsDSun4yRgWToHqHY+ael WM4Cm7/+6ShhhrJA8yqk5XalcJ9U1XDasA+DIxhx6vC7VU9ZneOX+fBwR1SusYCNGAT7 fkAYsMSn3wp3W+Re4PBfrzH5QnJRZtkPMHrLzXwpHGill/BViBlZYV1i6NHEHOCCQO21 TA9V6cE5ce9G7aGQhzJOxgNPP03YKSa0RBMq3PWjm4Q4s/eHGH2qLQjZtbDmfc7AkQ4x pE+w== X-Forwarded-Encrypted: i=1; AL+hErGcL2URw3jUMXzr+HkZ/su9WpLi7TnM2rzcn1GI7xPPH4/NNuQZpES1z4ufxzZ4zzjnIQrv1zU=@vger.kernel.org X-Gm-Message-State: APuU4Z9aN1CeJLm49l00UGl8vsjb23in27QkL2MFL6RtwSkv0q9TLc91 pDAZZfAknbTBukDBk3s1zq/SwOqF9CNUZ8RWPvlpdE3XEg09p/d9sibetHqNPhKF+6M= X-Gm-Gg: AZFdTZeqCZG1l1/IbCSfnbuCeisCX8Haj+6lbtvow02i1t6aAL0D19jC9mYyt0H3VIj zQ6o5gm8EpcCPWdEhR2SFwerjblwzdhjn4LtX/OtW4I1dhoZ/7IgTjcRcDKTFhmbCjcpvYFKnqV TIymUP+PeiEvTfcpOTcPFnUCDV2JP+nIDD1ZiB9HxYp5n6duFSibEXiOZXsnirhCHMZVIFPU+Oo kosLHAGEFONka+vDxN6Sl3QgJHp3SGcIA97LSiRJqIe/6R3J25ZLIasyCDtKmEJEklKn0EKjg9X 9flxHpRM9LrfBVU2HptCqJmYZKvBTTKNLQQZcbRp1vehx8v6BgibCbWWZXMzz/qh9bxJPfTeHIG iis5K8DSAWf2yjn0TZfc7NPskne6yyBqjLcyCMVnivwaSBiRrTy895TvfivakX//jMgAITtsJe2 We576jnubwilsbTDdv8dwdqWQckVYWH1Zp9LwU10U7V/g/SkorPedxLgjmO9W7OdwcN3hZfkNoj ZXKJetT79FbC1/KT6ZGA9dI0SYy3hwnSBTCsifA3tb6ENLOV0pmQ4+pC8UBWNqtYiF7kPbKAN98 PA+UmXD3uUp9UyUWNRrCBZ0NiNxeeE2fbbYocbn5YDYriMqUZYAy4YEkLBCdKz9lKC5kGf+8uZo 02MdBODRWGaKxSnm2IsGNSQWDKw== X-Received: by 2002:a05:701a:ccca:20b0:1b5:71bb:6800 with SMTP id a92af1059eb24-1b571bb698bmr23173320c88.3.1796062956357; Mon, 30 Nov 2026 10:22:36 -0800 (PST) Received: from localhost.localdomain ([2603:8003:6d40:6669:69ad:25af:f892:8dbd]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm79805376c88.8.2026.11.30.10.22.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 10:22:35 -0800 (PST) From: Artem Dinaburg To: stable@vger.kernel.org Cc: Sasha Levin , davem@davemloft.net, edumazet@kernel.org, horms@kernel.org, jhs@mojatatu.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, toke@toke.dk, victor@mojatatu.com Subject: [PATCH 5.10.y] net/sched: codel: bound the dropping loop per dequeue call Date: Mon, 30 Nov 2026 13:22:20 -0500 Message-ID: <20261130182220.37645-5-artem@trailofbits.com> In-Reply-To: <2026-11-26-1-daily-reply-0010@kernel.org> References: <2026-11-26-1-daily-reply-0010@kernel.org> 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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit From: Jamal Hadi Salim Date: Sat, 12 Sep 2026 14:08:30 -0400 [ Upstream commit 7f4a5ec6258fd7c92633ec4b0493fc51166d9398 ] The CoDel control law schedules the next drop one interval/sqrt(count) after the previous drop, using the configured interval (codel_params.interval). For very small intervals the scheduled step rounds down to zero, so the dropping loop in codel_dequeue() never advances and drains the entire backlog under the qdisc lock in one call - an unprivileged user can trigger a soft lockup this way. Fix in the shared codel code used by both codel and fq_codel: 1. Make the control-law step at least 1 tick so the dropping loop always moves forward. 2. Cap the dropping loop at CODEL_MAX_DROPS_PER_DEQUEUE (256) drops per codel_dequeue() call, resyncing drop_next to now when the cap is hit: the catch-up owed to the loop grows with the idle gap and the backlog, which no interval threshold can bound. This is a deliberate behaviour change after long idle gaps. The cap applies to fq_codel (4b549a2ef4be) and the mac80211 TXQ path (fixed interval, cap only). The target sojourn delay (codel_params.target) is not validated: it does not feed the control law, so a sub-tick value is aggressive rather than deadlock-prone. Conditions to recreate the bug: - tc qdisc add dev lo root handle 1: tbf rate 1kbit burst 2kb limit 1000000 - tc qdisc add dev lo parent 1:1 handle 10: codel interval 2us target 1ms noecn limit 1000000 (same for fq_codel) - unpatched kernel: tc accepts it; a UDP flood under the 1kbit tbf soft-lockups (watchdog: BUG: soft lockup) while one codel_dequeue() call drops the backlog under the qdisc lock - patched kernel: same setup, at most 256 drops per dequeue call, no soft lockup Testing: claim reproducer and interval 2us/3us variants run clean; tdc qdisc category passes (see the selftests patch). Fixes: 76e3cc126bb2 ("codel: Controlled Delay AQM") Reported-by: Vega Reviewed-by: Eric Dumazet Tested-by: Victor Nogueira Signed-off-by: Jamal Hadi Salim Reviewed-by: Toke Høiland-Jørgensen Link: https://patch.msgid.link/QDISC-1L5H.v1.20260912080102@mojatatu.com Signed-off-by: Jakub Kicinski [ Backport to 5.10.y: context adjusted in codel_dequeue(); 5.10.y lacks the upstream WRITE_ONCE() annotations of the codel state. The added code is unchanged. ] Signed-off-by: Artem Dinaburg --- Hi, This is the 5.10.y backport Sasha asked for. It fixes CVE-2026-98427. The diff is the same as the 6.18.y one apart from line offsets. Compile-tested on 5.10.275 (sch_codel, sch_fq_codel and mac80211). I used an LLM to help prepare this backport and reviewed the result. Thanks, Artem Dinaburg include/net/codel.h | 5 +++++ include/net/codel_impl.h | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/net/codel.h b/include/net/codel.h index a6e428f80135..025e1c6abec1 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -137,6 +137,11 @@ struct codel_vars { /* needed shift to get a Q0.32 number from rec_inv_sqrt */ #define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS) +/* Cap on drops per codel_dequeue() call: the loop's work depends on the + * idle gap and backlog, both outside our control; resync when exceeded. + */ +#define CODEL_MAX_DROPS_PER_DEQUEUE 256 + /** * struct codel_stats - contains codel shared variables and stats * @maxpacket: largest packet we've seen so far diff --git a/include/net/codel_impl.h b/include/net/codel_impl.h index f7615981d39e..6e9c91b8c56f 100644 --- a/include/net/codel_impl.h +++ b/include/net/codel_impl.h @@ -89,12 +89,17 @@ static void codel_Newton_step(struct codel_vars *vars) * CoDel control_law is t + interval/sqrt(count) * We maintain in rec_inv_sqrt the reciprocal value of sqrt(count) to avoid * both sqrt() and divide operation. + * + * Clamp the increment to at least 1 tick: a very small interval (or a + * large count) can truncate it to zero, stalling the dropping loop. */ static codel_time_t codel_control_law(codel_time_t t, codel_time_t interval, u32 rec_inv_sqrt) { - return t + reciprocal_scale(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT); + return t + max_t(u32, 1, + reciprocal_scale(interval, + rec_inv_sqrt << REC_INV_SQRT_SHIFT)); } static bool codel_should_drop(const struct sk_buff *skb, @@ -150,6 +155,7 @@ static struct sk_buff *codel_dequeue(void *ctx, codel_skb_dequeue_t dequeue_func) { struct sk_buff *skb = dequeue_func(vars, ctx); + unsigned int drops = 0; codel_time_t now; bool drop; @@ -176,6 +182,14 @@ static struct sk_buff *codel_dequeue(void *ctx, */ while (vars->dropping && codel_time_after_eq(now, vars->drop_next)) { + if (++drops > CODEL_MAX_DROPS_PER_DEQUEUE) { + /* fell far behind the schedule */ + WRITE_ONCE(vars->drop_next, + codel_control_law(now, + params->interval, + vars->rec_inv_sqrt)); + break; + } vars->count++; /* dont care of possible wrap * since there is no more divide */