Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.lightlink.com!news.iecc.com!.POSTED!nerds-end From: sandmann@cs.au.dk (=?utf-8?Q?S=C3=B8ren?= Sandmann) Newsgroups: comp.compilers Subject: Re: Executing from dynamically allocated memory Date: Sat, 12 Oct 2013 20:58:42 +0200 Organization: SunSITE.dk - Supporting Open source Lines: 28 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-10-009@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 Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1381605789 88390 64.57.183.58 (12 Oct 2013 19:23:09 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 12 Oct 2013 19:23:09 +0000 (UTC) Keywords: architecture, history Posted-Date: 12 Oct 2013 15:23:09 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:992 "news" writes: > In the past, I've malloc'd memory, written machine instructions into it, > and called the function I built there. > > All this on a 32-bit intel instruction set, on a Debian system. > > This appears no longer too work. My program gives a segmentation fault. > The debugger tells me that the segmentation fault occurs on the first > instruction of the called function, a > push %ebp > residing in malloced memory. > > 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? It's probably just that anonymous memory is not executable by default anymore. Take a look at this: http://www.akkadia.org/drepper/selinux-mem.html in particular the execmem case. There is also example code. SC8ren