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=1796380907; b=gn7YD1hkLn7tIa92TtTJ6ZFkDbnyFYlZjmZcapVREJUS32ITvlp1akXXGDqJenemv3y2 EPbbqqHgWlN8BXvNYQ7JVenYiswJ3ahc4SPmlWlhIWFtMXcA7vh0oGM3JSVT15pBND65j hMmWuRmg8R5v2QGt4oBNbf24hn1L/6nSS+8D27z+DX4ogUFVIDH0WmfEmELG3Dt8ugSMD lU391LtddL5KSQiyCTVXJvpPhdPHwkPW6YDFiASfk9vyA8W/3U8kDbIJ+namVcsa0Qfuw mc3Frx5L4Cs03ivFTeISRjeitu6qtC6hxHXoYiBs7RP71AXGKFXf4DGW3vsaT2F7guA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380907; 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=2aF1f2vJbMpuDKEkwS+JDP4PlQxgEcs9YqiCpnMqTAk=; b=x+QuBcv7ckslfH/c49ZDrM5ivjyI+LugpQ5T8ifm3I0EbVRmioM+lNC/2SkbRDutiJ+O Q/LMZS6GNtc6YLn23g8zRCsSe4gte8oeHujxTryGtoFFsDbYSYg9wtsa/tnS4m7v8Aq8b tgGkgdcWViHIeIkGGoHyi16KPQ2EXC5wa46LRIUbYJyBaRZIFp1xCvBK7ogK8VEEOm+f4 CBwZet29Tg4fvB/Q0JNEEEcX4HxAiDia86A9QbB6OyC2p6lOgoVggdw5frlHYwuapX8HQ HFlHH0yOV6wHNnkLEbuycj86PP5vXEgf1YHnKkyTCMRnDpeRQYzNTiKMm/R4DRyLn8A== 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="W8uLN0/Z"; 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 F20E5606A322; Fri, 4 Dec 2026 10:41:46 +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=W8uLN0/Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B3A91F000CE; Fri, 4 Dec 2026 10:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380906; bh=2aF1f2vJbMpuDKEkwS+JDP4PlQxgEcs9YqiCpnMqTAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W8uLN0/ZyNOqcAkdygHULhS/1LT6s2ppNhhWtDj7AijOwioTZEArsa7KBdiGrl3L3 u4GK66AJ9EV/KV1eeMBEjbR8OL220sy1JG54vxGNqYItr2xoeT8Dt9gOXnfmG2MxoN Fb99/hltJBSbqaDpLl8P6eHik124vxnC2S2mS3JQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, co+b0df61d49532b2ee@bugs.sh, Helge Deller , Weiming Shi Subject: [PATCH 7.3 474/742] fbdev: vfb: Validate framebuffer geometry and memory size Date: Fri, 4 Dec 2026 19:05:38 +0900 Message-ID: <20261204100647.742601999@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi commit b438bb88f65a8b464ad08057873db9605cdae945 upstream. FBIOPUT_VSCREENINFO can supply a virtual width large enough to overflow get_line_length()'s int multiplication and bypass the video-memory limit, allowing fbcon to write past the framebuffer. The offset additions can also wrap, while an excessive videomemorysize module parameter can be truncated when PAGE_ALIGN() is assigned to unsigned int. Limit virtual geometry and offsets to 8192 x 8192 and cap video memory at 512 MiB, keeping the stride, framebuffer-size, and generic fbdev drawing calculations within their destination types. KASAN reports: BUG: KASAN: vmalloc-out-of-bounds in sys_fillrect drivers/video/fbdev/core/sysfillrect.c:24 Write of size 8 at addr ffa0000001671000 by task poc/198 sys_fillrect drivers/video/fbdev/core/sysfillrect.c:24 bit_clear_margins drivers/video/fbdev/core/bitblit.c:247 fbcon_clear_margins.constprop.0 drivers/video/fbdev/core/fbcon.c:1410 fbcon_switch drivers/video/fbdev/core/fbcon.c:2261 redraw_screen drivers/tty/vt/vt.c:994 fbcon_modechanged drivers/video/fbdev/core/fbcon.c:2693 fbcon_update_vcs drivers/video/fbdev/core/fbcon.c:2732 Cc: stable@vger.kernel.org Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: co+b0df61d49532b2ee@bugs.sh Suggested-by: Helge Deller Assisted-by: LLM Signed-off-by: Weiming Shi Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/vfb.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -30,7 +30,10 @@ * The default can be overridden if the driver is compiled as a module */ -#define VIDEOMEMSIZE (1*1024*1024) /* 1 MB */ +#define MAX_XRES 8192 +#define MAX_YRES 8192 +#define VIDEOMEMSIZE (1 * 1024 * 1024) /* 1 MB */ +#define MAX_VIDEOMEMSIZE (8192 * 8192 * sizeof(u32)) static void *videomemory; static u_long videomemorysize = VIDEOMEMSIZE; @@ -159,6 +162,14 @@ static int vfb_check_var(struct fb_var_s else return -EINVAL; + if (var->xres_virtual > MAX_XRES || + var->yres_virtual > MAX_YRES) + return -EINVAL; + + if (var->xoffset > MAX_XRES - var->xres || + var->yoffset > MAX_YRES - var->yres) + return -EINVAL; + if (var->xres_virtual < var->xoffset + var->xres) var->xres_virtual = var->xoffset + var->xres; if (var->yres_virtual < var->yoffset + var->yres) @@ -434,9 +445,12 @@ static int __init vfb_setup(char *option static int vfb_probe(struct platform_device *dev) { struct fb_info *info; - unsigned int size = PAGE_ALIGN(videomemorysize); + unsigned int size; int retval = -ENOMEM; + videomemorysize = min(videomemorysize, MAX_VIDEOMEMSIZE); + size = PAGE_ALIGN(videomemorysize); + /* * For real video cards we use ioremap. */