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 BF9441CC14B; Wed, 6 Nov 2024 13:17:06 +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=1730899026; cv=none; b=QJBWg6BgoaL+V4xrQ0dEnyBONb0C0oO2uCuUrTFqzZ4ybn2OMrMw2voUF0nU6VOis2taEdmYMab3AA6HmnZwPjg5uawEST6t9oERZxdO8LmWHwrob6YMa/PRa3lhiCxwCgAbWdPZXDOHnB6sXZB9Yq0n92DUBfTbAjcmN0MlcxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730899026; c=relaxed/simple; bh=Cn3c4cwij1IfXRgAF1bbdsvrVaa0GTBXL5Lrf/YpUnw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iz6eLpFVjISyCQJqgZI+/Eb6WwhDy+q7d3sU/ou8Jdfb4nJ4FPzvueRLQxGZnoW9YknhVs1rmTWAaoqZbhlueDCeCKbh91OowPBl38RLMuyi6kRLnvxU491r2rm+0jiX7bUwCbFldBtjl+RzYqvFORq8IkEfAkJmMo/KDRPaGzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vSZQIZZQ; 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="vSZQIZZQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45D2EC4CED5; Wed, 6 Nov 2024 13:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730899026; bh=Cn3c4cwij1IfXRgAF1bbdsvrVaa0GTBXL5Lrf/YpUnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vSZQIZZQM4F3BnIHQt6ATMuVgA0/0gLhnweACpVQLSdikmvcfOxoy7A3Wp5Dshb5f Ti+wFoigMMvdFA7Ysc6TmiC9CZxzDuwhCdFlgpQ1UO+DD+C5lWGEasiiTJy7C8I94l yo0dBuLPS01CDZYU/4LeoVMyoPYeeYt1Cz3p2K1Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Budimir Markovic , Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 437/462] net/sched: stop qdisc_tree_reduce_backlog on TC_H_ROOT Date: Wed, 6 Nov 2024 13:05:30 +0100 Message-ID: <20241106120342.297207814@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120331.497003148@linuxfoundation.org> References: <20241106120331.497003148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pedro Tammela [ Upstream commit 2e95c4384438adeaa772caa560244b1a2efef816 ] In qdisc_tree_reduce_backlog, Qdiscs with major handle ffff: are assumed to be either root or ingress. This assumption is bogus since it's valid to create egress qdiscs with major handle ffff: Budimir Markovic found that for qdiscs like DRR that maintain an active class list, it will cause a UAF with a dangling class pointer. In 066a3b5b2346, the concern was to avoid iterating over the ingress qdisc since its parent is itself. The proper fix is to stop when parent TC_H_ROOT is reached because the only way to retrieve ingress is when a hierarchy which does not contain a ffff: major handle call into qdisc_lookup with TC_H_MAJ(TC_H_ROOT). In the scenario where major ffff: is an egress qdisc in any of the tree levels, the updates will also propagate to TC_H_ROOT, which then the iteration must stop. Fixes: 066a3b5b2346 ("[NET_SCHED] sch_api: fix qdisc_tree_decrease_qlen() loop") Reported-by: Budimir Markovic Suggested-by: Jamal Hadi Salim Tested-by: Victor Nogueira Signed-off-by: Pedro Tammela Signed-off-by: Jamal Hadi Salim net/sched/sch_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Horman Link: https://patch.msgid.link/20241024165547.418570-1-jhs@mojatatu.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 069d0d8a89397..b8dc03a7487e3 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -770,7 +770,7 @@ void qdisc_tree_reduce_backlog(struct Qdisc *sch, int n, int len) drops = max_t(int, n, 0); rcu_read_lock(); while ((parentid = sch->parent)) { - if (TC_H_MAJ(parentid) == TC_H_MAJ(TC_H_INGRESS)) + if (parentid == TC_H_ROOT) break; if (sch->flags & TCQ_F_NOPARENT) -- 2.43.0