Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1907886imm; Thu, 24 May 2018 02:44:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqilDP7EzXLWP10pG3O2B6GtFW3uuQTgAoKuTcsbnXluRTkvnqZ54TIYzAKKNNkeFM19OvO X-Received: by 2002:a17:902:8307:: with SMTP id bd7-v6mr6607252plb.234.1527155041225; Thu, 24 May 2018 02:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155041; cv=none; d=google.com; s=arc-20160816; b=DmWIxmPeofF0wsnHPSpV3upj3l5XOrYD+yCVM34AIs9wtL7s85vcn9U9PpNepYBCVz +qxD/zvxX9Te0kCj7iZ1FKozA77ERHXRF9029bGGiX8Hml+0mpJME4JhbfiTo8Gtjc1Z B4/NXP0mvYT8LxQPynU38hrqJI0gjJBCfShuA4P0P/zxFWCj0QlOdQTLYEzuBIX6Cn7t aEiq3g4b+r/jjyBWRo3OclARWinRBiLUc2grcBcbMJ7GzxI6hOWiwp/aLobXOtb9LY6p neYOuaPZU1oAW774DjJ/FiMNk8ZH8WFVSiAR1IsIic0HNgGUp7l3Xr0xLS1BLnBaOixt 8WDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=G9+d3Qijb9SlsGb2KERvQnwO4sQuHkHYStKry4vrBxI=; b=jYIfckur65jshjr0GMb3G+U+avSOPJvLLklAKMh9Z/tCzj/238NIjMw2FhMLcEvimQ 7pibB4gMq4541jGS7PFCyv++dG1ONXv3Gn4guXy63I27TM+57CPwaR4cfIYSs/DKCmqy /pXfPh+1d2EnGnyJcN2xCMlHABN07iPSr24cm6m56nC9sNeVZZgOQHjcXOBUyYy2km6K UOxCjKlmNmSp7khbMJf5gNiBs8ES5V4qpCVjhs7qdsQsWDVbbP+QpULaqyqO6kZ9zqE3 klC7Pw0FtFLj2eeSnCNrx13hnl6Jw4fJVLGhXqCdxQLjyyEuAbtoWj4dS+09TJ/X9xPY 52aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IKJqz1KA; 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 m197-v6si4608801pga.107.2018.05.24.02.43.46; Thu, 24 May 2018 02:44:01 -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=IKJqz1KA; 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 S966423AbeEXJm7 (ORCPT + 99 others); Thu, 24 May 2018 05:42:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:54480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966408AbeEXJm4 (ORCPT ); Thu, 24 May 2018 05:42:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 46363208AF; Thu, 24 May 2018 09:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154975; bh=Y/CYs/i0OnLQojp9WqGl3sX5rjQdthvFCX9wYesCZUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKJqz1KAmduxqQu6x3gsBuU+TSRfQmVI7OJTFNKyL4PpBzONt5PLOmWfmXu0+EDhM gCI1Vc4NFaCpOvXKhucnjwEkXP3xGXm/XFczDf/bDCDymZKeqiEGF+Ir6bR1nBiHog NqDqRZfXZ+DMe2nmO1nCLCguMcw0ieVON7kix3x4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+de73361ee4971b6e6f75@syzkaller.appspotmail.com, Hangbin Liu , Nikolay Aleksandrov , "David S. Miller" Subject: [PATCH 4.4 02/92] bridge: check iface upper dev when setting master via ioctl Date: Thu, 24 May 2018 11:37:39 +0200 Message-Id: <20180524093159.476457655@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hangbin Liu [ Upstream commit e8238fc2bd7b4c3c7554fa2df067e796610212fc ] When we set a bond slave's master to bridge via ioctl, we only check the IFF_BRIDGE_PORT flag. Although we will find the slave's real master at netdev_master_upper_dev_link() later, it already does some settings and allocates some resources. It would be better to return as early as possible. v1 -> v2: use netdev_master_upper_dev_get() instead of netdev_has_any_upper_dev() to check if we have a master, because not all upper devs are masters, e.g. vlan device. Reported-by: syzbot+de73361ee4971b6e6f75@syzkaller.appspotmail.com Signed-off-by: Hangbin Liu Acked-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/bridge/br_if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -456,8 +456,8 @@ int br_add_if(struct net_bridge *br, str if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) return -ELOOP; - /* Device is already being bridged */ - if (br_port_exists(dev)) + /* Device has master upper dev */ + if (netdev_master_upper_dev_get(dev)) return -EBUSY; /* No bridging devices that dislike that (e.g. wireless) */