Skip to content

Commit 80b406d

Browse files
dcpleungcfriedt
authored andcommitted
x86: acpi: limit search on where EBDA can be
This limits the search for Extended BIOS Data Area (EBDA) to 0x80000 to 0x100000 as this is usually the area for it. If 0000:040e has an address not pointing to this area, it is probably an invalid address, and should not be de-referenced to avoid segfault. Signed-off-by: Daniel Leung <[email protected]>
1 parent 837ab4a commit 80b406d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/core/acpi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ static void find_rsdp(void)
5050
bda_seg = 0x040e + zero_page_base;
5151
uint64_t *search = (void *)(long)(((int)*(uint16_t *)bda_seg) << 4);
5252

53-
/* Might be nothing there, check before we inspect */
54-
if (search != NULL) {
53+
/* Might be nothing there, check before we inspect.
54+
* Note that EBDA usually is in 0x80000 to 0x100000.
55+
*/
56+
if ((POINTER_TO_UINT(search) >= 0x80000UL) &&
57+
(POINTER_TO_UINT(search) < 0x100000UL)) {
5558
for (int i = 0; i < 1024/8; i++) {
5659
if (search[i] == ACPI_RSDP_SIGNATURE) {
5760
rsdp = (void *)&search[i];

0 commit comments

Comments
 (0)