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 8725C253F31; Tue, 29 Apr 2025 17:55:55 +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=1745949355; cv=none; b=Bd3DyCjoqLZzGRe1GSB+emsoqq+/UD9HpGO4fJVFHjf2L1Ef3eKuywNPgAhaRV12nDweoAUzVzVOzEYSMOx3hNeCQeS5jqMljfa/upCTC+cgfLLUKZIrNsaGMfogB5Gds1Wi0v+nLGx8tgtpfHuVav9MSAOFK/9gFx8b/ejv9EM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745949355; c=relaxed/simple; bh=TLkvkQuZ35elOrudNTc31In3XvdKNzm2h4OZbdxpGwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=akwP9J/WMmJI+MHYB5qFT3rOlJmOzo1pR4cmWtOwCUg5Kq97CfO16D/Bhl4bzIZqPub4dCaCu8BxJNfaRMLUUIz77j5H36dVJ/C48KhcI3K3yRABytROo9Xneq6kwySGDUDeXuKWyDs2LISmmcD680eJObQIZA5F0djhV1JUSNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uWNLIdWr; 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="uWNLIdWr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABC03C4CEE3; Tue, 29 Apr 2025 17:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745949355; bh=TLkvkQuZ35elOrudNTc31In3XvdKNzm2h4OZbdxpGwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWNLIdWrPiMrTAvbKMnG2ZJ9ANleohH5Yd+tEsVhK4mLc1zYSsC971ZBQ598Ei24U tS43YF5mNEJAj+lnfb00vdu3ZEbXSS3ufJD+jRCEeFLvIFuY2d09mm5knAa7di0ajc h2khsImjamWt9KklaeEeeXyWSmCnFZpj2GV/zwQs= 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 5.15 293/373] net_sched: hfsc: Fix a potential UAF in hfsc_dequeue() too Date: Tue, 29 Apr 2025 18:42:50 +0200 Message-ID: <20250429161135.166997835@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@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 5.15-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 ea42708aac7e2..85c296664c9ab 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1644,10 +1644,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