2

I'm capturing a SIGSEGV on a read/write to a known block of memory. The block is mmaped and under my control, so it can be manipulated. I'd like to simulate the read/write succeeding, actually process the data and continue the application. I've got two possible solutions, but they all seem too complicated. I'm hoping there's a better way to achieve this:

  1. Borrow the trick from debuggers and:

    • mmap the area and protect
    • wait for SIGSEGV
    • get the read/write size from instruction type
    • for reads, put the required data in memory and remove protection
    • single-step the app
    • for writes, read what was written and process
    • in the single-step TRAP protect the page again and continue the app
  2. Do some crazy processing on the instruction itself and:

    • mmap the area and protect
    • wait for SIGSEGV
    • get the instruction under eip and simulate its effects
    • return after the instruction

The app is not running under root account, in case that matters.

I'm assuming x86_64 and don't really care about other platforms at the moment.

viraptor
  • 33,322
  • 10
  • 107
  • 191
  • Related: http://stackoverflow.com/questions/14233464/can-a-c-program-continue-execution-after-a-signal-is-handled – shauryachats Mar 24 '15 at 08:51
  • 2
    Seems like a duplicate: http://stackoverflow.com/questions/2663456/write-a-signal-handler-to-catch-sigsegv -- or if not, could you please explain why this isn't a duplicate? – juhist Mar 24 '15 at 08:51

0 Answers0