From 1d2c9dbc3a664f826b4c7d08a4ef6dea76963502 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 28 Jan 2020 20:57:40 +0100 Subject: BXVGA: Disallow resolutions higher than 4096x2160 There's no sense in allowing arbitrarily huge resolutions. Instead, we now cap the screen size at 4K DCI resolution and will reject attempts to go bigger with EINVAL. --- Kernel/Devices/BXVGADevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Kernel') diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp index 47730d9936..474b8a897f 100644 --- a/Kernel/Devices/BXVGADevice.cpp +++ b/Kernel/Devices/BXVGADevice.cpp @@ -33,6 +33,9 @@ #include #include +#define MAX_RESOLUTION_WIDTH 4096 +#define MAX_RESOLUTION_HEIGHT 2160 + #define VBE_DISPI_IOPORT_INDEX 0x01CE #define VBE_DISPI_IOPORT_DATA 0x01CF @@ -167,6 +170,8 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg) auto* resolution = (FBResolution*)arg; if (!current->process().validate_read_typed(resolution) || !current->process().validate_write_typed(resolution)) return -EFAULT; + if (resolution->width > MAX_RESOLUTION_WIDTH || resolution->height > MAX_RESOLUTION_HEIGHT) + return -EINVAL; set_resolution(resolution->width, resolution->height); resolution->pitch = m_framebuffer_pitch; resolution->width = m_framebuffer_width; -- cgit v1.2.3