From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4EFA1A5B9D; Tue, 17 Jun 2025 16:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750178400; cv=none; b=EDeFdNEEInHDa98p9uLZ3+JB+64Ml8aOLrUV+NpxOznB0DEQZ/i2RVuIu0upMIzZWpinrJmAvngaWTpEzyL3EvbreFCHwqyLxoPU7DskOf54ur96c3nv/pLJgLsGvr/aszAMBI9bNfmUUQH8halp9LywjyB9H9/y8Duw/AehofI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750178400; c=relaxed/simple; bh=NJkGPvkum+iRq1lTpsI2qF3EBNCbcexuP8SFmfKG8Gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dODyooW0wVS6qX+FNnSPO9PU1d8kyJYu0E0o2enlA+4Ok5xSKvmsLnEU+aiG/lMluZ3YMu1/Qhsvpm0bBocaFYcGriVZsZsv6FE16GNwAdyA/oWd2PbcLPkpUBLn45p1/Un778ajQi0BpF2HUgMGNvKHPjWj/50Kfu/VTKZYDY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=f5Iy6tQv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="f5Iy6tQv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C98ECC4CEE3; Tue, 17 Jun 2025 16:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750178400; bh=NJkGPvkum+iRq1lTpsI2qF3EBNCbcexuP8SFmfKG8Gg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5Iy6tQvQUP4E78imMhj2nsKVXfmctSISUZIW3JADlbPLXvuttkq1Ii+yjT9tHiDe 9dR3JgAvWn9b3Pyo9jUjsMgpTfwlTRp0z0N6ruD927vHasrtM/6f7yBPFBP/3ANjIJ U72t3qZzirBMh8HE7WJy2sTpKzS7w+8mgCApbm9Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gerrard Tai , Eric Dumazet , Zhengchao Shao , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 467/512] net_sched: tbf: fix a race in tbf_change() Date: Tue, 17 Jun 2025 17:27:13 +0200 Message-ID: <20250617152438.501085340@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152419.512865572@linuxfoundation.org> References: <20250617152419.512865572@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 43eb466041216d25dedaef1c383ad7bd89929cbc ] Gerrard Tai reported a race condition in TBF, whenever SFQ perturb timer fires at the wrong time. The race is as follows: CPU 0 CPU 1 [1]: lock root [2]: qdisc_tree_flush_backlog() [3]: unlock root | | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() | [4]: qdisc_put() This can be abused to underflow a parent's qlen. Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock. Fixes: b05972f01e7d ("net: sched: tbf: don't call qdisc_put() while holding tree lock") Reported-by: Gerrard Tai Suggested-by: Gerrard Tai Signed-off-by: Eric Dumazet Cc: Zhengchao Shao Link: https://patch.msgid.link/20250611111515.1983366-4-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_tbf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index dc26b22d53c73..4c977f049670a 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -452,7 +452,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt, sch_tree_lock(sch); if (child) { - qdisc_tree_flush_backlog(q->qdisc); + qdisc_purge_queue(q->qdisc); old = q->qdisc; q->qdisc = child; } -- 2.39.5