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 136522F7426; Tue, 17 Jun 2025 16:13:24 +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=1750176804; cv=none; b=KorEbNegkIi3UoKiB/EGWsq1nerH4PMhcGHvBGsP5u4/UdJshPbvK2x7LlOTTrZY7VUrsi936vEvFrpdA6EpLFOVO8XQQT9J6woU55w0LQ/mw+1JBe6jHRD82YDxbd+O4SlVMncEet+4yEYCDpQ55NW8LaCpANxjyhn0lBTkcpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750176804; c=relaxed/simple; bh=zydLWrjoHs/X+0E8YoJMEgpVYalUvhIDUKso/S8Jabg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A2JkpFBsWV1OLUKWUibgDyQaBh6SOWmDN50CWzJDp6zyL2NpTVtFcEqVj03eCvDbU/XSSZEI1B01bH+9HqEsJaRiShPeNhuXiuuPAQAoZYdB+NLY3jnz3h4nml/CT5hiUQCbBmgHgGHPkK1t0Tejp4ruUGdPY/vGEdXy0r6uVeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kaHKu6rc; 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="kaHKu6rc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79051C4CEE7; Tue, 17 Jun 2025 16:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750176804; bh=zydLWrjoHs/X+0E8YoJMEgpVYalUvhIDUKso/S8Jabg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kaHKu6rcZOdWIPnGz+OL33umZmWQWRqblp/VgVqwKIVR0QdKCw/+dNNj5RYcHoglZ lS3PZ/F2wl2vQjlDDHdbugLuqhNvnj+VxtpiYxIzq2rWdHNdnUp6MkehsEQNYrekAB 6G2CJnZRvl1AGbQYmb8hTh1pyNlS03yTlMzNMMNM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sergey Shtylyov , Helge Deller , Sasha Levin Subject: [PATCH 6.12 268/512] fbdev: core: fbcvt: avoid division by 0 in fb_cvt_hperiod() Date: Tue, 17 Jun 2025 17:23:54 +0200 Message-ID: <20250617152430.454558568@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152419.512865572@linuxfoundation.org> References: <20250617152419.512865572@linuxfoundation.org> User-Agent: quilt/0.68 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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sergey Shtylyov [ Upstream commit 3f6dae09fc8c306eb70fdfef70726e1f154e173a ] In fb_find_mode_cvt(), iff mode->refresh somehow happens to be 0x80000000, cvt.f_refresh will become 0 when multiplying it by 2 due to overflow. It's then passed to fb_cvt_hperiod(), where it's used as a divider -- division by 0 will result in kernel oops. Add a sanity check for cvt.f_refresh to avoid such overflow... Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Fixes: 96fe6a2109db ("[PATCH] fbdev: Add VESA Coordinated Video Timings (CVT) support") Signed-off-by: Sergey Shtylyov Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/core/fbcvt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcvt.c b/drivers/video/fbdev/core/fbcvt.c index 64843464c6613..cd3821bd82e56 100644 --- a/drivers/video/fbdev/core/fbcvt.c +++ b/drivers/video/fbdev/core/fbcvt.c @@ -312,7 +312,7 @@ int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb) cvt.f_refresh = cvt.refresh; cvt.interlace = 1; - if (!cvt.xres || !cvt.yres || !cvt.refresh) { + if (!cvt.xres || !cvt.yres || !cvt.refresh || cvt.f_refresh > INT_MAX) { printk(KERN_INFO "fbcvt: Invalid input parameters\n"); return 1; } -- 2.39.5