Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6549208ybx; Mon, 11 Nov 2019 10:46:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxUFIdL4cnwlJVFb33I5A2m5MTIVYYgr5C9jKG8S6svhnnSt/sJYwXlTEin4IS11J+TnaMt X-Received: by 2002:a17:906:8054:: with SMTP id x20mr23699904ejw.68.1573498005831; Mon, 11 Nov 2019 10:46:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498005; cv=none; d=google.com; s=arc-20160816; b=mKIfrg8hf5MXRXwYc79Xe3a6TyT7PJ+oQQcnmDBbaEN3qGVOzpTk6eZpR9wXiqmpAb BAEH+E0Q3X8WjONT8vCixtcIsFAEA4eOEA4U/rflkBZaM6gDG16Qy2lCxEOicq/vvFvx qtB0KJEQPYcdmdi1tTN/70gd6uHkBjSAJzwvv00ocxip37ZzG/gmt2vYCCJ5MUxUKilu UiL/g+49U5/753jDiG48p2LewXQfIuZ7oHCnitAaJQDDw170DvLWmOYNI9zWqLhBu9pT 4dM+DzPI2ZdTRD+uiwgx8YSVdvM91fSq7lX63VebiNsV2CYKBHPzWbJWKJLP2R2yNrKt CaEA== 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=J6hgp7hgIk/7IS3hCRzK6zaMOFSkqwXtO5vTw0mZYYQ=; b=RO5aGanuvRjKagBbO8jlvVWKo0S9CRGcjggrJzfSz+lZ1cuSWZXy7RSj6E3EB6gODX dg2lMtzuLj90KD71NpJDjcQ90qBBYLLYj4YP3JaAFIPsTVHQQ2MpRXexas/6LElHLriH /rwUmmWVvYmLq/6xc4GFlTy+m2eaHjDUenTuffVlIcnaVb9gQHZ90c26L2AmkUPiXr0M Rzhu1r9gwCmCVtVmtvRB97rQBO/3pdUDC7AH/gM3Fsjm03auBzZVfBeP4GCOJJ7XMHXF G0p/J9YRv0ku7UbtO5vcrjjrg3BX4Rrmitma+1HnKAywgJbZFOu70H61FqrmWkSh9Hln nqzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=abm00pVS; 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 c12si11963292eda.402.2019.11.11.10.46.22; Mon, 11 Nov 2019 10:46:45 -0800 (PST) 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=abm00pVS; 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 S1729773AbfKKSow (ORCPT + 99 others); Mon, 11 Nov 2019 13:44:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:36530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729759AbfKKSoq (ORCPT ); Mon, 11 Nov 2019 13:44:46 -0500 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 ED5FF204FD; Mon, 11 Nov 2019 18:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497885; bh=3iNS7/C6a0Lio62IpjKjE3izWfZiLXsULx097bg3Q/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abm00pVSy6Cjysd3dl7h8HbDu3TrAnG5hhGIS4siGI414hRPC4QZhww3lTr3FwGkR 31TiMxqKR+2FNYoQf0qPOJwiDvKGUIyzlLfhvcsxySW6q+WImOEzNIB8mKVBdAlYpt t+AXgIJWuRNwFCM2kfTL3nTQtp+4TwvBKr0iMn10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 087/125] bonding: fix unexpected IFF_BONDING bit unset Date: Mon, 11 Nov 2019 19:28:46 +0100 Message-Id: <20191111181451.722271158@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@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: Taehee Yoo [ Upstream commit 65de65d9033750d2cf1b336c9d6e9da3a8b5cc6e ] The IFF_BONDING means bonding master or bonding slave device. ->ndo_add_slave() sets IFF_BONDING flag and ->ndo_del_slave() unsets IFF_BONDING flag. bond0<--bond1 Both bond0 and bond1 are bonding device and these should keep having IFF_BONDING flag until they are removed. But bond1 would lose IFF_BONDING at ->ndo_del_slave() because that routine do not check whether the slave device is the bonding type or not. This patch adds the interface type check routine before removing IFF_BONDING flag. Test commands: ip link add bond0 type bond ip link add bond1 type bond ip link set bond1 master bond0 ip link set bond1 nomaster ip link del bond1 type bond ip link add bond1 type bond Splat looks like: [ 226.665555] proc_dir_entry 'bonding/bond1' already registered [ 226.666440] WARNING: CPU: 0 PID: 737 at fs/proc/generic.c:361 proc_register+0x2a9/0x3e0 [ 226.667571] Modules linked in: bonding af_packet sch_fq_codel ip_tables x_tables unix [ 226.668662] CPU: 0 PID: 737 Comm: ip Not tainted 5.4.0-rc3+ #96 [ 226.669508] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 226.670652] RIP: 0010:proc_register+0x2a9/0x3e0 [ 226.671612] Code: 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 39 01 00 00 48 8b 04 24 48 89 ea 48 c7 c7 a0 0b 14 9f 48 8b b0 e 0 00 00 00 e8 07 e7 88 ff <0f> 0b 48 c7 c7 40 2d a5 9f e8 59 d6 23 01 48 8b 4c 24 10 48 b8 00 [ 226.675007] RSP: 0018:ffff888050e17078 EFLAGS: 00010282 [ 226.675761] RAX: dffffc0000000008 RBX: ffff88805fdd0f10 RCX: ffffffff9dd344e2 [ 226.676757] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffff88806c9f6b8c [ 226.677751] RBP: ffff8880507160f3 R08: ffffed100d940019 R09: ffffed100d940019 [ 226.678761] R10: 0000000000000001 R11: ffffed100d940018 R12: ffff888050716008 [ 226.679757] R13: ffff8880507160f2 R14: dffffc0000000000 R15: ffffed100a0e2c1e [ 226.680758] FS: 00007fdc217cc0c0(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000 [ 226.681886] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 226.682719] CR2: 00007f49313424d0 CR3: 0000000050e46001 CR4: 00000000000606f0 [ 226.683727] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 226.684725] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 226.685681] Call Trace: [ 226.687089] proc_create_seq_private+0xb3/0xf0 [ 226.687778] bond_create_proc_entry+0x1b3/0x3f0 [bonding] [ 226.691458] bond_netdev_event+0x433/0x970 [bonding] [ 226.692139] ? __module_text_address+0x13/0x140 [ 226.692779] notifier_call_chain+0x90/0x160 [ 226.693401] register_netdevice+0x9b3/0xd80 [ 226.694010] ? alloc_netdev_mqs+0x854/0xc10 [ 226.694629] ? netdev_change_features+0xa0/0xa0 [ 226.695278] ? rtnl_create_link+0x2ed/0xad0 [ 226.695849] bond_newlink+0x2a/0x60 [bonding] [ 226.696422] __rtnl_newlink+0xb9f/0x11b0 [ 226.696968] ? rtnl_link_unregister+0x220/0x220 [ ... ] Fixes: 0b680e753724 ("[PATCH] bonding: Add priv_flag to avoid event mishandling") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/bonding/bond_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 136a972ea903a..9b8143dca5123 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1798,7 +1798,8 @@ err_detach: slave_disable_netpoll(new_slave); err_close: - slave_dev->priv_flags &= ~IFF_BONDING; + if (!netif_is_bond_master(slave_dev)) + slave_dev->priv_flags &= ~IFF_BONDING; dev_close(slave_dev); err_restore_mac: @@ -2004,7 +2005,8 @@ static int __bond_release_one(struct net_device *bond_dev, else dev_set_mtu(slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~IFF_BONDING; + if (!netif_is_bond_master(slave_dev)) + slave_dev->priv_flags &= ~IFF_BONDING; bond_free_slave(slave); -- 2.20.1