SUSE / libpulp

libpulp enables live patching in user space applications.
GNU Lesser General Public License v2.1
55 stars 11 forks source link

Add support for processes launched with systemd MemoryDenyWriteExecuteWrite=Yes #191

Closed giulianobelinassi closed 1 year ago

giulianobelinassi commented 1 year ago

Previously, libpulp blocked livepatching when it found that the process was launched with MemoryDenyWriteExecute=yes because it could not set the page permission to writable in order to write the redirection code in the ULP prologue.

This patch fixes this by doing the following workaround:

1- Set a instruction queue between libpulp.so and the ulp tool. 2- While livepatching, libpulp.so fill this queue with instructions. one of such instruction is WRITE, which is implemented using ptrace. This will write into the target process address 3- After livepatching is complete on libpulp.so side, the ulp tool will retrieve the queue and interpret it, effectively ptracing the function's prologue with the redirection code for the new function. 4- The ulp tool cleans the queue on the target process for the next patch.

Note that 3 and 4 runs with the target process stopped, so there is no race condition in the queue.