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

Jindrich Makovicka makovick at kmlinux.fjfi.cvut.cz
Mon Jan 24 10:49:14 CET 2005

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.
> Aurel
> +#define MAX_FUNNY_CODE_SIZE 10000

Shouldn't it be also a multiple of the pagesize? Otherwise some memory 
could be later malloc'd after the funnycode, which will be executable 
too. I didn't see anything about aligning the allocated size in memalign(3).


More information about the MPlayer-dev-eng mailing list