]> git.baikalelectronics.ru Git - kernel.git/commit
video: hyperv_fb: Fix validation of screen resolution
authorMichael Kelley <mikelley@microsoft.com>
Sun, 16 Jan 2022 19:18:31 +0000 (11:18 -0800)
committerWei Liu <wei.liu@kernel.org>
Mon, 24 Jan 2022 14:01:12 +0000 (14:01 +0000)
commit12aa99ef3f28c6a5f6c21d7df267a061d5397624
tree3d69e46c2ba7ec52833367b0e126f995593dd2d2
parent535b75c64a2c8446f321526c7195f209d542de75
video: hyperv_fb: Fix validation of screen resolution

In the WIN10 version of the Synthetic Video protocol with Hyper-V,
Hyper-V reports a list of supported resolutions as part of the protocol
negotiation. The driver calculates the maximum width and height from
the list of resolutions, and uses those maximums to validate any screen
resolution specified in the video= option on the kernel boot line.

This method of validation is incorrect. For example, the list of
supported resolutions could contain 1600x1200 and 1920x1080, both of
which fit in an 8 Mbyte frame buffer.  But calculating the max width
and height yields 1920 and 1200, and 1920x1200 resolution does not fit
in an 8 Mbyte frame buffer.  Unfortunately, this resolution is accepted,
causing a kernel fault when the driver accesses memory outside the
frame buffer.

Instead, validate the specified screen resolution by calculating
its size, and comparing against the frame buffer size.  Delete the
code for calculating the max width and height from the list of
resolutions, since these max values have no use.  Also add the
frame buffer size to the info message to aid in understanding why
a resolution might be rejected.

Fixes: ced18b82e2c3 ("video: hyperv: hyperv_fb: Obtain screen resolution from Hyper-V host")
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Acked-by: Helge Deller <deller@gmx.de>
Link: https://lore.kernel.org/r/1642360711-2335-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/video/fbdev/hyperv_fb.c