Re:Why do Windows functions all begin with a pointless MOV E...
by brohee on Thursday September 22, 2011 @08:20AM
(#3025795)
malloc()ed memory is executable if you mprotect() it to be so. malloc()ing memory and blindly executing it is definitely a bug OTOH. malloc() is mmap() based a lot of systems nowadays anyway, so malloc() vs mmap() is just a choice of convenience of API.
[ Parent
| on HN ]
Re:Why do Windows functions all begin with a pointless MOV E...
by haberman on Thursday September 22, 2011 @01:39PM
(#3026902)
> malloc()ed memory is executable if you mprotect() it to be so.
True, but since mprotect() can only operate on full pages your mprotect() calls will most likely affect memory beyond what malloc gave you. For example if remove write or execute permissions your program will probably crash, and it's best to avoid having pages that are both writable and executable.