From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754271AbbCQCqP (ORCPT ); Mon, 16 Mar 2015 22:46:15 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:49405 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754181AbbCQCqL (ORCPT ); Mon, 16 Mar 2015 22:46:11 -0400 X-Sasl-enc: dMNjAVAlw6KB41/IIOaN8PXIL1pvpzIBBmIMBQCRcxLw 1426560369 Subject: [RFC PATCH v4 10/12] nfs - objlayout use namespace if not executing in init namespace From: Ian Kent To: Kernel Mailing List Cc: David Howells , Oleg Nesterov , Trond Myklebust , "J. Bruce Fields" , Benjamin Coddington , Al Viro , Jeff Layton , "Eric W. Biederman" Date: Tue, 17 Mar 2015 10:45:55 +0800 Message-ID: <20150317024554.24592.52603.stgit@pluto.fritz.box> In-Reply-To: <20150317022308.24592.35785.stgit@pluto.fritz.box> References: <20150317022308.24592.35785.stgit@pluto.fritz.box> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Kent If the caller is running within a container then execute the usermode helper callback within the init namespace of the container. Signed-off-by: Ian Kent Cc: Benjamin Coddington Cc: Al Viro Cc: J. Bruce Fields Cc: David Howells Cc: Trond Myklebust Cc: Oleg Nesterov Cc: Eric W. Biederman Cc: Jeff Layton --- fs/nfs/objlayout/objlayout.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c index 919efd4..00c9a34 100644 --- a/fs/nfs/objlayout/objlayout.c +++ b/fs/nfs/objlayout/objlayout.c @@ -599,9 +599,14 @@ static int __objlayout_upcall(struct __auto_login *login) "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; + unsigned int umh_flags = UMH_WAIT_PROC; char *argv[8]; int ret; + /* If running within a container use the container namespace */ + if (current->nsproxy->net_ns != &init_net) + umh_flags |= UMH_USE_NS; + if (unlikely(!osd_login_prog[0])) { dprintk("%s: osd_login_prog is disabled\n", __func__); return -EACCES; @@ -620,7 +625,7 @@ static int __objlayout_upcall(struct __auto_login *login) argv[6] = login->systemid_hex; argv[7] = NULL; - ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); + ret = call_usermodehelper(argv[0], argv, envp, umh_flags); /* * Disable the upcall mechanism if we're getting an ENOENT or * EACCES error. The admin can re-enable it on the fly by using