From patchwork Mon Aug 24 08:30:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264999 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=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 C8CD6C433DF for ; Mon, 24 Aug 2020 09:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B037207D3 for ; Mon, 24 Aug 2020 09:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598262373; bh=zX+PYRXhtE6PMjXkgX4sI3tpbql86gUJVBN/7PV38+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=e30J7YitdZBeEbX0USDWxKIkXeNEdvejuHrEvoHcIkl7ycqdUn7mADcC7SIbU8VEb awX3BxHbUHIq1VDTOVibxunCZsJoxBLXh7HOgZpOO6N2doU7nmcV5V6mLOV0fPrw8o Z6du6SJYyhadWuLzaLp2QglQNE/SEvSc0EX0WraQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728503AbgHXImY (ORCPT ); Mon, 24 Aug 2020 04:42:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:34324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728936AbgHXImU (ORCPT ); Mon, 24 Aug 2020 04:42:20 -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 9991E2075B; Mon, 24 Aug 2020 08:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258539; bh=zX+PYRXhtE6PMjXkgX4sI3tpbql86gUJVBN/7PV38+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h05dBi2DdgInvTjNNDrYgX6ONg4k3Id/7bhfkiMA7JD8lWSqvIezl8BvksHCkibq/ J9A9NqYl3DmsyM5rcI3/HgIG79JVHBdbPgdRt2ZeMZs2+ovv3Qlh6VC5Fk+JsXs7fJ JvpcxoWncmKReZx+ZcoLPlGspxNPuZVdk6aZUna8= 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" , Sasha Levin Subject: [PATCH 5.7 082/124] bonding: fix a potential double-unregister Date: Mon, 24 Aug 2020 10:30:16 +0200 Message-Id: <20200824082413.444005717@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082409.368269240@linuxfoundation.org> References: <20200824082409.368269240@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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: Sasha Levin --- drivers/net/bonding/bond_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7abb3e2cc9926..02f2428cbc3ba 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2084,7 +2084,8 @@ static int bond_release_and_destroy(struct net_device *bond_dev, int ret; ret = __bond_release_one(bond_dev, slave_dev, false, true); - 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\n"); bond_remove_proc_entry(bond);