From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062952; b=OyTXGQVWV7gMf2uDaKs/DxqFxLEdPifKc5jtGIPSWOF3HdKOLRGIlmgSj/15fvx79RkR 43Qpe3eaZUXw+Yp5CIUzOwmWWFM0xkWJYtevo2D3BS3hHCWJTPzykxdluTAlGyd619N+4 slX+GuE42u/VNVzK8Ds0zwyOmE+dxyfu02YUZTnoQCgixcjz2fJw0fZloBhhIgjKwULCx Xc9C5s1MjjUlnvhZj7Wp5/OtM/zX+QepLw0q6DGemrh+oL9/gexZ7lWqktquYpRmpxnBe 3t+eZBrHmLBgAXrfphdzAqB7fGnkZDwQHHAleZzEv0fTFKgSDovNDi5HdvDlEPUe1yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062952; 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=BNFvvbj5wZVWBhwi7MHipMPxrUNpPPy0nKLPIUh5zxA=; b=LSZESY6e2AY6ZuLO/XLMimv+gxfmFI44ozf9NbAbKDC38YpN3V4Di635pWcTYuISVOtN /Jm4+oxyfCyfoS676mjf9YXziEHRYgOMSYlnLAVRoZ51jSF8h0NOxs9HuU5w54J1UL3yM rJ53n/IGsig4g7JwIrCjeW7mWFAkB5u7MNahhSUjpfIH1Olbg3PZJM5otYm2ijhpjZaip cdZ3GsU932j49ZMyCWt/hJOpLaHp7mlL0r4b3PdT/dQA2HjT7waqCwDgfN3oXy9wIW7tH rwatpzY/mgO899Qf9WXpA+os1a+eJ+h2xxZ4IqMRwuxPk4DalU07QmdQlaUltA4HXlg== 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=hBNtvNbY; arc=none smtp.remote-ip=74.125.82.47 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (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 A2C4C606A325 for ; Mon, 30 Nov 2026 18:22:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2C4C606A325 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=hBNtvNbY Received: by mail-dl1-f47.google.com with SMTP id a92af1059eb24-1b59e19b33bso398303c88.1 for ; Mon, 30 Nov 2026 10:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1796062951; x=1796667751; 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=BNFvvbj5wZVWBhwi7MHipMPxrUNpPPy0nKLPIUh5zxA=; b=hBNtvNbYdeqLiFkkxV1Vw3kLNW/sbJVCkZNwFDX7JeSzHsmA6H0kQwriWJeXeeqBXM 6dwlv+uEeY/X1KmRSVugp1Zd9aO1OPNytUkkAFMjpEbKR8tj2K7h9KKi0LeFXWyprL4o pQ2krfgK1mAavEgncLV2w2EuQSnwd+YrA8LvYxzYZI6oRDliKO2iPoW0jxBs/HiaOZCR SNz/B1HVkl2+Vo7/dY7cRVxAzArR+axXsm+bzdGiNRUwmky/BPexBIrnk4rK1Om4nzwx 7R/4S7Vaz4EtzbB9WDas5rEtmCAerWpkthN7LWtsmrFo7a3PKsYSwkEzVEaLhk3XN7CQ muUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796062951; x=1796667751; 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=BNFvvbj5wZVWBhwi7MHipMPxrUNpPPy0nKLPIUh5zxA=; b=V5wes0o3eYsalKRjmDjYUuA5O61Z5b4C9ey44oAUxPh3e8n3VZgTTA61giIF+zLE2r EpVCFDYQTkcVmbADT8M7mE0g9Qilfg43wDtodGavq6N8OS6Fz3xfeV9ALRArq0uAaENr IfI9T0t7Igk2gViG4671BG/aNdD4wcOenn6iOE/R1z1Of/Af+SsKlbuExFJUmibaT/8p koY8TDKWWYjWJKWK4IDcWnmW8jLkWQ1YvO1UceoWyGjGzLZpBxvhWqkFf8B04nDezR0n x50l1wAOwFto9lzpOwQu2R3o0U0BD+IrSwPSxpw/BQ+m+15J8JqHbxHqBlFkzjl604KK slAA== X-Forwarded-Encrypted: i=1; AL+hErFH8Yg4YywZn3JatmFa9TVl1Y0VLKc21ypL+dM94A11THIZAkAX6H/VWlxyS0YY79ssrs7n6Ts=@vger.kernel.org X-Gm-Message-State: APuU4Z9aaz8aKdcEQqyRy0Njky9u8ZM9NlIu6q7TwdF8xQHN8wjkTkGJ MZxuEVD0Va5jLdk4SrQ/1MD8gXlWQdFrqsJbsJ1WXPrNLUaDZh/9NsRw6q8ns8+SNT4= X-Gm-Gg: AZFdTZdOw7JglAaAZ3tu4XaEe5DxXnefFBV+igDa10Guu5Si7QhNuRf1ggnelQZ07hu 60B7iFZFSO7ctUl4d6PxDKtlBkkllyU/O8C5VkqZk3Xu+4jPsa8ilDP74S05Es7aAW7e5vXkts6 AcAX3HwsP/aZYvitWsBovNLPBEn4+DbwqNCVA8NtZSGkYzX4c4ernvM/qrPF32NNSONnuhH/CvL pbAbSuBa/L/J3dvjXsypstDfGDCj7n2jMM1d1vvKHZ5QKoSLmS/KI+TPRB+LOjLpE0izMeQDYjS GOxIe7Fy8nh4BNOxgpIyrRxMDU/sbgyWZDSUSX2ltOW3FfC0lBdFtgVBdbDkz+cK/CXYvsvFtLr oPpgcahtjrhN1L1Q/Q5X01hhg2OWME+rU2PSLzp6j43eYBb5MqET7FE3cfnya8ycy64Jo2Zepcx /QYL32fFzR5NeDDc6TYS/xKgViJ4XdtSOJP5Tv0OKOhDRqh7Ze6DvJCCjiEw+ySz92AZn+WlPuX t4pdfb5uOUbeB6jnD1olp6ulBUGbRNSQN9+Qqz0QHmDxTFITPMCgu2Hfl/4g9kEFImzExewlN6d m5juWUU1eWNm5/44FFdG0+bufrAe/etGUZJ2xOtIdNDdtBwFTnRdrPsQMWGlCLYi9p6S8uE11IK lhEzG8uLvdFTebbbIMudobsOrDw== X-Received: by 2002:a05:7022:1587:b0:1b5:a243:198a with SMTP id a92af1059eb24-1b5a24319bamr11225009c88.18.1796062950589; Mon, 30 Nov 2026 10:22:30 -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.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 10:22:30 -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 6.6.y] net/sched: codel: bound the dropping loop per dequeue call Date: Mon, 30 Nov 2026 13:22:17 -0500 Message-ID: <20261130182220.37645-2-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 6.6.y: context adjusted in codel_dequeue(); 6.6.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 6.6.y backport Sasha asked for. It fixes CVE-2026-98427. The diff is the same as the 6.18.y one. Compile-tested on 6.6.163 (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 aa80f744826c..183d43c2bd43 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -140,6 +140,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 b2c359c6dd1b..4d5e471472f6 100644 --- a/include/net/codel_impl.h +++ b/include/net/codel_impl.h @@ -93,12 +93,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, @@ -154,6 +159,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; @@ -180,6 +186,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 */