mirror of
https://github.com/angr/angr
synced 2026-08-17 12:23:11 -04:00
SimLinux.state_blank pre-grows the stack by a fixed 0x20 pages without
checking that 0x20 pages exist beneath the stack pointer. When they do
not, the allocation loop wraps past address 0 and hands out the remainder
at the top of the address space.
On x86-64 that is silent: blank_state(stack_end=0x10000) maps sixteen
stack pages from 0x0 up and sixteen more from 0xfffffffffffff000 down.
Where the wrap reaches a page the same call already handed out, the state
fails with SimSegfaultException("stack collided with heap") instead, and
where it reaches the loaded image it replaces it with blank pages.
Skip the pre-grow when that much space does not exist. Clamping it to the
space that does exist is not an option: the pre-allocated pages are not
backed by the loader, so a stack that reaches down to an image beneath it
hides that image. The pages that are skipped are still faulted in on
demand.
Also reject an allocation that does not fit beneath the top of the stack
in allocate_stack_pages() itself, so a caller that asks for one gets an
error rather than pages at the top of the address space.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| ailment | ||
| analyses | ||
| angrdb | ||
| engines | ||
| exploration_techniques | ||
| factory | ||
| gui | ||
| knowledge_plugins | ||
| llm | ||
| manual | ||
| mcp | ||
| misc | ||
| perf | ||
| procedures | ||
| regression | ||
| serialization | ||
| sim | ||
| simos | ||
| state_plugins | ||
| storage | ||
| types | ||
| utils | ||
| __init__.py | ||
| common.py | ||
| README.md | ||
| test_calling_conventions.py | ||
| test_cli.py | ||
| test_fuzzer.py | ||
| test_load_shellcode.py | ||
Tests
Running tests
These tests require the binaries repository, clone it in the folder where angr was cloned.
git clone https://github.com/angr/binaries
nose2 or pytest may be used to run tests.
Each tool can be installed with pip:
pip install nose2
pip install pytest
To run the tests with nose2, from the root of the repository, run:
nose2 -s tests
Or if using pytest, simply run:
pytest
Writing new tests
New tests should be written using unittest, part of Python's standard library. For more information about unittest, see https://docs.python.org/3/library/unittest.html. While we prefer nose2 and pytest for running tests, avoid using nose2 or pytest features in tests themselves, to avoid dependency on a specific runner.