Re: [PATCH v2] prctl: PR_SET_MM - unify copying of user's auvx

2021-03-25 Thread Dmitry Safonov
Hi Cyrill, On 3/23/21 10:06 PM, Cyrill Gorcunov wrote: [..] > --- linux-tip.git.orig/kernel/sys.c > +++ linux-tip.git/kernel/sys.c > @@ -1961,6 +1961,30 @@ out: > return error; > } > > +static int copy_auxv_from_user(unsigned long *auxv, size_t auxv_size, > +

[PATCH v2] prctl: PR_SET_MM - unify copying of user's auvx

2021-03-23 Thread Cyrill Gorcunov
prctl(PR_SET_MM, PR_SET_MM_AUXV | PR_SET_MM_MAP, ...) copies user provided auxiliary vector to kernel and saves it to mm::saved_auxv, this involves same code in to places. Lets move it into one helper instead. When we copy data from user space we make sure that the vector ends up with AT_NULL key

Re: [PATCH -mm] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v4

2014-08-26 Thread Cyrill Gorcunov
On Mon, Aug 25, 2014 at 02:08:43PM +0400, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call, in particular once new user namespace > is cre

Re: [PATCH -mm] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v4

2014-08-26 Thread Cyrill Gorcunov
On Mon, Aug 25, 2014 at 02:08:43PM +0400, Cyrill Gorcunov wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable

[PATCH -mm] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v4

2014-08-25 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

[PATCH -mm] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v4

2014-08-25 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

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: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Fri, Aug 22, 2014 at 01:46:28PM -0700, Andrew Morton wrote: > On Sat, 23 Aug 2014 00:38:09 +0400 Cyrill Gorcunov wrote: > > > > > > > Or will we? What happens if we later decide that some additional field > > > needs to be added? Do we version the interface? Add a new prctl() > > > mode?

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Andrew Morton
On Sat, 23 Aug 2014 00:38:09 +0400 Cyrill Gorcunov wrote: > > > > Or will we? What happens if we later decide that some additional field > > needs to be added? Do we version the interface? Add a new prctl() > > mode? Let's cook up a plan for that and at least add to changelog? > > I don't

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Thu, Aug 21, 2014 at 11:49:12PM -0700, Andrew Morton wrote: > > > > > > But it's a bit hacky. Can anyone think of anything smarter? > > > > Looks good to me and not that hacky actually. > > Hacky :( I guess it's pretty safe because this is a userspace-visible > structure so we'll never be

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: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Andrew Morton
On Fri, 22 Aug 2014 10:32:42 +0400 Cyrill Gorcunov wrote: > > > + error |= __prctl_check_addr_space(start_code); > > > + error |= __prctl_check_addr_space(end_code); > > > + error |= __prctl_check_addr_space(start_data); > > > + error |= __prctl_check_addr_space(end_data); > > > + error |=

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Thu, Aug 21, 2014 at 03:51:15PM -0700, Andrew Morton wrote: ... > > > > Still note that updating exe-file link now doesn't require sys-resource > > capability anymore, after all there is no much profit in preventing setup > > own file link (there are a number of ways to execute own code --

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Thu, Aug 21, 2014 at 03:51:15PM -0700, Andrew Morton wrote: ... Still note that updating exe-file link now doesn't require sys-resource capability anymore, after all there is no much profit in preventing setup own file link (there are a number of ways to execute own code -- ptrace,

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Andrew Morton
On Fri, 22 Aug 2014 10:32:42 +0400 Cyrill Gorcunov gorcu...@gmail.com wrote: + error |= __prctl_check_addr_space(start_code); + error |= __prctl_check_addr_space(end_code); + error |= __prctl_check_addr_space(start_data); + error |= __prctl_check_addr_space(end_data); + error |=

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

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Thu, Aug 21, 2014 at 11:49:12PM -0700, Andrew Morton wrote: But it's a bit hacky. Can anyone think of anything smarter? Looks good to me and not that hacky actually. Hacky :( I guess it's pretty safe because this is a userspace-visible structure so we'll never be changing it.

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Andrew Morton
On Sat, 23 Aug 2014 00:38:09 +0400 Cyrill Gorcunov gorcu...@gmail.com wrote: Or will we? What happens if we later decide that some additional field needs to be added? Do we version the interface? Add a new prctl() mode? Let's cook up a plan for that and at least add to changelog?

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-22 Thread Cyrill Gorcunov
On Fri, Aug 22, 2014 at 01:46:28PM -0700, Andrew Morton wrote: On Sat, 23 Aug 2014 00:38:09 +0400 Cyrill Gorcunov gorcu...@gmail.com wrote: Or will we? What happens if we later decide that some additional field needs to be added? Do we version the interface? Add a new prctl()

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-21 Thread Andrew Morton
On Mon, 04 Aug 2014 21:22:59 +0400 Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call, in particular once new user namespace > is cre

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-21 Thread Andrew Morton
On Mon, 04 Aug 2014 21:22:59 +0400 Cyrill Gorcunov gorcu...@openvz.org wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-05 Thread Cyrill Gorcunov
On Tue, Aug 05, 2014 at 12:08:53PM +0400, Andrew Vagin wrote: > > > > Signed-off-by: Cyrill Gorcunov > > Cc: Kees Cook > > Cc: Tejun Heo > > Cc: Andrew Morton > > Cc: Andrew Vagin > > Acked-by: Andrew Vagin > > I have tested this patch with criu. Everything work as expected. Thanks

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-05 Thread Andrew Vagin
On Mon, Aug 04, 2014 at 09:22:59PM +0400, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call, in particular once new user namespace > is cre

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-05 Thread Andrew Vagin
On Mon, Aug 04, 2014 at 09:22:59PM +0400, Cyrill Gorcunov wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-05 Thread Cyrill Gorcunov
On Tue, Aug 05, 2014 at 12:08:53PM +0400, Andrew Vagin wrote: Signed-off-by: Cyrill Gorcunov gorcu...@openvz.org Cc: Kees Cook keesc...@chromium.org Cc: Tejun Heo t...@kernel.org Cc: Andrew Morton a...@linux-foundation.org Cc: Andrew Vagin ava...@openvz.org Acked-by: Andrew Vagin

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-04 Thread Serge E. Hallyn
Quoting Cyrill Gorcunov (gorcu...@openvz.org): > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call, in particular once new user namespace > is created capable(CAP_SYS_RESOURC

Re: [patch 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-08-04 Thread Serge E. Hallyn
Quoting Cyrill Gorcunov (gorcu...@openvz.org): > Instead of taking mm->mmap_sem inside prctl_set_mm_exe_file move > it out of and rename the helper to prctl_set_mm_exe_file_locked. > This will allow to reuse this function in a next patch. > > Signed-off-by: Cyrill Gorcunov > Cc: Kees Cook > Cc:

[patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-04 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

[patch 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-08-04 Thread Cyrill Gorcunov
Instead of taking mm->mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov Cc: Kees Cook Cc: Tejun Heo Cc: Andrew Morton Cc: Andrew Vagin Cc: Eric W.

[patch 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-08-04 Thread Cyrill Gorcunov
Instead of taking mm-mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov gorcu...@openvz.org Cc: Kees Cook keesc...@chromium.org Cc: Tejun Heo

[patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-04 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

Re: [patch 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-08-04 Thread Serge E. Hallyn
Quoting Cyrill Gorcunov (gorcu...@openvz.org): Instead of taking mm-mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov gorcu...@openvz.org Cc: Kees

Re: [patch 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-08-04 Thread Serge E. Hallyn
Quoting Cyrill Gorcunov (gorcu...@openvz.org): During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer

Re: [rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 12:31:54PM -0700, Kees Cook wrote: ... > > + > > +#ifdef CONFIG_STACK_GROWSUP > > + if (may_adjust_brk(rlimit(RLIMIT_STACK), > > + stack_vma->vm_end, > > + prctl_map->start_stack, 0, 0)) > > +#else > > + if

Re: [rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Kees Cook
On Thu, Jul 24, 2014 at 9:47 AM, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call, in particular once new user namespace > is created capable(CAP_

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 11:44:50AM -0700, Kees Cook wrote: ... > > > > The file can have a suid bit, so after executing it we may lose ability > > to attach to it. To check that we can check that uid and gid is zero > > in a current userns (local root). > > > > What else do we need to check? > >

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Kees Cook
On Thu, Jul 24, 2014 at 6:48 AM, Andrew Vagin wrote: > On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: >> > - @exe_fd is referred from /proc/$pid/exe and when generating >> >coredump. We uses prctl_set_mm_exe_file_locked helper to update >> >this member, so exe-file link

[rfc 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-07-24 Thread Cyrill Gorcunov
Instead of taking mm->mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov Cc: Kees Cook Cc: Tejun Heo Cc: Andrew Morton Cc: Andrew Vagin Cc: Eric W.

[rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 05:48:28PM +0400, Andrew Vagin wrote: > On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: > > > - @exe_fd is referred from /proc/$pid/exe and when generating > > >coredump. We uses prctl_set_mm_exe_file_locked helper to update > > >this member, so exe-file

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Andrew Vagin
On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: > > - @exe_fd is referred from /proc/$pid/exe and when generating > >coredump. We uses prctl_set_mm_exe_file_locked helper to update > >this member, so exe-file link modification remains one-shot > >action. > > Controlling

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Andrew Vagin
On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: - @exe_fd is referred from /proc/$pid/exe and when generating coredump. We uses prctl_set_mm_exe_file_locked helper to update this member, so exe-file link modification remains one-shot action. Controlling exe_fd

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 05:48:28PM +0400, Andrew Vagin wrote: On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: - @exe_fd is referred from /proc/$pid/exe and when generating coredump. We uses prctl_set_mm_exe_file_locked helper to update this member, so exe-file link

[rfc 3/4] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-07-24 Thread Cyrill Gorcunov
Instead of taking mm-mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov gorcu...@openvz.org Cc: Kees Cook keesc...@chromium.org Cc: Tejun Heo

[rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable(CAP_SYS_RESOURCE) no longer passes. A approach is to eliminate CAP_SYS_RESOURCE

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Kees Cook
On Thu, Jul 24, 2014 at 6:48 AM, Andrew Vagin ava...@parallels.com wrote: On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: - @exe_fd is referred from /proc/$pid/exe and when generating coredump. We uses prctl_set_mm_exe_file_locked helper to update this member, so exe-file

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 11:44:50AM -0700, Kees Cook wrote: ... The file can have a suid bit, so after executing it we may lose ability to attach to it. To check that we can check that uid and gid is zero in a current userns (local root). What else do we need to check? Yeah, I think

Re: [rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Kees Cook
On Thu, Jul 24, 2014 at 9:47 AM, Cyrill Gorcunov gorcu...@openvz.org wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace is created capable

Re: [rfc 4/4] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v3

2014-07-24 Thread Cyrill Gorcunov
On Thu, Jul 24, 2014 at 12:31:54PM -0700, Kees Cook wrote: ... + +#ifdef CONFIG_STACK_GROWSUP + if (may_adjust_brk(rlimit(RLIMIT_STACK), + stack_vma-vm_end, + prctl_map-start_stack, 0, 0)) +#else + if

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-22 Thread Cyrill Gorcunov
On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: > On Fri, Jul 11, 2014 at 10:36 AM, Cyrill Gorcunov wrote: > > On Wed, Jul 09, 2014 at 07:06:04PM +0400, Cyrill Gorcunov wrote: > >> > >> Thanks a lot for comments, Kees! I tend to agre, leaving off the @prctl_map > >> variable out of

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-22 Thread Kees Cook
k better. > --- > From: Cyrill Gorcunov > Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v2 > > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-22 Thread Kees Cook
Gorcunov gorcu...@openvz.org Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v2 During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call, in particular once new user namespace

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-22 Thread Cyrill Gorcunov
On Tue, Jul 22, 2014 at 01:07:51PM -0700, Kees Cook wrote: On Fri, Jul 11, 2014 at 10:36 AM, Cyrill Gorcunov gorcu...@gmail.com wrote: On Wed, Jul 09, 2014 at 07:06:04PM +0400, Cyrill Gorcunov wrote: Thanks a lot for comments, Kees! I tend to agre, leaving off the @prctl_map variable out

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-11 Thread Cyrill Gorcunov
ng something > in security aspects when time permits. I suppse this one should look better. --- From: Cyrill Gorcunov Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v2 During development of c/r we've noticed that in case if we need to support user namespaces we face a problem wi

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-11 Thread Cyrill Gorcunov
in security aspects when time permits. I suppse this one should look better. --- From: Cyrill Gorcunov gorcu...@openvz.org Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation, v2 During development of c/r we've noticed that in case if we need to support user namespaces we face a problem

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Cyrill Gorcunov
On Wed, Jul 09, 2014 at 07:53:10AM -0700, Kees Cook wrote: ... > > + > > + /* > > +* Make sure the pairs are ordered. > > +*/ > > +#define __prctl_check_order(__map, __m1, __m2) > > \ > > + (unsigned long)__map->__m2 <= (unsigned

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Kees Cook
comment since original "It takes >> a pointer of prctl_mm_map structure which carries all members to be >> updated" is too short. > > Here is a way more descriptove changelog I hope. Please poke me if > more details needed, or something should be improved/changed and >

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Cyrill Gorcunov
" is too short. Here is a way more descriptove changelog I hope. Please poke me if more details needed, or something should be improved/changed and etc. --- From: Cyrill Gorcunov Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation During development of c/r we've noticed that in ca

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Cyrill Gorcunov
, or something should be improved/changed and etc. --- From: Cyrill Gorcunov gorcu...@openvz.org Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Kees Cook
descriptove changelog I hope. Please poke me if more details needed, or something should be improved/changed and etc. --- From: Cyrill Gorcunov gorcu...@openvz.org Subject: prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation During development of c/r we've noticed that in case if we need

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-09 Thread Cyrill Gorcunov
On Wed, Jul 09, 2014 at 07:53:10AM -0700, Kees Cook wrote: ... + + /* +* Make sure the pairs are ordered. +*/ +#define __prctl_check_order(__map, __m1, __m2) \ + (unsigned long)__map-__m2 = (unsigned long)__map-__m1 +

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Cyrill Gorcunov
On Tue, Jul 08, 2014 at 02:38:30PM -0700, Andrew Morton wrote: > On Tue, 8 Jul 2014 23:08:49 +0400 Cyrill Gorcunov wrote: > > > Ping. Guys, any commens please? > > Well, allowing a process to modify pretty deep internals like this is > always scary from a security point of view, and now we're

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Andrew Morton
On Tue, 8 Jul 2014 23:08:49 +0400 Cyrill Gorcunov wrote: > Ping. Guys, any commens please? Well, allowing a process to modify pretty deep internals like this is always scary from a security point of view, and now we're removing CAP_SYS_RESOURCE protections. Yikes. Convince me we aren't

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Cyrill Gorcunov
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call. > > Current PR_SET_MM code forbids t

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Cyrill Gorcunov
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call. Current PR_SET_MM code forbids to modify fields

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Andrew Morton
On Tue, 8 Jul 2014 23:08:49 +0400 Cyrill Gorcunov gorcu...@gmail.com wrote: Ping. Guys, any commens please? Well, allowing a process to modify pretty deep internals like this is always scary from a security point of view, and now we're removing CAP_SYS_RESOURCE protections. Yikes. Convince me

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-08 Thread Cyrill Gorcunov
On Tue, Jul 08, 2014 at 02:38:30PM -0700, Andrew Morton wrote: On Tue, 8 Jul 2014 23:08:49 +0400 Cyrill Gorcunov gorcu...@gmail.com wrote: Ping. Guys, any commens please? Well, allowing a process to modify pretty deep internals like this is always scary from a security point of view, and

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-04 Thread Cyrill Gorcunov
On Fri, Jul 04, 2014 at 11:52:56AM +0400, Andrew Vagin wrote: > > + > > +struct prctl_mm_map { > > + unsigned long start_code; > > "unsigned long" has different sizes on x86_64 and x86, so a compat > is required for x32 processes on x64 kernel. Yes, good point. I think we can use u64/32

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-04 Thread Andrew Vagin
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call. > > Current PR_SET_MM code forbids t

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-04 Thread Andrew Vagin
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call. Current PR_SET_MM code forbids to modify fields

Re: [RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-04 Thread Cyrill Gorcunov
On Fri, Jul 04, 2014 at 11:52:56AM +0400, Andrew Vagin wrote: + +struct prctl_mm_map { + unsigned long start_code; unsigned long has different sizes on x86_64 and x86, so a compat is required for x32 processes on x64 kernel. Yes, good point. I think we can use u64/32 types instead

[RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-03 Thread Cyrill Gorcunov
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: > During development of c/r we've noticed that in case if we need to > support user namespaces we face a problem with capabilities in > prctl(PR_SET_MM, ...) call. Sigh, I updated changelog after I started writting the 0/

[RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-03 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call. Current PR_SET_MM code forbids to modify fields if no CAP_SYS_RESOURCE granted, but rather relies on one who use this interface is passing

[RFC 1/2] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-07-03 Thread Cyrill Gorcunov
Instead of taking mm->mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov Cc: Kees Cook Cc: Tejun Heo Cc: Andrew Morton Cc: Andrew Vagin Cc: Eric W.

[RFC 1/2] prctl: PR_SET_MM -- Factor out mmap_sem when update mm::exe_file

2014-07-03 Thread Cyrill Gorcunov
Instead of taking mm-mmap_sem inside prctl_set_mm_exe_file move it out of and rename the helper to prctl_set_mm_exe_file_locked. This will allow to reuse this function in a next patch. Signed-off-by: Cyrill Gorcunov gorcu...@openvz.org Cc: Kees Cook keesc...@chromium.org Cc: Tejun Heo

[RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-03 Thread Cyrill Gorcunov
During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call. Current PR_SET_MM code forbids to modify fields if no CAP_SYS_RESOURCE granted, but rather relies on one who use this interface is passing

[RFC 2/2] prctl: PR_SET_MM -- Introduce PR_SET_MM_MAP operation

2014-07-03 Thread Cyrill Gorcunov
On Thu, Jul 03, 2014 at 06:33:20PM +0400, Cyrill Gorcunov wrote: During development of c/r we've noticed that in case if we need to support user namespaces we face a problem with capabilities in prctl(PR_SET_MM, ...) call. Sigh, I updated changelog after I started writting the 0/0 message

Re: prctl(PR_SET_MM)

2013-02-23 Thread Amnon Shiloh
al file-systems. The code that does that was already included in the Linux kernel by the CRIU group, in the form of "prctl(PR_SET_MM)", but prior to this was enclosed within their private "#ifdef CONFIG_CHECKPOINT_RESTORE", which is normally disabled. It was not clear from you

Re: prctl(PR_SET_MM)

2013-02-23 Thread Amnon Shiloh
al file-systems. The code that does that was already included in the Linux kernel by the CRIU group, in the form of "prctl(PR_SET_MM)", but prior to this was enclosed within their private "#ifdef CONFIG_CHECKPOINT_RESTORE", which is normally disabled. It was not clear from you

Re: prctl(PR_SET_MM)

2013-02-23 Thread Amnon Shiloh
-systems. The code that does that was already included in the Linux kernel by the CRIU group, in the form of prctl(PR_SET_MM), but prior to this was enclosed within their private #ifdef CONFIG_CHECKPOINT_RESTORE, which is normally disabled. It was not clear from your answer, Andrew, whether you

Re: prctl(PR_SET_MM)

2013-02-23 Thread Amnon Shiloh
-systems. The code that does that was already included in the Linux kernel by the CRIU group, in the form of prctl(PR_SET_MM), but prior to this was enclosed within their private #ifdef CONFIG_CHECKPOINT_RESTORE, which is normally disabled. It was not clear from your answer, Andrew, whether you

  1   2   >