Skip to content

Commit

Permalink
stalker: Abort when allocate_near() fails on arm64
Browse files Browse the repository at this point in the history
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
3 people committed Jan 11, 2024
1 parent da07022 commit b9fdec4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gum/backend-arm64/gumstalker-arm64.c
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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b9fdec4

Please sign in to comment.