Can mremap be used to text_poke in x86 usermode?
by Evian-Zhang from LinuxQuestions.org on (#6PSMR)
As described in Add a text_poke syscall, it is difficult to implement text_poke in usermode. After checking the implementation of text_poke in arch/x86/kernel/alternative.c, I think the text_poke is just to remap the page, modify it, and remap back. So I wonder if we could use mremap syscall to implement a usermode text_poke? As a reference, this SO answer shows that in macOS, using memory remap can modify instruction in user mode.
It is hard to verify whether a text_poke is implemented correctly to allow cross-modifying instructions at another thread, so I come here to seek for some theoretical suggestions.
It is hard to verify whether a text_poke is implemented correctly to allow cross-modifying instructions at another thread, so I come here to seek for some theoretical suggestions.