linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] User namespace: don't allow sysctl in non-init user ns
@ 2011-09-15 19:48 Serge E. Hallyn
  0 siblings, 0 replies; 3+ messages in thread
From: Serge E. Hallyn @ 2011-09-15 19:48 UTC (permalink / raw)
  To: lkml
  Cc: Eric W. Biederman, Linux Containers, Andrew Morton,
	Vasiliy Kulikov, richard

sysctl.c has its own custom uid check, which is not user namespace
aware.  As discovered by Richard, that allows root in a container
privileged access to set all sysctls.

To fix that, just refuse access if current is not in init_user_ns.  We
may at some point want to relax that check so that some sysctls are
allowed - for instance dmesg_restrict when syslog is containerized.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Vasiliy Kulikov <segoon@openwall.com>
Cc: richard@nod.at
---
 kernel/sysctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 11d65b5..f2b42e2 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1697,6 +1697,8 @@ void register_sysctl_root(struct ctl_table_root *root)
 
 static int test_perm(int mode, int op)
 {
+	if (current_user_ns() != &init_user_ns)
+		return -EACCES;
 	if (!current_euid())
 		mode >>= 6;
 	else if (in_egroup_p(0))
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread
[parent not found: <xs4all.20110915194812.GA24348@sergelap>]

end of thread, other threads:[~2011-09-21 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 19:48 [PATCH] User namespace: don't allow sysctl in non-init user ns Serge E. Hallyn
     [not found] <xs4all.20110915194812.GA24348@sergelap>
2011-09-21  9:46 ` Miquel van Smoorenburg
2011-09-21 13:15   ` Serge E. Hallyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).