What's the protection flags of memory allocated by malloc?
问题 According to this thread,memory allocated by malloc at least have PROT_READ | PROT_EXEC ,otherwise the contaned function can't be executed . man malloc doesn't mention anything about protection thus the question. 回答1: malloc is not the right tool for allocating memory for code. You should use mmap , and depending on the paranoid security policies on your system, you might need to use mprotect too for changing the permissions. Among the reasons malloc is not the right tool: Permissions are set