From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755186AbbK3WZX (ORCPT ); Mon, 30 Nov 2015 17:25:23 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:58393 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755055AbbK3WZQ (ORCPT ); Mon, 30 Nov 2015 17:25:16 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Stephen Hemminger Cc: David Miller , Richard Weinberger , "netdev\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "kernel-hardening\@lists.openwall.com" , bridge@lists.linux-foundation.org, Kees Cook References: <565B7F7D.80208@nod.at> <87egf7183c.fsf_-_@x220.int.ebiederm.org> <20151130141208.516b1046@xeon-e3> Date: Mon, 30 Nov 2015 16:16:52 -0600 In-Reply-To: <20151130141208.516b1046@xeon-e3> (Stephen Hemminger's message of "Mon, 30 Nov 2015 14:12:08 -0800") Message-ID: <87si3nxhd7.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1/WdGHDoSGY16wQSgMhOuzcMXxYSGEHpP4= X-SA-Exim-Connect-IP: 70.59.167.217 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 BAYES_40 BODY: Bayes spam probability is 20 to 40% * [score: 0.2739] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Stephen Hemminger X-Spam-Relay-Country: X-Spam-Timing: total 1441 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.9 (0.3%), b_tie_ro: 2.8 (0.2%), parse: 1.28 (0.1%), extract_message_metadata: 30 (2.1%), get_uri_detail_list: 3.3 (0.2%), tests_pri_-1000: 6 (0.4%), tests_pri_-950: 1.99 (0.1%), tests_pri_-900: 1.61 (0.1%), tests_pri_-400: 40 (2.8%), check_bayes: 38 (2.6%), b_tokenize: 13 (0.9%), b_tok_get_all: 12 (0.9%), b_comp_prob: 4.6 (0.3%), b_tok_touch_all: 4.3 (0.3%), b_finish: 0.82 (0.1%), tests_pri_0: 673 (46.7%), tests_pri_500: 678 (47.0%), poll_dns_idle: 663 (46.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH net] bridge: Only call /sbin/bridge-stp for the initial network namespace X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stephen Hemminger writes: > On Mon, 30 Nov 2015 15:38:15 -0600 > ebiederm@xmission.com (Eric W. Biederman) 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. >> >> Signed-off-by: "Eric W. Biederman" >> --- >> net/bridge/br_stp_if.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c >> index 5396ff08af32..742fa89528ab 100644 >> --- a/net/bridge/br_stp_if.c >> +++ b/net/bridge/br_stp_if.c >> @@ -142,7 +142,9 @@ 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); >> + r = -ENOENT; >> + if (dev_net(br->dev) == &init_net) >> + r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC); > > I don't think this will cause loud screams. > But it might break people that use containers to run virtual networks > for testing. I don't see how this interface can possibly be for more than the initial network namespace. There is no network namespace information conveyed and /sbin/bridge-stp always runs in the initial network namespace. Which is the point of this patch. Don't try when the code can not work. The only way this code could possibly work in the presence of multiple network namespaces is if somehow the network namespace was encoded in the device name, and then the usermode helper switched to the appropriate network namespace. I suspect that anyone knowledgable enough to know this interface exists would have sent a patch to fix the kernel to give network namespace information rather than use a horrible userspace hack like encoding the network namespace in the device name. > One coding nit: > Why are you afraid of using an else? Branch stalls. Plus in this case an else is more lines and just plain uglier code. Eric