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 344D0254850; Tue, 29 Apr 2025 18:02:58 +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=1745949778; cv=none; b=jmI8wkqM/0BQtnoooj7a8R66onVacNNzwwC685y/Wqph3OOfAyPJ+ABXROqHbPUxYA9jjNprg2hXhmDBfzddyEm9Mi1W+Q3wPMquPLa/JqV9O/tycVXKJN0/rkpvL9Oyh5LH7BVVicum+QIooIPttCQyiiKK6YCAdtA3/BQTCMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745949778; c=relaxed/simple; bh=pUsKOofhS2JMBd2qrQucH6jCAEFRn/9y2Ao9XAwOyPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tFoweiN4KT+ku3OHkYrlKjQk5iEyOw6qtJhZSV/9bQP45OhyHIyrTTbsi7V7ZHP5uTN6rBPhmoRsokdvlYJ5OYv1bl+FrUrZfiqssjxHqao7hG0BQRAr1oye0yXKsZRtxHdqUC/jY9Z32OJRZPvMkU7gnMFc18pLM6pHvEm96f8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0tGOITI4; 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="0tGOITI4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983ADC4CEE3; Tue, 29 Apr 2025 18:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745949778; bh=pUsKOofhS2JMBd2qrQucH6jCAEFRn/9y2Ao9XAwOyPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0tGOITI456D+1Nj/h1qkFS9M4KZewzG7egYqRaild9HGPoln6nsEB7D6052pUno6h hnnvnwbWCYRdD10xiOi3qLcqFr96rg2IcV1T5/UySeL8c7Ibh/ghsHwA2jpkBsqv79 56QFkZIzoMj8moyOncez98oWiZzT7JLwJEpDHYdo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gerrard Tai , Cong Wang , Jamal Hadi Salim , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 053/167] net_sched: hfsc: Fix a potential UAF in hfsc_dequeue() too Date: Tue, 29 Apr 2025 18:42:41 +0200 Message-ID: <20250429161053.911686448@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161051.743239894@linuxfoundation.org> References: <20250429161051.743239894@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit 6ccbda44e2cc3d26fd22af54c650d6d5d801addf ] Similarly to the previous patch, we need to safe guard hfsc_dequeue() too. But for this one, we don't have a reliable reproducer. Fixes: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 ("Linux-2.6.12-rc2") Reported-by: Gerrard Tai Signed-off-by: Cong Wang Reviewed-by: Jamal Hadi Salim Link: https://patch.msgid.link/20250417184732.943057-3-xiyou.wangcong@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_hfsc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 901bc93ece5aa..dbed490aafd3d 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1636,10 +1636,16 @@ hfsc_dequeue(struct Qdisc *sch) if (cl->qdisc->q.qlen != 0) { /* update ed */ next_len = qdisc_peek_len(cl->qdisc); - if (realtime) - update_ed(cl, next_len); - else - update_d(cl, next_len); + /* Check queue length again since some qdisc implementations + * (e.g., netem/codel) might empty the queue during the peek + * operation. + */ + if (cl->qdisc->q.qlen != 0) { + if (realtime) + update_ed(cl, next_len); + else + update_d(cl, next_len); + } } else { /* the class becomes passive */ eltree_remove(cl); -- 2.39.5