Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED!nerds-end From: =?UTF-8?B?U8OpYmFzdGllbiBGcmlja2Vy?= Newsgroups: comp.compilers Subject: Re: Executing from dynamically allocated memory Date: Sat, 12 Oct 2013 11:52:11 +0200 Organization: Compilers Central Lines: 26 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-10-006@comp.compilers> References: <13-10-004@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1381603961 83592 64.57.183.58 (12 Oct 2013 18:52:41 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 12 Oct 2013 18:52:41 +0000 (UTC) Keywords: architecture, code Posted-Date: 12 Oct 2013 14:52:41 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:989 On 12.10.13 02:05, news wrote: > In the past, I've malloc'd memory, written machine instructions into it, > and called the function I built there. ... > Now it was a year or three ago that this worked. Has Linux changed in > this respect? Is there something new I have to do to allocate executable > writable memory for this purpose? > > Or might there be something even weirder going on? > > -- hendrik > > [ Sounds like the NX bit. See http://en.wikipedia.org/wiki/NX_bit#Linux -John] Hendrik, this does not wonder me that it does not work anymore. In 2003, I was working on the ARM-Linux kernel and I could see that more and more the MMU protection bit get used principally to avoid the possibility to misuse buffer-overflow. But did you have a look on mmap()? (man mmap) There is a flag PROT_EXEC. I guess this should permit to create a memory area on which you can execute code. SC)bastien