Below is a part of an experiement. I am trying to mprotect the whole of the stack area but mprotect needs page aligned space. I can get the address of the current pointer using ucontext.uc_mcontext.gregs[REG_ESP] . But how do I get the page-size aligned address to use in the mprotect ? and How do I calculate the size of the stack ?
This being an experiment, I am also curious if it possible in the first place. If so, would it result in security issues ? . Thanks.