[RFC PATCH 5 5/7] nfs - objlayout use service thread if not executing in init namespace

2015-03-30 Thread Ian Kent
From: Ian Kent 

If the caller is running within a container then execute the usermode
helper callback within the container also.

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 |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c
index 919efd4..1d4fd11 100644
--- a/fs/nfs/objlayout/objlayout.c
+++ b/fs/nfs/objlayout/objlayout.c
@@ -600,8 +600,14 @@ static int __objlayout_upcall(struct __auto_login *login)
NULL
};
char *argv[8];
+   int umh_token;
int ret;
 
+   /* If running within a container use the container namespace */
+   umh_token = 0;
+   if (current->nsproxy->net_ns != _net)
+   umh_token = umh_wq_get_token(0, "objlayout");
+
if (unlikely(!osd_login_prog[0])) {
dprintk("%s: osd_login_prog is disabled\n", __func__);
return -EACCES;
@@ -620,7 +626,13 @@ 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);
+   if (!umh_token)
+   ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
+   else {
+   ret = call_usermodehelper_service(argv[0], argv, envp,
+ umh_token, UMH_WAIT_PROC);
+   umh_wq_put_token(umh_token);
+   }
/*
 * Disable the upcall mechanism if we're getting an ENOENT or
 * EACCES error. The admin can re-enable it on the fly by using

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 5 5/7] nfs - objlayout use service thread if not executing in init namespace

2015-03-30 Thread Ian Kent
From: Ian Kent ik...@redhat.com

If the caller is running within a container then execute the usermode
helper callback within the container also.

Signed-off-by: Ian Kent ik...@redhat.com
Cc: Benjamin Coddington bcodd...@redhat.com
Cc: Al Viro v...@zeniv.linux.org.uk
Cc: J. Bruce Fields bfie...@fieldses.org
Cc: David Howells dhowe...@redhat.com
Cc: Trond Myklebust trond.mykleb...@primarydata.com
Cc: Oleg Nesterov onest...@redhat.com
Cc: Eric W. Biederman ebied...@xmission.com
Cc: Jeff Layton jeff.lay...@primarydata.com
---
 fs/nfs/objlayout/objlayout.c |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c
index 919efd4..1d4fd11 100644
--- a/fs/nfs/objlayout/objlayout.c
+++ b/fs/nfs/objlayout/objlayout.c
@@ -600,8 +600,14 @@ static int __objlayout_upcall(struct __auto_login *login)
NULL
};
char *argv[8];
+   int umh_token;
int ret;
 
+   /* If running within a container use the container namespace */
+   umh_token = 0;
+   if (current-nsproxy-net_ns != init_net)
+   umh_token = umh_wq_get_token(0, objlayout);
+
if (unlikely(!osd_login_prog[0])) {
dprintk(%s: osd_login_prog is disabled\n, __func__);
return -EACCES;
@@ -620,7 +626,13 @@ 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);
+   if (!umh_token)
+   ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
+   else {
+   ret = call_usermodehelper_service(argv[0], argv, envp,
+ umh_token, UMH_WAIT_PROC);
+   umh_wq_put_token(umh_token);
+   }
/*
 * Disable the upcall mechanism if we're getting an ENOENT or
 * EACCES error. The admin can re-enable it on the fly by using

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/