summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-28 20:57:40 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-28 20:57:40 +0100
commit1d2c9dbc3a664f826b4c7d08a4ef6dea76963502 (patch)
treec5d973102c14bbe97d8181c2932b903f84858c9e /Kernel
parentc17f80e720b269e88700af4ea13f877b6d72303b (diff)
downloadserenity-1d2c9dbc3a664f826b4c7d08a4ef6dea76963502.zip
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.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Devices/BXVGADevice.cpp5
1 files changed, 5 insertions, 0 deletions
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 <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
+#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;