Re: Executing from dynamically allocated memory

sandmann@cs.au.dk (=?utf-8?Q?S=C3=B8ren?= Sandmann)
Sat, 12 Oct 2013 20:58:42 +0200

          From comp.compilers

Related articles
Executing from dynamically allocated memory news@fx32.iad.highwinds-media.com (news) (2013-10-12)
Re: Executing from dynamically allocated memory james.harris.1@gmail.com (James Harris) (2013-10-12)
Re: Executing from dynamically allocated memory sebastien.fricker@gmail.com (=?UTF-8?B?U8OpYmFzdGllbiBGcmlja2Vy?=) (2013-10-12)
Re: Executing from dynamically allocated memory chakaram@auth.gr (2013-10-12)
Re: Executing from dynamically allocated memory blog@rivadpm.com (Alex McDonald) (2013-10-12)
Re: Executing from dynamically allocated memory sandmann@cs.au.dk (2013-10-12)
Re: Executing from dynamically allocated memory jkallup@web.de (Jens Kallup) (2013-10-13)
| List of all articles for this month |
From: sandmann@cs.au.dk (=?utf-8?Q?S=C3=B8ren?= Sandmann)
Newsgroups: comp.compilers
Date: Sat, 12 Oct 2013 20:58:42 +0200
Organization: SunSITE.dk - Supporting Open source
References: 13-10-004
Keywords: architecture, history
Posted-Date: 12 Oct 2013 15:23:09 EDT

"news" <news@fx32.iad.highwinds-media.com> 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



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.