[RHEL7,COMMIT] ve/fs: allow mount fs in init userns if it's mounted in another userns

Submitted by Konstantin Khorenko on July 2, 2018, 12:10 p.m.

Details

Message ID 201807021210.w62CAW5L012566@finist_ce7.work
State New
Series "ve/fs: allow mount fs in init userns if it's mounted in another userns"
Headers show

Commit Message

Konstantin Khorenko July 2, 2018, 12:10 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.8
------>
commit f8a3e221f5d2bf09a195ab9488b952261dc35c4a
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Mon Jul 2 14:46:09 2018 +0300

    ve/fs: allow mount fs in init userns if it's mounted in another userns
    
    We mount secondary ploop on host for resize functionality so allow mount
    in init userns if fs already mounted in non-init userns.
    
    https://jira.sw.ru/browse/PSBM-68599
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 fs/super.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/super.c b/fs/super.c
index 221e681c909c..ca9bd0d261ba 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -494,7 +494,12 @@  struct super_block *sget_userns(struct file_system_type *type,
 		hlist_for_each_entry(old, &type->fs_supers, s_instances) {
 			if (!test(old, data))
 				continue;
-			if (user_ns != old->s_user_ns) {
+			/* PSBM-86208: we mount secondary ploop on host for
+			 * resize functionality so allow mount in init userns
+			 * if fs already mounted in non-init userns
+			 */
+			if (user_ns != old->s_user_ns &&
+			    user_ns != &init_user_ns) {
 				spin_unlock(&sb_lock);
 				if (s) {
 					up_write(&s->s_umount);