logo       

Re: cytpes and non executable memory: msg#00023

python.ctypes

Subject: Re: cytpes and non executable memory

Bob Ippolito <bob@xxxxxxxxxx> writes:

> I don't know about windows, but mmap/msync/mprotect (or some similar
> mechanism) can and should be used to get pages that are executable.
> OpenBSD definitely doesn't have its heap marked executable on
> platforms that support it (they call this W^X, no page has both write
> and execute unless explicitly asked for).. Has anyone been testing
> there? I bought OpenBSD 3.5 cds when I went to BSDCan, but I haven't
> installed them anywhere yet, and I won't have that kind of free time
> for at least a week.
>
> -bob

I have libffi and ctypes running on OpenBSD 3.5. I had to hack some
preliminary code which uses mmap to allocate executable memory, and the
unittests now run without any failure.

But: mmap (or VirtualAlloc on Windows) return memory blocks with a size
rounded up to be a multiple of the system's pagesize - and it is
somewhat wasteful to use a 4k block when only 20 or 30 bytes are really
needed. So, it seems a very simple memory manager is needed. Since the
block size is always the same, it probably wouldn't be too complicated
to hack one, but isn't there a library I can reuse?

Thomas



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise