summaryrefslogtreecommitdiff
path: root/Kernel/Arch
diff options
context:
space:
mode:
authorJean-Baptiste Boric <jblbeurope@gmail.com>2021-03-07 12:36:16 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-07 14:05:17 +0100
commit32e1354b9b0050dd2920c8506cef2841789e14df (patch)
tree978d28e415464ac36d3b991f3d1a0d011fe54b9e /Kernel/Arch
parenta6f957a36b6b7a51225c0ea7f9e2e22678f3ed31 (diff)
downloadserenity-32e1354b9b0050dd2920c8506cef2841789e14df.zip
Kernel: Fix unaligned read inside map_ebda()
Diffstat (limited to 'Kernel/Arch')
-rw-r--r--Kernel/Arch/PC/BIOS.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Kernel/Arch/PC/BIOS.cpp b/Kernel/Arch/PC/BIOS.cpp
index 009df2df3f..1214ba80ed 100644
--- a/Kernel/Arch/PC/BIOS.cpp
+++ b/Kernel/Arch/PC/BIOS.cpp
@@ -43,10 +43,11 @@ MappedROM map_bios()
MappedROM map_ebda()
{
auto ebda_segment_ptr = map_typed<u16>(PhysicalAddress(0x40e));
- auto ebda_length_ptr = map_typed<u16>(PhysicalAddress(0x413));
+ auto ebda_length_ptr_b0 = map_typed<u8>(PhysicalAddress(0x413));
+ auto ebda_length_ptr_b1 = map_typed<u8>(PhysicalAddress(0x414));
PhysicalAddress ebda_paddr(*ebda_segment_ptr << 4);
- size_t ebda_size = *ebda_length_ptr;
+ size_t ebda_size = (*ebda_length_ptr_b1 << 8) | *ebda_length_ptr_b0;
MappedROM mapping;
mapping.region = MM.allocate_kernel_region(ebda_paddr.page_base(), page_round_up(ebda_size), {}, Region::Access::Read);