Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruction that triggers a page fault is not completely rewound #10

Open
huettenhain opened this issue Dec 7, 2024 · 0 comments
Open

Comments

@huettenhain
Copy link

Consider the following code:

from icicle import Icicle, MemoryProtection

ic = Icicle('x86_64')
ic.mem_map(0x100, 0x20, MemoryProtection.ExecuteRead)
ic.mem_map(0x200, 0x20, MemoryProtection.ReadOnly)
ic.mem_write(0x100, B'\x55') # push rbp
ic.reg_write('rbp', 0xF00)
ic.reg_write('rsp', 0x210)
ic.reg_write('rip', 0x100)
status = ic.step(1)

print(F'run status      : {status}')
print(F'exception code  : {ic.exception_code}')
print(F'exception value : {hex(ic.exception_value)}')
print(F'stack pointer   : {hex(ic.reg_read("rsp"))}')

When executing this under Python 3.12.6 on Windows, using icicle-emu==0.0.5, it produces the following output:

run status      : RunStatus.UnhandledException
exception code  : ExceptionCode.WritePerm
exception value : 0x208
stack pointer   : 0x208

The exception is to be expected considering the permissions, but what is unexpected here is the value of the stack pointer: Its expected value would be 0x210, i.e. I would have expected that no part of the faulting instruction is executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant