From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382442; b=qD8M3rFDmF/BvAln1N9HefIVpB6l50DRFprXdpXoiyQNJXY58zeqa0AbLGnRICSFpZmN xVFaZHP8+WcrhdkrfTM7LHd6j/3H4cgtDXrzfpSViCUhVdlm5Ky15wZepXbVZOTT01NY4 dWlX3oxkI6WgIANdx2TsBO8cY+OSy0GMgA3cG5+QaHlhzXAWxSxxD2bTOu+R62QT/q/pU Eyy4Zdnhfc9yRUiGJW0XC+sr1MWgV1uS1B2aKk7Va+Gya8rqm8ryLYRQf/DAUukWGBR3Y v0POxUHy8HQfIzSmNU9xVwAgzLTeR0tGT9C9dozMtQTMpEogmmHVYLVi4NUJ/QQr5LA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382442; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=O94eeq18nIXVjj7HK2zbeJZNr7/NVk/gEJxj+msGmiU=; b=vG5umRhrt3+ZklB/OHa0Wu+eZ6qCegvx9FQ3BLbhpPHllc7Mk761YYp11IH8PQG3KUq8 6grcEHsSm33gxTBWnOhQjSyJrkobZBk2SGGGoEi3ufXB/5hvFX5zAYwB0qoE+Ir1du8um iesXPb9oJOnfp0QJNVBwvr3/HNSpGIRX2TtLy/6Q67jznhR/LQbdPhcV+UNFGhHWbkbQV ZpwBWBR6BkyQvjFm0gGWdmN9Je2cihs1dlNgwEQabGGyf56wthB8AhoKaWXYmRiJ3Tf9X lSzMM8fOa8Ko20NUDhRbfaNqGAPU2d3AQ7L/soUdh6G8IiXymTMBp8+E2gxUOr6+wGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0T0D+GGm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC6F0606A33C; Fri, 4 Dec 2026 11:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0T0D+GGm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36F161F000CE; Fri, 4 Dec 2026 11:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382442; bh=O94eeq18nIXVjj7HK2zbeJZNr7/NVk/gEJxj+msGmiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0T0D+GGm+dUY22neipop+fveR9Gf7r6cdEJpMtZfD434Td+MCGj99ziGPxtxk6TpX B28PdwjIO8B3iWTlse3/C+6T8x/ySDPaDDVF6zcwhJ5PjxnSUUlQdjmfjRJ524bwrv 7sVmfpuomvs+4bx5RQ9843evRbZdv8Zn9SdduL6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alex Kazinsky , Tejun Heo , Jens Axboe Subject: [PATCH 6.18 404/703] blk-iocost: Fix overflow in donation weight calculation Date: Fri, 4 Dec 2026 19:05:03 +0900 Message-ID: <20261204100638.582777266@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alex Kazinsky commit a56d5a485be4a9d52f0d7b3ed0dc3521367cb986 upstream. hweight_after_donation() receives usage as u32, clamped to the range [1, WEIGHT_ONE]. Since WEIGHT_ONE is 1 << 16, multiplying it by usage equal to WEIGHT_ONE wraps the 32-bit unsigned result to zero before it is passed to div64_s64(). This makes new_hwi zero, which is then clamped to 1, incorrectly reducing the cgroup's in-use weight to the minimum. Cast WEIGHT_ONE to s64 before multiplication to preserve the full product. Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool. Fixes: f1de2439ec43 ("blk-iocost: revamp donation amount determination") Cc: stable@vger.kernel.org Signed-off-by: Alex Kazinsky Acked-by: Tejun Heo Link: https://patch.msgid.link/20261113110842.4189035-1-a.kazinsky@ideco.ru Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-iocost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1845,7 +1845,8 @@ static u32 hweight_after_donation(struct delta = div64_s64(WEIGHT_ONE * (now->vnow - vtime), now->vnow - ioc->period_at_vtime); target = WEIGHT_ONE * MARGIN_TARGET_PCT / 100; - new_hwi = div64_s64(WEIGHT_ONE * usage, WEIGHT_ONE - target + delta); + new_hwi = div64_s64((s64)WEIGHT_ONE * usage, + WEIGHT_ONE - target + delta); return clamp_t(s64, new_hwi, 1, hwm); }