Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 09:29:15PM +0200, Oleg Nesterov wrote: > On 08/23, Cyrill Gorcunov wrote: > > > > On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: > > > > > > And btw, where do you see RLIMIT_STACK in do_shmat() ? > > > > Indirectly, though start_stack pointer. We assign it

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: > > On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: > > > > And btw, where do you see RLIMIT_STACK in do_shmat() ? > > Indirectly, though start_stack pointer. We assign it in setup_arg_pages > taking into > account RLIMIT_STACK value, then do_shmat

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: > > > > > > Besides, it can't help anyway. cred_guard_mutex is per-process (not > > > per-thread), > > > suppose that a vfork()'ed child does prctl() while another thread reads > > > the > > > parent's /proc/pid/auxv. > > > > Then

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: > > On Sat, Aug 23, 2014 at 03:30:01PM +0200, Oleg Nesterov wrote: > > > > On 08/23, Oleg Nesterov wrote: > > > > > > On 08/23, Cyrill Gorcunov wrote: > > > > > > > Looks like I need > > > > to use cred_guard_mutex instead of task_lock here, no? > > > > > > Please

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 03:30:01PM +0200, Oleg Nesterov wrote: > forgot to mention, > > On 08/23, Oleg Nesterov wrote: > > > > On 08/23, Cyrill Gorcunov wrote: > > > > > Looks like I need > > > to use cred_guard_mutex instead of task_lock here, no? > > > > Please don't. First of all, it can't

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
forgot to mention, On 08/23, Oleg Nesterov wrote: > > On 08/23, Cyrill Gorcunov wrote: > > > Looks like I need > > to use cred_guard_mutex instead of task_lock here, no? > > Please don't. First of all, it can't help because proc_pid_auxv() doesn't hold > this lock. It does mm_access() which drops

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: > > On Sat, Aug 23, 2014 at 01:53:02PM +0200, Oleg Nesterov wrote: > > > > > > It should protect from allocation/devetion/mergin of another vma. IOW when > > > I lookup for vma I need to be sure it exist and won't disappear at least > > > while I validate it. > > >

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 01:53:02PM +0200, Oleg Nesterov wrote: > > > > It should protect from allocation/devetion/mergin of another vma. IOW when > > I lookup for vma I need to be sure it exist and won't disappear at least > > while I validate it. > > plus you need mmap_sem (at least for reading)

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: > > On Fri, Aug 22, 2014 at 09:22:41PM +0200, Oleg Nesterov wrote: > > Hi Cyrill, > > > > I think the patch is fine but I can't understand the usage of mmap_sem > > and alloc_lock, > > > > > + stack_vma = find_vma(mm, (unsigned long)prctl_map->start_stack); > > > >

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: On Fri, Aug 22, 2014 at 09:22:41PM +0200, Oleg Nesterov wrote: Hi Cyrill, I think the patch is fine but I can't understand the usage of mmap_sem and alloc_lock, + stack_vma = find_vma(mm, (unsigned long)prctl_map-start_stack); OK, find_vma()

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 01:53:02PM +0200, Oleg Nesterov wrote: It should protect from allocation/devetion/mergin of another vma. IOW when I lookup for vma I need to be sure it exist and won't disappear at least while I validate it. plus you need mmap_sem (at least for reading) when you

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: On Sat, Aug 23, 2014 at 01:53:02PM +0200, Oleg Nesterov wrote: It should protect from allocation/devetion/mergin of another vma. IOW when I lookup for vma I need to be sure it exist and won't disappear at least while I validate it. plus you need

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
forgot to mention, On 08/23, Oleg Nesterov wrote: On 08/23, Cyrill Gorcunov wrote: Looks like I need to use cred_guard_mutex instead of task_lock here, no? Please don't. First of all, it can't help because proc_pid_auxv() doesn't hold this lock. It does mm_access() which drops this lock

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 03:30:01PM +0200, Oleg Nesterov wrote: forgot to mention, On 08/23, Oleg Nesterov wrote: On 08/23, Cyrill Gorcunov wrote: Looks like I need to use cred_guard_mutex instead of task_lock here, no? Please don't. First of all, it can't help because

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: On Sat, Aug 23, 2014 at 03:30:01PM +0200, Oleg Nesterov wrote: On 08/23, Oleg Nesterov wrote: On 08/23, Cyrill Gorcunov wrote: Looks like I need to use cred_guard_mutex instead of task_lock here, no? Please don't. First of all, it can't

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: Besides, it can't help anyway. cred_guard_mutex is per-process (not per-thread), suppose that a vfork()'ed child does prctl() while another thread reads the parent's /proc/pid/auxv. Then either I need to use

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Oleg Nesterov
On 08/23, Cyrill Gorcunov wrote: On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: And btw, where do you see RLIMIT_STACK in do_shmat() ? Indirectly, though start_stack pointer. We assign it in setup_arg_pages taking into account RLIMIT_STACK value, then do_shmat operates

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-23 Thread Cyrill Gorcunov
On Sat, Aug 23, 2014 at 09:29:15PM +0200, Oleg Nesterov wrote: On 08/23, Cyrill Gorcunov wrote: On Sat, Aug 23, 2014 at 05:32:22PM +0200, Oleg Nesterov wrote: And btw, where do you see RLIMIT_STACK in do_shmat() ? Indirectly, though start_stack pointer. We assign it in

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-22 Thread Cyrill Gorcunov
On Fri, Aug 22, 2014 at 09:22:41PM +0200, Oleg Nesterov wrote: > Hi Cyrill, > > I think the patch is fine but I can't understand the usage of mmap_sem > and alloc_lock, > > > + stack_vma = find_vma(mm, (unsigned long)prctl_map->start_stack); > > OK, find_vma() needs mmap_sem. But otherwise,

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-22 Thread Oleg Nesterov
Hi Cyrill, I think the patch is fine but I can't understand the usage of mmap_sem and alloc_lock, > + stack_vma = find_vma(mm, (unsigned long)prctl_map->start_stack); OK, find_vma() needs mmap_sem. But otherwise, why this should be called under down_read(>mmap_sem) ? What this lock tries to

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-22 Thread Oleg Nesterov
Hi Cyrill, I think the patch is fine but I can't understand the usage of mmap_sem and alloc_lock, + stack_vma = find_vma(mm, (unsigned long)prctl_map-start_stack); OK, find_vma() needs mmap_sem. But otherwise, why this should be called under down_read(mm-mmap_sem) ? What this lock tries to

Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree

2014-08-22 Thread Cyrill Gorcunov
On Fri, Aug 22, 2014 at 09:22:41PM +0200, Oleg Nesterov wrote: Hi Cyrill, I think the patch is fine but I can't understand the usage of mmap_sem and alloc_lock, + stack_vma = find_vma(mm, (unsigned long)prctl_map-start_stack); OK, find_vma() needs mmap_sem. But otherwise, why this