From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7E29C433E2 for ; Tue, 1 Sep 2020 17:21:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77C792087D for ; Tue, 1 Sep 2020 17:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598980908; bh=Qdd2t+Bq7aOgloQpyqL/JTwfqg9nGMTvB29mRmWzITk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=czeQB4RLgI0rXJJk6a4PkpecR4CrcO1C1ed5CA0oKWGdsWExTCiMD1TMzYFQD9SYG AwTSgqruogCRFpQEWiD1T7TOULSy8HM/9BSQyuGrayjwzjg27Wzf5/4KtQR+vtfgB4 eW8UKBTA9R9CU+nyXsuKMiwEcbkQIa+0+WPqFzzk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729188AbgIARVr (ORCPT ); Tue, 1 Sep 2020 13:21:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:54734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728713AbgIAPMX (ORCPT ); Tue, 1 Sep 2020 11:12:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A151720BED; Tue, 1 Sep 2020 15:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973143; bh=Qdd2t+Bq7aOgloQpyqL/JTwfqg9nGMTvB29mRmWzITk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofoR8QYqP/G+Wf0iiEDi+xa+WqKsP5JVwfnGghOnxL4UaZH0y6tDRMrUC+GXOT3nQ 18i/6gU7f6Ybj2gyhUCRCnQLSc8Cg+wF/SZtNzYGi0RdZKFsf605Gnw1PZWLU4MB3M bvfEHwi0Y5owQunBLY/R8YJDMqU5eRP5rnvQto1w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+af23e7f3e0a7e10c8b67@syzkaller.appspotmail.com, Eric Dumazet , Andy Gospodarek , Jay Vosburgh , Cong Wang , "David S. Miller" Subject: [PATCH 4.4 05/62] bonding: fix a potential double-unregister Date: Tue, 1 Sep 2020 17:09:48 +0200 Message-Id: <20200901150920.977690328@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150920.697676718@linuxfoundation.org> References: <20200901150920.697676718@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: Cong Wang [ Upstream commit 832707021666411d04795c564a4adea5d6b94f17 ] When we tear down a network namespace, we unregister all the netdevices within it. So we may queue a slave device and a bonding device together in the same unregister queue. If the only slave device is non-ethernet, it would automatically unregister the bonding device as well. Thus, we may end up unregistering the bonding device twice. Workaround this special case by checking reg_state. Fixes: 9b5e383c11b0 ("net: Introduce unregister_netdevice_many()") Reported-by: syzbot+af23e7f3e0a7e10c8b67@syzkaller.appspotmail.com Cc: Eric Dumazet Cc: Andy Gospodarek Cc: Jay Vosburgh Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/bonding/bond_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1940,7 +1940,8 @@ static int bond_release_and_destroy(str int ret; ret = bond_release(bond_dev, slave_dev); - if (ret == 0 && !bond_has_slaves(bond)) { + if (ret == 0 && !bond_has_slaves(bond) && + bond_dev->reg_state != NETREG_UNREGISTERING) { bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; netdev_info(bond_dev, "Destroying bond %s\n", bond_dev->name);