netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* user controllable usermodehelper in br_stp_if.c
@ 2015-11-29 22:43 Richard Weinberger
  2015-11-30 20:14 ` Kees Cook
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Weinberger @ 2015-11-29 22:43 UTC (permalink / raw)
  To: netdev@vger.kernel.org
  Cc: bridge, linux-kernel@vger.kernel.org, keescook@chromium.org,
	kernel-hardening@lists.openwall.com

Hi!

By spawning new network and user namesapces an unprivileged user
is able to execute /sbin/bridge-stp within the initial mount namespace
with global root rights.
While this cannot directly be used to break out of a container or gain
global root rights it could be used by exploit writers as valuable building block.

e.g.
$ unshare -U -r -n /bin/sh
$ brctl addbr br0
$ brctl stp br0 on # this will execute /sbin/bridge-stp

As this mechanism clearly cannot work with containers and seems to be legacy code
I suggest not calling call_usermodehelper() at all if we're not in the initial user namespace.
What do you think?

Thanks,
//richard

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH net] bridge: Only call /sbin/bridge-stp for the initial network namespace
@ 2016-01-05  9:46 Hannes Frederic Sowa
  0 siblings, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2016-01-05  9:46 UTC (permalink / raw)
  To: netdev; +Cc: Eric W. Biederman

[I stole this patch from Eric Biederman. He wrote:]

> There is no defined mechanism to pass network namespace information
> into /sbin/bridge-stp therefore don't even try to invoke it except
> for bridge devices in the initial network namespace.
>
> It is possible for unprivileged users to cause /sbin/bridge-stp to be
> invoked for any network device name which if /sbin/bridge-stp does not
> guard against unreasonable arguments or being invoked twice on the
> same network device could cause problems.

[Hannes: changed patch using netns_eq]

Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 net/bridge/br_stp_if.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 905cedd37a0539..a31ac6ad76a223 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -143,7 +143,10 @@ static void br_stp_start(struct net_bridge *br)
 	char *envp[] = { NULL };
 	struct net_bridge_port *p;
 
-	r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
+	if (net_eq(dev_net(br->dev), &init_net))
+		r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
+	else
+		r = -ENOENT;
 
 	spin_lock_bh(&br->lock);
 
-- 
2.5.0

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

end of thread, other threads:[~2016-01-05  9:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-29 22:43 user controllable usermodehelper in br_stp_if.c Richard Weinberger
2015-11-30 20:14 ` Kees Cook
2015-11-30 21:38   ` [PATCH net] bridge: Only call /sbin/bridge-stp for the initial network namespace Eric W. Biederman
2015-11-30 22:12     ` Stephen Hemminger
2015-11-30 22:16       ` Eric W. Biederman
2015-11-30 22:57     ` Richard Weinberger
2015-12-01 14:13     ` Hannes Frederic Sowa
2015-12-03  4:50     ` David Miller
2015-12-08 20:56       ` Kees Cook
2015-11-30 23:03   ` user controllable usermodehelper in br_stp_if.c Richard Weinberger
  -- strict thread matches above, loose matches on Subject: below --
2016-01-05  9:46 [PATCH net] bridge: Only call /sbin/bridge-stp for the initial network namespace Hannes Frederic Sowa

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).