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 64DE933A6E2; Mon, 13 Apr 2026 16:56:51 +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=1776099411; cv=none; b=WZ/zaL26U4+DKJq6wScXR27GbBdlWqf1RN63UNJ4OAr1PlE4eEA4z1UZz4WlzzZDi66c0G4GBxLdK1rkk8n7oafyWhx7QAtKEuQqt98Nt00TYh68jWN1ZSGjzScEeS48mMrV+JpeSa7staENBbB6TJlf9Dd/sczTb4PlAVNJ5QM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099411; c=relaxed/simple; bh=mlCngU1p4fI1eN5yXHp9U+sb1eJNoaoYJ4u5HGs00V8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTRDoty8h/6N+bGDIJpkSB/394sMOKIYzTA7s5xIlqgc61xdeRhUf/+Mec89SVFuf6NaL1u6BQp9AL2Qb1DCaTHnwKqnAtpvyqM2lnNvZv7Ezqd1VRxbcwNexNjSyw64aSGbux988PN+FvLdkUrM53BUbLvk7vIZCbgT3lKYc+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v/5on+So; 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="v/5on+So" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEC45C2BCB0; Mon, 13 Apr 2026 16:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776099411; bh=mlCngU1p4fI1eN5yXHp9U+sb1eJNoaoYJ4u5HGs00V8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/5on+SoJ0q56VV/zXRQOh0yfjtILEEEhqs7BKS59cfyLe8JhGuM4kOiIL9et9ZMV by9Ym7pWD2Du3gUNqKBQ/B5L8yzpOUilQtTKCWM8kojcOUuK8cdIyvpaBn7wbnw93S U2Sf91tBjklCTZzPa9SlN+cZ2z0TTgRa6ND0ESik= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Weiming Shi , Xiang Mei , Jamal Hadi Salim , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 330/491] net/sched: sch_hfsc: fix divide-by-zero in rtsc_min() Date: Mon, 13 Apr 2026 17:59:35 +0200 Message-ID: <20260413155831.396661494@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@linuxfoundation.org> User-Agent: quilt/0.69 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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei [ Upstream commit 4576100b8cd03118267513cafacde164b498b322 ] m2sm() converts a u32 slope to a u64 scaled value. For large inputs (e.g. m1=4000000000), the result can reach 2^32. rtsc_min() stores the difference of two such u64 values in a u32 variable `dsm` and uses it as a divisor. When the difference is exactly 2^32 the truncation yields zero, causing a divide-by-zero oops in the concave-curve intersection path: Oops: divide error: 0000 RIP: 0010:rtsc_min (net/sched/sch_hfsc.c:601) Call Trace: init_ed (net/sched/sch_hfsc.c:629) hfsc_enqueue (net/sched/sch_hfsc.c:1569) [...] Widen `dsm` to u64 and replace do_div() with div64_u64() so the full difference is preserved. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Weiming Shi Signed-off-by: Xiang Mei Acked-by: Jamal Hadi Salim Link: https://patch.msgid.link/20260326204310.1549327-1-xmei5@asu.edu Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_hfsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 25360061ad288..3a271ad16443b 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -556,7 +556,7 @@ static void rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y) { u64 y1, y2, dx, dy; - u32 dsm; + u64 dsm; if (isc->sm1 <= isc->sm2) { /* service curve is convex */ @@ -599,7 +599,7 @@ rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y) */ dx = (y1 - y) << SM_SHIFT; dsm = isc->sm1 - isc->sm2; - do_div(dx, dsm); + dx = div64_u64(dx, dsm); /* * check if (x, y1) belongs to the 1st segment of rtsc. * if so, add the offset. -- 2.53.0