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

Aurelien Jacobs aurel at gnuage.org
Tue Jan 25 14:00:36 CET 2005


On Tue, 25 Jan 2005 10:22:07 +0100
Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:

> Hi,
> On Mon, Jan 24, 2005 at 08:43:07PM +0100, Aurelien Jacobs wrote:
> > On Mon, 24 Jan 2005 15:53:06 +0100
> > Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> > > On Mon, Jan 24, 2005 at 03:39:44PM +0100, Aurelien Jacobs wrote:
> > > > 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:
> > > > > 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.
> > > 
> > > With all that alignment? And you have to find out the page size etc. for
> > > the other variant...
> > 
> > Hum... did you had a look at my mmap patch ?
> > It also check PAGESIZE to ensure that only funnyCode and nothing more
> > Maybe it's not useful ? I don't know if mmap only alloc full pages or
> > if non used end of page can be malloced later ?
> 
> mmap always allocates full pages AFAIK, so no need to use or know PAGESIZE there.

Ok, that's nice :-)

> > Finally what do you think is the best solution ?
> 
> I very much prefer the mmap version, it looks much less "hackish" to me. And makes less assumptions. It can even work if the program is not allowed to
> change permissions after allocating a memory area (enforcing this might be a good idea security-wise).

I now agree that mmap is better.

> One question is open though: what to do when mmap fails... Try with normal malloced memory (i.e. fallback to version when no mmap is available) and
> print warning?

According to the man page, the only error we can get when using
this set of flags (especially MAP_ANONYMOUS) is ENOMEM. But then
malloc won't do better.
So I think it not worth to verify if mmap failed.
Moreover, if we default to malloc when mmap fail, we would need to
add a flag somewhere to know if we should free or munmap at uninit.

I hope this new patch is finally the last one.

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


More information about the MPlayer-dev-eng mailing list