1 Reply
      Latest reply on May 20, 2020 1:49 AM by eskimo
      tobe43 Level 1 Level 1 (0 points)

        Now we want to use the system call of `mprotect` to access and execute any function in dynamic way. It is really usage in hot patching running process. Normaly, we use `mprotect` with flags like `PROT_WRITE` or `PROT_READ` and it should work in Linux and MacOS(before Catalina).


        Recently we found that  `mprotect` with  `PROT_WRITE` will fail and return zero even throught we have grant the priviledges to the process. It may be the security issue so we disable the csrutil and codesign with almost all the entitlements before testing but it still fail.


        Here are the related discussion: https://github.com/flutter/flutter/issues/36714 https://github.com/agiledragon/gomonkey/issues/10 https://stackoverflow.com/questions/60654834/using-mprotect-to-make-text-segment-writable-on-macos