-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stalker: Abort when allocate_near() fails on arm64
Instead of crashing due to the subsequent NULL pointer dereference. Co-authored-by: Alex Soler <[email protected]> Co-authored-by: Francesco Tamagni <[email protected]>
- Loading branch information
1 parent
da07022
commit b9fdec4
Showing
1 changed file
with
12 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
/* | ||
* Copyright (C) 2014-2023 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2014-2024 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2017 Antonio Ken Iannillo <[email protected]> | ||
* Copyright (C) 2019 John Coates <[email protected]> | ||
* Copyright (C) 2023 Håvard Sørbø <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* Copyright (C) 2024 Alex Soler <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -5660,6 +5661,11 @@ gum_code_slab_new (GumExecCtx * ctx) | |
|
||
code_slab = gum_memory_allocate_near (&spec, total_size, stalker->page_size, | ||
stalker->is_rwx_supported ? GUM_PAGE_RWX : GUM_PAGE_RW); | ||
if (code_slab == NULL) | ||
{ | ||
g_error ("Unable to allocate code slab near %p with max_distance=%zu", | ||
spec.near_address, spec.max_distance); | ||
} | ||
|
||
gum_code_slab_init (code_slab, stalker->code_slab_size_dynamic, total_size, | ||
stalker->page_size); | ||
|
@@ -5723,6 +5729,11 @@ gum_data_slab_new (GumExecCtx * ctx) | |
|
||
slab = gum_memory_allocate_near (&spec, slab_size, stalker->page_size, | ||
GUM_PAGE_RW); | ||
if (slab == NULL) | ||
{ | ||
g_error ("Unable to allocate data slab near %p with max_distance=%zu", | ||
spec.near_address, spec.max_distance); | ||
} | ||
|
||
gum_data_slab_init (slab, slab_size, slab_size); | ||
|
||
|