Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752806AbbBJQ4Z (ORCPT ); Tue, 10 Feb 2015 11:56:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39711 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762AbbBJQ4Y (ORCPT ); Tue, 10 Feb 2015 11:56:24 -0500 Date: Tue, 10 Feb 2015 17:55:03 +0100 From: Oleg Nesterov To: Ian Kent Cc: Kernel Mailing List , David Howells , Trond Myklebust , "J. Bruce Fields" , Benjamin Coddington , Al Viro , Jeff Layton , "Eric W. Biederman" Subject: Re: [RFC PATCH 3/8] kmod - teach call_usermodehelper() to use a namespace Message-ID: <20150210165503.GA6797@redhat.com> References: <20150205021553.8382.16297.stgit@pluto.fritz.box> <20150205023410.8382.13695.stgit@pluto.fritz.box> <20150208190019.GA22948@redhat.com> <1423446203.2583.18.camel@pluto.fritz.box> <20150209160328.GA2817@redhat.com> <1423526889.2612.14.camel@pluto.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1423526889.2612.14.camel@pluto.fritz.box> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2127 Lines: 72 On 02/10, Ian Kent wrote: > > On Mon, 2015-02-09 at 17:03 +0100, Oleg Nesterov wrote: > > > > I understand. but I still can't understand why we can't implement something > > like > > enter_ns(struct nsproxy *p) > > { > > new_nsproxy = create_new_namespaces(...); > > > > p->mnt_ns->ns->ops->install(new_nsproxy, ...); > > p->pid_ns_for_children->ns->ops->install(new_nsproxy, ...); > > ... > > > > switch_task_namespaces(new_nsproxy); > > } > > > > Why we should abuse fs/proc ? > > That sounds like a much better approach. > Your saying just take a reference to the nsproxy from the located > process and use it instead, right? Yes, > Working out if there's a difference with what you from the open is > challenging (I already tried), I'll have another go at it. I thinks there should not be any difference, but please re-check ;) > > And. Whatever we do, ops->install() or setns_inode() can't solve the problem with > > pid_ns. You need the additional clone() to "activate" it. pidns_install() does not > > actually change task_active_pid_ns(). > > Right, but all this is done in preparation for the following do_execve() > call. Isn't that enough or am I missing something? Yes, but do_execve() doesn't (and shouldn't) change task_active_pid_ns(). Note the ->pid_ns_for_children's name. It is only used by copy_process()->alloc_pid(). task_active_pid_ns() uses task_pid() and we obviously can't change it. I am wondering if we can do something like kernel_thread_in_ns(struct nsproxy *ns, ...) { struct nsproxy *saved_ns = current->nsproxy; pid_t pid; task_lock(current); current->nsproxy = ns; task_unlock(current); pid = kernel_thread(...); task_lock(current); current->nsproxy = saved_ns; task_unlock(current); return pid; } used by __call_usermodehelper/wait_for_helper, instead of "enter_ns" from sub_info->init()... Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/