]> git.ipfire.org Git - thirdparty/grub.git/commit
commands/videoinfo: Prevent crash when run while video driver already active
authorGlenn Washburn <development@efficientek.com>
Fri, 11 Aug 2023 21:30:04 +0000 (16:30 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Aug 2023 16:04:04 +0000 (18:04 +0200)
commit1de58326994b0045ccfb28017d05fc1ddecdb92d
treeae25ac87e89287c35a444c267c96e15891b36369
parent43bf0b2a10bc8f312ad4b38649c8523620d66d2b
commands/videoinfo: Prevent crash when run while video driver already active

The videoinfo command will initialize all non-active video adapters. Video
drivers tend to zero out the global framebuffer object on initialization.
This is not a problem when there is no active video adapter. However, when
there is, then outputting to the video adapter will cause a crash because
methods in the framebuffer object are reinitialized. For example, this
command sequence will cause a crash.

  terminal_output --append gfxterm; videoinfo

When running in a QEMU headless with GRUB built for the x86_64-efi target,
the first command initializes the Bochs video adapter, which, among
other things, sets the set_page() member function. Then when videoinfo is
run, all non-Bochs video adapters will be initialized, each one wiping
the framebuffer and thus setting set_page to NULL. Soon after the videoinfo
command finishes there will be a call to grub_refresh(), which will
ultimately call the framebuffer's set_page which will be NULL and cause
a crash when called.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/videoinfo.c