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=1796383818; b=BWJ1jaAioZh/nMxiiim4pdICKk+mTRVrkrQXZgMxoBRyvjnf5i+P7dYwUsq7vuIdWQqh 2r8ur+AAu2GI4tcS/2e6/oFpsDnDDOY39+rnwSHn0tYQrw++4wzt2gernckg6puXx/17d sPluZwUEhcRx9rAWy05V2YsZucon8xwSDCFbLz1VVmGN8w3ao3Z94Fd6caYB1i4U4zfw4 lQ9kFQhoZY2GZ0LuMQNc8HPWuaBPiWlX42/GmdMtNSSnHK8ia7h6SlMjeQhCJsZ5mkY2K qlIcdM/USWWnPvh2rsCUWFnhpg1cz2zWIsrg54tvtJF1/3vJHyZf2mERTSaaBvtGlgA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383818; 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=AYMESYmx2epv3aL4dGDy9mmRfsTQEsWcQTgpxOL7h4A=; b=Vk22Rma1iEScSp+UfsQJKigzQO6az1yIlyAQEh6KuNLE2F9oIxs4Ta6Alg0/PsZ6LVmy NmieX1xBf46rvHjafenuNVHzXUO4fqVqCZRTF4rpNZnfNsCofkVrIMIh9AyL9G/Ei9VK5 Zqtdp5ug1Opi9ef6GaAA2vXN9MDq0tHt4HmazHfdR4olbYFj6CHunCHY45Vr7o9jJt5sh q/wGKM1DSPsDhVMS1fWiRQesyY0iQeW2+OvHJof0AYBuA0LWgZoi8nOXKUfJCamn32hxa OWOYf0ZmsKqCTn53NmmWk+xVbQ1/wJ044VZYg70Z3DJIMyI7POIyKCarlcUcJBpzUzA== 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=DPgfifis; 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 6E599606A334; Fri, 4 Dec 2026 11:30:18 +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=DPgfifis Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C0451F000C2; Fri, 4 Dec 2026 11:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383818; bh=AYMESYmx2epv3aL4dGDy9mmRfsTQEsWcQTgpxOL7h4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DPgfifisDPThWzEK37gQtAicndy64woC+xq6B4r0Zrh7VDnQOLCNRKwLtiu2KEXyT NZ451vtImENL2tm+kN2s8SUGMiTt/E6K6OvHW3g6F6OmuJQmsI1tff0DfDC5c3CJq7 ueIvBYinruqgTA7MV37rVVVZIBBHonWTJ+tfkx4w= 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 6.12 381/555] fbdev: vfb: Validate framebuffer geometry and memory size Date: Fri, 4 Dec 2026 19:07:04 +0900 Message-ID: <20261204100624.330169942@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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. */