public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Could not mount sysfs when enable userns but disable netns
@ 2014-07-11  7:27 chenhanxiao
  2014-07-11 14:28 ` Serge E. Hallyn
  0 siblings, 1 reply; 5+ messages in thread
From: chenhanxiao @ 2014-07-11  7:27 UTC (permalink / raw)
  To: Eric W. Biederman (ebiederm@xmission.com),
	Serge Hallyn (serge.hallyn@ubuntu.com), Greg Kroah-Hartman
  Cc: containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org,
	'Daniel P. Berrange (berrange@redhat.com)'

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1254 bytes --]

Hello,

How to reproduce:
1. Prepare a container, enable userns and disable netns
2. use libvirt-lxc to start a container
3. libvirt could not mount sysfs then failed to start.

Then I found that
commit 7dc5dbc879bd0779924b5132a48b731a0bc04a1e says:
"Don't allow mounting sysfs unless the caller has CAP_SYS_ADMIN rights
over the net namespace."

But why should we check sysfs mouont permission over net namespace?
We've already checked CAP_SYS_ADMIN though.

What the relationship between sysfs and net namespace,
or this check is a little redundant?

Any insights on this?

Thanks,
- Chen

PS: codes below could be a workaround

@@ -34,7 +35,8 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
                if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
                        return ERR_PTR(-EPERM);
 
-               if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
+               if (current->nsproxy->net_ns != &init_net &&
+                    !kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
                        return ERR_PTR(-EPERM);
        }
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-14 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11  7:27 Could not mount sysfs when enable userns but disable netns chenhanxiao
2014-07-11 14:28 ` Serge E. Hallyn
2014-07-11 16:29   ` Eric W. Biederman
2014-07-14  9:32     ` chenhanxiao
2014-07-14 17:23       ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox