Re: MAP_FIXED for ELF mappings

2017-10-05 Thread Michal Hocko
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); > > > -

Re: MAP_FIXED for ELF mappings

2017-10-05 Thread Oleg Nesterov
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)) > > -

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Michal Hocko
On Wed 04-10-17 10:15:31, Linus Torvalds wrote: > On Wed, Oct 4, 2017 at 10:12 AM, Michal Hocko wrote: > > > > Yes, but we already have a new stack mapped and that was the point of > > the referenced CVE where the binary segments got mapped over the stack > > AFAIU. > > Well, if you control the b

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Linus Torvalds
On Wed, Oct 4, 2017 at 10:12 AM, Michal Hocko wrote: > > Yes, but we already have a new stack mapped and that was the point of > the referenced CVE where the binary segments got mapped over the stack > AFAIU. Well, if you control the binary to the point where you just make the ELF section map on

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Michal Hocko
On Wed 04-10-17 23:37:41, Baoquan He wrote: > On 10/04/17 at 05:17pm, Michal Hocko wrote: > > On Wed 04-10-17 23:12:38, Baoquan He wrote: > > > I made a clean up patch according to Oleg's suggestion. It's trying to > > > get an map area to cover total_size, then do mmap for for the 1st > > > progra

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Baoquan He
On 10/04/17 at 05:17pm, Michal Hocko wrote: > On Wed 04-10-17 23:12:38, Baoquan He wrote: > > I made a clean up patch according to Oleg's suggestion. It's trying to > > get an map area to cover total_size, then do mmap for for the 1st > > program segment only. Not sure if this way is correct. > >

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Michal Hocko
On Wed 04-10-17 23:12:38, Baoquan He wrote: > I made a clean up patch according to Oleg's suggestion. It's trying to > get an map area to cover total_size, then do mmap for for the 1st > program segment only. Not sure if this way is correct. > > >From 40f231bb78a74caebcb4a898089a9fa5323be05f Mon S

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Michal Hocko
On Wed 04-10-17 23:03:34, Baoquan He wrote: > On 10/04/17 at 09:50am, Michal Hocko wrote: > > Hi, > > while studying CVE-2017-1000253 and the MAP_FIXED usage in load_elf* > > code paths I have stumbled over MAP_FIXED usage for elf segments > > mapping. I am not really familiar with this area much s

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Baoquan He
I made a clean up patch according to Oleg's suggestion. It's trying to get an map area to cover total_size, then do mmap for for the 1st program segment only. Not sure if this way is correct. >From 40f231bb78a74caebcb4a898089a9fa5323be05f Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Fri, 29 Se

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Baoquan He
On 10/04/17 at 09:50am, Michal Hocko wrote: > Hi, > while studying CVE-2017-1000253 and the MAP_FIXED usage in load_elf* > code paths I have stumbled over MAP_FIXED usage for elf segments > mapping. I am not really familiar with this area much so I might draw > completely incorrect conclusions here

Re: MAP_FIXED for ELF mappings

2017-10-04 Thread Michal Hocko
Dohh, screwed up From. Sorry for spamming. On Wed 04-10-17 09:50:59, Michal Hocko wrote: > Hi, > while studying CVE-2017-1000253 and the MAP_FIXED usage in load_elf* > code paths I have stumbled over MAP_FIXED usage for elf segments > mapping. I am not really familiar with this area much so I migh