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=1796389396; b=TWG65T8itAoFZUnGYtdLNw3U8HXZBEkfuRElK+rc6iw4yMqlMH/Mj8JJOrDnUikr55Q8 muw1TxF8hTilPFgi4qWuDJ/IeV5mD7TlaftgydH7pME807oL8B8Cew5uk35r/B2kc+nNY 468xvT0tIWgF5a5WrzRNVUW96EiXWA+LHqcKBFT2vQGaaDDRwXyokDeWWyDBxKxw/SGd7 PoNYxQb+i48hmQHtLr0/58WpI6yBRWzLVvsJ63lD58d53soK3XisE+OwYPKw2qb+uE2Hh V23LfdKvjspGixK6AYrp+9q+GgLv344AtW3eGL75cKhMy7usiTwMCxStYq+svzs2AUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389396; 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=o8W3qshAyQ2NRHT0SMcpqVER/L7m8q9vXY2tWcuVRZM=; b=LKGu1n2toQkwKBuBI+zxnULQNzqHkqF6m371m92fQUYKzaU0g8d8ebsMxOjAJe/stBzB O7lS1LiWbWEE82JaDsXrol6vA07PeDAvDG4yE87LAtjjrL0HlE7Ntoe9o3wRjHMeqjeiC 7AQHkSY0aASvTmbrleHMiLHLJDTIa3aVTWfHBdXc/CXhTuaBAUFp1r4uyukl5w15wuxd8 WqPmv/it0VN6lfIbE5hIsTS95kkarW0asEw2m9c6B9DXqokFuY/jQobMJIGJTBlF4MpsS Bby2yRIOY70dddy9HNWk/zunBrnTFTmOvIJy8JN/63aA4Qe/QeaFw9j4cXu3q/u4Slg== 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=seBMdRrA; 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 CBBE1606A322; Fri, 4 Dec 2026 13:03:16 +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=seBMdRrA Received: by smtp.kernel.org (Postfix) with ESMTPSA id E25511F000CE; Fri, 4 Dec 2026 13:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389396; bh=o8W3qshAyQ2NRHT0SMcpqVER/L7m8q9vXY2tWcuVRZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=seBMdRrAEgD8hQvcp6tD54I9Y0Ckl4wZjD82lsifV0gKheOA1nhCWO55KLB2u5XDQ 1/sCkb8NePdDVutKuIXnSxCKLg6Oleqmqr7fAxEHYPSKMq6sz3foH378El7EyCQ40/ hGGHrn+xBmxGFscULos5Yp0F+o5oklUY05nnHgOM= 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.1 0935/1059] fbdev: vfb: Validate framebuffer geometry and memory size Date: Fri, 4 Dec 2026 19:07:46 +0900 Message-ID: <20261204100708.243441235@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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; @@ -161,6 +164,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. */