linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: kyro: Add some geometry checks.
@ 2025-03-23 18:57 Danila Chernetsov
  0 siblings, 0 replies; only message in thread
From: Danila Chernetsov @ 2025-03-23 18:57 UTC (permalink / raw)
  To: Helge Deller
  Cc: Danila Chernetsov, linux-fbdev, dri-devel, linux-kernel,
	lvc-project

The check protects against division by 0, integer wraparound,
and overflow Start/End window settings.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Danila Chernetsov <listdansp@mail.ru>
---
 drivers/video/fbdev/kyro/fbdev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 08ee8baa79f8..1d5246313d9a 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -378,6 +378,13 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight
 	    (x < 2 && ulWidth + 2 == 0))
 		return -EINVAL;
 
+	/* The check protects against division by 0, integer wraparound,
+	 * and overflow Start/End window settings.
+	 */
+	if (x + ulWidth - 1 <= x || y + ulHeight - 1 <= y ||
+	    x + ulWidth - 1 > 65535 || y + ulHeight - 1 > 65535)
+		return -EINVAL;
+
 	/* Stop Ramdac Output */
 	DisableRamdacOutput(deviceInfo.pSTGReg);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-23 19:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-23 18:57 [PATCH] video: fbdev: kyro: Add some geometry checks Danila Chernetsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).