From 9b14a8605a8ef4ab81141f7baff634d472912beb Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 17 Jun 2021 19:29:49 +0200 Subject: Kernel: Add a VERIFY() to make sure our DMA address is valid This checks whether the address we're trying to use for DMA is low enough so as not to overflow the I/O register. --- Kernel/Devices/SB16.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index ec29fe28b0..83b3c20289 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -200,6 +200,9 @@ void SB16::dma_start(uint32_t length) // Write the buffer IO::out8(0x8b, addr >> 16); + auto page_number = addr >> 16; + VERIFY(page_number <= NumericLimits::max()); + IO::out8(0x8b, page_number); // Enable the DMA channel IO::out8(0xd4, (channel % 4)); -- cgit v1.2.3