[MPlayer-dev-eng] Re: amd64 -sws 0 fix (iow: playing with NX bit)

Aurelien Jacobs aurel at gnuage.org
Mon Jan 24 15:39:44 CET 2005


On Mon, 24 Jan 2005 13:31:05 +0100
Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:

> On Mon, Jan 24, 2005 at 03:07:06AM +0100, Aurelien Jacobs wrote:
> > On Fri, 21 Jan 2005 21:40:34 +0100
> > Alex Beregszaszi <alex at fsn.hu> wrote:
> > > > > trivial diff to disable NX bit via mprotect().
> > > > 
> > > > Very nice ! That's exactly what I was looking for.
> > > > But your code has a small problem. The pointer you pass to mprotect
> > > > is not aligned on a PAGESIZE (which is required by mprotect).
> > > 
> > > What about aligning the funnycode stuff ? so no non-appropriate part of
> > > the memory would be set to exec enable
> > 
> > Right ! That would be more secure.
> > I first wanted to achieve this trivially by using
> > __attribute__((aligned(PAGESIZE))) but it seems that the linker don't
> > accept too high alignment values.
> > So I finally used a memalign() block to store the funny code.
> > This patch is now better.
> 
> How about just using anonymous mmap instead of malloc+mprotect?
> According to my understandig of its manpage it should work...

Right, it works. But I don't like this too much. It less readable and not
really simpler IMHO.
Do you think this patch is really better or should I stick with my
memalign() version ?

Aurel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mprotect4.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/91aeb570/attachment.txt>


More information about the MPlayer-dev-eng mailing list