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=1796382927; b=eupp5lcH0Ca8z4rCtf8pCboJoU3sX670cYqqvmQPpMW9Nc2F+eb+4ORWoMtWBMCBHDDd 8C8FuQy7EL3F5/bGcXmbnyejFTkxf6P8aJLh0Cg1JuCFQzrD5+VMSifBsV3hHqwOoh90w 0KdKmEsAPcuZVYvhrfF7bRSKO7AcYzT1gqjkMxL0mCEuFW17gTA1CYmsDXBAhpCfQaJ0o DmUJajPNliU1VCkzbpkuhdBB121Gk4mCjVP7+9fdkEsP3yXzIixMukZ3nv+aQB4alqP+W ubi/7gOpaUpCPb7RWNk5IkEJOj/aUqwynNHfxdTV5Zgp6pJLB+cxRPORhCnN6D5rb8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382927; 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=NvUN6UZafiAejfGNYE41BuxeIUPFBXexwCC+8UwySic=; b=raWSLo5eMUwKBbY+SXmCfxhfDiAnW5KPwnhdVv2GsPEYhJOke3R3VyohZAmfZ9hbRgir 00Wwguq0hbT/xUgtZgYg3DkK/gzdgzpJ0AFcberGEIpcY9Yyn3zRGcVq9H1YG0obtHIKs p+WnLwlS5z4BTy8e38ts0yeEU+VfTQjjDARepMoZK1w22p8pwRiq8sfYXje82FRNDbMxx z21LOjX0b6szc5QN0mYq25cr8CUz4bc9c4DgdlQgtw5ZGy3yLsgymVc98NFpDFkiJ+pOu Gt6eqqNfOH3UKeOcDWmoR2R8zMjZsNNYO9pfDGzIS9HpE5/WzhRVAWdX53z9Xh8S/Dw== 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=sgWaU8X0; 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 2D8F6606A332; Fri, 4 Dec 2026 11:15:27 +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=sgWaU8X0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 270611F000C2; Fri, 4 Dec 2026 11:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382926; bh=NvUN6UZafiAejfGNYE41BuxeIUPFBXexwCC+8UwySic=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sgWaU8X0RDsMsmwNztj33npBYOYlrL9+C7jeNWyJca9SA6zkE6fb353QmshrSonKC t7fBrceLIOvk1DbWcwEKyN58EaOmPpfpbBDW7oHjnM2fvL3APgmPzt0I8n716cDbsl H8HJHhIOdlehhz7Cq1/p1MxXRHJdk9HnS5Ulko20= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Zimmermann , Ruben Wauters Subject: [PATCH 6.18 653/703] drm/gud: fix potential divide error due to optimisation Date: Fri, 4 Dec 2026 19:09:12 +0900 Message-ID: <20261204100645.153161930@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: Ruben Wauters commit cbea6bdc930b2de974e77e6c3031f67796793625 upstream. Compilers can potentially optmise the read of gdrm->stats_actual_length to two separate reads. As flagged by sashiko, when the rect is flushed the stats_actual_length can reset to zero. If this was to occur between the two reads, the divide error can still be triggered (albeit rarely). Fix this by adding a READ_ONCE around the gdrm->stats_actual_length Fixes: 431c2dffd2b7 ("drm/gud: avoid divide error in gud_stats_debugfs") Cc: Reviewed-by: Thomas Zimmermann Link: https://patch.msgid.link/20261117141943.10540-1-ruben.wauters@linux.dev Signed-off-by: Ruben Wauters Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/gud/gud_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/gud/gud_drv.c +++ b/drivers/gpu/drm/gud/gud_drv.c @@ -329,7 +329,7 @@ static int gud_stats_debugfs(struct seq_ seq_puts(m, "\n"); if (gdrm->compression) { - u64 actual_length = gdrm->stats_actual_length; + u64 actual_length = READ_ONCE(gdrm->stats_actual_length); u64 remainder; u64 ratio, ratio_frac;