From: Helge Deller <deller@gmx.de>
To: weidongw@illinois.edu
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Zijie Zhao <zijie4@illinois.edu>
Subject: Re: [PATCH] fbdev: cirrusfb: Fix overflow in the video memory check
Date: Wed, 18 Nov 2026 19:48:46 +0100 [thread overview]
Message-ID: <4f2af4ab-2fd7-4564-9d71-638a8a991de2@gmx.de> (raw)
In-Reply-To: <20261112-c4-n053-v1-1-1e45ef75304c@illinois.edu>
On 11/12/26 07:37, Weidong Wang via B4 Relay wrote:
> From: Weidong Wang <weidongw@illinois.edu>
>
> cirrusfb_check_var() raises xres_virtual to xres and then checks
> xres_virtual * yres_virtual against the video memory in 32-bit
> arithmetic. fb_set_var() checks the product for overflow, but only for
> the values passed in, before the driver raises xres_virtual. A mode with
> xres 65536, xres_virtual 640 and yres_virtual 65536 passes that check,
> becomes 65536 x 65536 in cirrusfb_check_var(), and the product wraps to
> 0, so the mode is accepted on a 4 MiB card with a line length of
> 65536 bytes. The framebuffer console then draws at offsets far past the
> end of the video memory mapping.
>
> Do the multiplication in 64 bits.
>
> Found by an AI code review agent (an LLM-based bug-finding tool
> developed by Zijie Zhao and the submitter) and confirmed on an
> unmodified kernel, without error injection, on x86_64 under QEMU with
> -vga cirrus (GD5446, 4 MiB) and KASAN. FBIOPUT_VSCREENINFO with
> xres 65536, yres 128, xres_virtual 640, yres_virtual 65536 at 8 bpp is
> accepted as 65536x128, virtual 65536x65536. Booted with
> video=cirrusfb:noaccel, fbcon's redraw then faults:
>
> BUG: unable to handle page fault for address: ffffc90000b00000
> RIP: 0010:cfb_imageblit+0xbc6/0x1970
> soft_cursor+0x5eb/0xcd0
> bit_cursor+0xb41/0x1910
> hide_cursor+0x6e/0x1d0
>
> With acceleration enabled, text on the GD5446 is drawn with the blitter,
> which QEMU bounds, so the mode is accepted but nothing faults; drawing
> goes through the CPU with noaccel and on the Laguna chips, which always
> run without acceleration. Asked for without the wrap, as 65536x128 with
> a 65536x128 virtual resolution (8 MiB), the mode is rejected, as it
> should be.
>
> With this patch the mode is rejected with "virtual resolution too high
> to fit into video memory", and 1024x768x8 is still accepted.
>
> The reproducer, fix and changelog were drafted with AI assistance
> (Claude), then reviewed and tested by the submitter.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Cc: Zijie Zhao <zijie4@illinois.edu>
> Signed-off-by: Weidong Wang <weidongw@illinois.edu>
> ---
> Tested on v7.4-rc1 (05441d697f7f), x86_64, KASAN, QEMU/KVM -vga cirrus
> (GD5446, 4 MiB). FBIOPUT_VSCREENINFO at 8 bpp:
>
> 65536x128, virtual 640x65536 65536x128, virtual 65536x128
> (control)
> unpatched accepted as virtual 65536x65536; rejected
> with noaccel, fbcon faults in
> cfb_imageblit, panic
> patched rejected rejected
can't you simply check xres_virtual and yres_virtual values
against sane values, e.g. bail out if each of them is bigger than
e.g. 16384 pixels ?
Helge
prev parent reply other threads:[~2026-11-18 18:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 6:37 Weidong Wang via B4 Relay
2026-11-18 18:48 ` Helge Deller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f2af4ab-2fd7-4564-9d71-638a8a991de2@gmx.de \
--to=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=weidongw@illinois.edu \
--cc=zijie4@illinois.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®