Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2575049ybh; Fri, 24 Jul 2020 17:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcMq14t4wBdXZpmVvDpKONHC0dC319y+VDqMYvgowVOwqaP9kNjZLHPNgfYYbgN4v6HPuA X-Received: by 2002:a17:906:ce43:: with SMTP id se3mr11229007ejb.543.1595635487622; Fri, 24 Jul 2020 17:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595635487; cv=none; d=google.com; s=arc-20160816; b=UnDbAO8eNyKvRebZJYRR3eHDfd/fq3GP5HAUKCyJ6v3yTIa+LYHzhYPGkNTZiTZKJ7 lx14Izbf7NDf72GKPGPg0uFqsu6QMbQZRtXdHwzl5tgXn9Rftefp4eK3db0nsrADWrCc lUeWVbiqXdPsZCkK9UxwHOwpQ79NF+DSDm9PO625oYvMeshErAXq5boNn8X5APOj55p2 0jku1ZfJrOCFReCF5wIhKXQQUWeXh7GP8FMzpaMB1JBMWjiFcVHwjRBsGnT6Eu6IEsoG VhcrOlQ+e7AZJbGJwkIyJv9PVtf3A3rK4sNIWDocCUjcOYjrXv2DukymLoc2D8LTMDQw 2kgg== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=4CrYwvQ/K+WjdAaHiWeV/8bSRKSNPuzlaPqhdnFjdFc=; b=pkc4kFACGI3DhxkuRsE13bZ4fxHOkixr1SZybmm38wUrmlwq3BD6wpsrYQdlSN3XAO V1TSk0CMkz+8Ns506KdOC1b3BFhxKd3bEHVv8tJmxY50Ir6fGrXgWL8nvjH2ptmTob2n eWoCQAEm0dz48jbLHxrtV8ry/AT6/1V7UR8kj9IGdA/7VLCtjY26RnwfOMWpKRkjSffW orMP0pAXm5eqd/Fb5J4/iGvwbcobZdBwPDeSIJpe2tRPDVdyyQFPgQQH5ElFNvOKKbGL +baYaysX+WwCiHkj1xPHcXbxu2w8trMwvL6/ALc0GzTPTdmCgaqlemnQLWOrTKbMDYMk /jlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si1501814ejm.538.2020.07.24.17.04.24; Fri, 24 Jul 2020 17:04:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726732AbgGYACV (ORCPT + 99 others); Fri, 24 Jul 2020 20:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgGYACV (ORCPT ); Fri, 24 Jul 2020 20:02:21 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECE5C0619D3; Fri, 24 Jul 2020 17:02:21 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 961C612756FEE; Fri, 24 Jul 2020 16:45:35 -0700 (PDT) Date: Fri, 24 Jul 2020 17:02:20 -0700 (PDT) Message-Id: <20200724.170220.1275270219725381485.davem@davemloft.net> To: andrea.righi@canonical.com Cc: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, kuba@kernel.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] xen-netfront: fix potential deadlock in xennet_remove() From: David Miller In-Reply-To: <20200724085910.GA1043801@xps-13> References: <20200724085910.GA1043801@xps-13> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 24 Jul 2020 16:45:35 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrea Righi Date: Fri, 24 Jul 2020 10:59:10 +0200 > There's a potential race in xennet_remove(); this is what the driver is > doing upon unregistering a network device: > > 1. state = read bus state > 2. if state is not "Closed": > 3. request to set state to "Closing" > 4. wait for state to be set to "Closing" > 5. request to set state to "Closed" > 6. wait for state to be set to "Closed" > > If the state changes to "Closed" immediately after step 1 we are stuck > forever in step 4, because the state will never go back from "Closed" to > "Closing". > > Make sure to check also for state == "Closed" in step 4 to prevent the > deadlock. > > Also add a 5 sec timeout any time we wait for the bus state to change, > to avoid getting stuck forever in wait_event(). > > Signed-off-by: Andrea Righi > --- > Changes in v2: > - remove all dev_dbg() calls (as suggested by David Miller) Applied, thank you.