Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4812110yba; Tue, 30 Apr 2019 04:55:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy03FsyFS2+LUv+fse/zXfvhiJACeGhMnhw14gOv/sTv7Qhoc/1izsNEVOYM/pRi0QRA1vb X-Received: by 2002:a62:5994:: with SMTP id k20mr14845270pfj.150.1556625354475; Tue, 30 Apr 2019 04:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625354; cv=none; d=google.com; s=arc-20160816; b=GvaMt83wmKo7m34t475w3Bd3sOTgU4wlsKVfckro9TxeaL9jC91jphubFCHIc+hBaF joK5yt4Edoqdbn4WIIoJw3EjtG/3rf/X9qvkhVCQ8KqroFB895nuhkI29iZiNWU4YNn7 3ZJbUCSlwNJamObmk61iw3iMM7R320tDV3iBzA7Vi8NglHEhF6A09UUBnYZmcEDOG/Oh hFf9bdt3qMghFHF75U9uJFVU63Ho6ShTEbK30atOxWWILxtsaCfC7R71cXE6XVY3RyVU gqRBrTX9VxINcUogGEGSIFHIZ7TBOxMAvy1ozqZxKyEwIcxeeJQebkxpwhUQeGeFWiBj K5Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j9vI+cFHCBe9BvuYH+OTVRdz0OqMT5QY7NjQbq3BO54=; b=amg3HcN2lhgJkYy9V94SDLYpadDZqnn/dpxADiOHkm+O4z1UfL7nE6L6fugh3sOocy Z/Cb2jGl700kNb25VAxDqxi1FzLsxAjrF6djGyej2h+bO0NrG1DzxSOQVyLHsEIUwzyt iIpMmYsyLj1wL6lWVdD4kbwZ8mMOr5J5y8aSZG2xwQO1hidF61TQlkNDXW9ot27MkKjA bg6k3LUICGb5e2YLpjSHwQJvLHwhZQC3h5SsNsbeN59OOCZJtK+ZF1PTePCqgfeVqjal C0rKAe6a/6NswWrUQiNXWQuc0DNS7ziaZC4o+kc3Ke2xmnVudJtgMrVmO9P5MKG8sSXk 5iaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G25+jRjr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si33213864pgq.528.2019.04.30.04.55.38; Tue, 30 Apr 2019 04:55:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G25+jRjr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731379AbfD3LvW (ORCPT + 99 others); Tue, 30 Apr 2019 07:51:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:38910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731367AbfD3LvR (ORCPT ); Tue, 30 Apr 2019 07:51:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A635521670; Tue, 30 Apr 2019 11:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625077; bh=+4WjDb9FV/4rePKrjQmde3TBFmURSqVCoxF/pRpRI/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G25+jRjrK9DNZwKScNzFCtmcZbPoJJiqv6GVLXpkR7viw8Mt4dg8MLfAG6rY1OYe8 SpHPQmFGrXr/VtWdGpKIbyga8L5EWGqPvap9Umt35iSVh4cRn/Kdu+p6xu36N0tUzW uJL6bXlQJ/W4Uo+w83jHxgN9z2QVPUoG8mzdtodc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Pirko , Hangbin Liu , "David S. Miller" Subject: [PATCH 5.0 81/89] team: fix possible recursive locking when add slaves Date: Tue, 30 Apr 2019 13:39:12 +0200 Message-Id: <20190430113613.582316488@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangbin Liu [ Upstream commit 925b0c841e066b488cc3a60272472b2c56300704 ] If we add a bond device which is already the master of the team interface, we will hold the team->lock in team_add_slave() first and then request the lock in team_set_mac_address() again. The functions are called like: - team_add_slave() - team_port_add() - team_port_enter() - team_modeop_port_enter() - __set_port_dev_addr() - dev_set_mac_address() - bond_set_mac_address() - dev_set_mac_address() - team_set_mac_address Although team_upper_dev_link() would check the upper devices but it is called too late. Fix it by adding a checking before processing the slave. v2: Do not split the string in netdev_err() Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device") Acked-by: Jiri Pirko Signed-off-by: Hangbin Liu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/team/team.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1157,6 +1157,13 @@ static int team_port_add(struct team *te return -EINVAL; } + if (netdev_has_upper_dev(dev, port_dev)) { + NL_SET_ERR_MSG(extack, "Device is already an upper device of the team interface"); + netdev_err(dev, "Device %s is already an upper device of the team interface\n", + portname); + return -EBUSY; + } + if (port_dev->features & NETIF_F_VLAN_CHALLENGED && vlan_uses_dev(dev)) { NL_SET_ERR_MSG(extack, "Device is VLAN challenged and team device has VLAN set up");