Suppose setuid
/setgid
bits are of no concern. Why is there a separate permission for execution?
Philosophically, it feels to me that the write permission subsumes the read permission, and that the read permission subsumes the execute permission. Of course, things aren't this way in Linux, and this can sometimes be useful, but I would reckon that it rarely is. For instance, if a process can read a file that isn't executable, then as long as that process can write in some directory, it can simply copy the file there, set the execute bit, and then run that program. So truly, read subsumes execute in simple cases. Obviously this isn't going to work properly if the source file has the setuid bit, or if the process can only write in noexec mount points.
The reason that I ask is that I'm implementing a Linux syscall that would allow a process to exec
an arbitrary chunk of its memory. (The specific use case is that I have a full program bundled within my main program, and I don't want to write it to disk in order to call execve
.) Are there any serious concerns with such a syscall that I should be aware of?