[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: non random mmap



Le Wed, May 31, 2006 at 02:49:36PM -0400, Scott Reese écrivait/wrote:
> Basile STARYNKEVITCH wrote:
> > Dear All,
> > 
> > I have an AMD64x2 4400 using Debian/Sid/AMD64 
> > I have a self built  2.6.16.18 kernel.
> > 
> > I want to have the mmap system call behaving predictably and in a
> > reproducable manner (because I am debugging a copying garbage collector).


> I think that what you're looking for is MAP_FIXED in your mmap call.

No. The MAP_FIXED flag is useful when the calling program want to constraint
the memory map to a fixed address, as the man page says

       MAP_FIXED  

                  Do not select a different address than the one specified. If
                  the memory region specified by start and len overlaps
                  pages of any existing mapping(s), then the overlapped part
                  of the existing mapping(s) will be discarded. If the
                  specified address cannot be used, mmap() will fail. If
                  MAP_FIXED is specified, start must be a multiple of the
                  pagesize. Use of this option is discouraged.

The danger of MAP_FIXED is that the calling program should provide the start
address (and if any overlap occur with existing mapping, they are
truncated).

What I want (this was the behavior in previous kernel, surely the 2.4
series, and probably some older 2.6 like 2.6.5) is a reproducible mmap
behavior. Two identical runs of the same program should make the same mmaps.

In a more prevcise fashion, I want to clear the PF_RANDOMIZE flag in the
task_struct of my processes. (grep the kernel source for it). But I did not
found how. (I'm expecting a sysctl ...) I thought that the chpax command
would do it...

See also  http://www.ussg.iu.edu/hypermail/linux/kernel/0512.1/0091.html
http://pax.grsecurity.net/docs/randmmap.txt


Regards.
 

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France



Reply to: