Re: MAP_FIXED for ELF mappings

From: Michal Hocko
Date: Thu Oct 05 2017 - 12:42:57 EST


On Thu 05-10-17 18:33:20, Oleg Nesterov wrote:
> On 10/04, Michal Hocko wrote:
> >
> > On Wed 04-10-17 23:12:38, Baoquan He wrote:
> > > if (total_size) {
> > > total_size = ELF_PAGEALIGN(total_size);
> > > - map_addr = vm_mmap(filep, addr, total_size, prot, flags, off);
> > > - if (!BAD_ADDR(map_addr))
> > > - vm_munmap(map_addr+size, total_size-size);
> > > - } else
> > > - map_addr = vm_mmap(filep, addr, size, prot, flags, off);
> > > + addr = get_unmapped_area(file, addr, total_size, off, flags);
> >
> > So how does this prevent clobbering an existing VMA when flags contains
> > MAP_FIXED?
>
> I got lost...
>
> this is just cleanup, it should not change the behaviour, with or without
> MAP_FIXED. It just avoids the mmap(total_size) + munmap(extra_size).

OK, I have clearly misunderstood the intention then.
--
Michal Hocko
SUSE Labs