I have a small program that mmaps potentially dangerous executable code (with PROT_EXEC), calls prctl(PR_SET_SECCOMP, 1)
and then executes this mmap'd code. This is all well and good, and allows me to "save" the state of the evaluation by sync the mmap'd region to disk, and reload it later (most likely on another machine for load balancing). However, this technique doesn't always work -- because this code might have made changes to the program that are not in the mmap'd region, and this information will be lost.
So what I would like to do, is make absolutely everything (other than this mmap'd region) read-only before calling the code. This way I have a guarantee that the executable code can't change the state of anything other than the mmap'd region which I can serialize/deserialize at will.
BTW this is Linux on x86_64
Thanks