Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2671809pxb; Mon, 11 Jan 2021 16:44:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJztWZs1oUHc8/F90u9mr6MdSJAXWeYTu0b8EI1yKtBrsqFB66gAFRe2fFPegSatOT2CreXI X-Received: by 2002:a17:906:234d:: with SMTP id m13mr1378393eja.270.1610412299482; Mon, 11 Jan 2021 16:44:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412299; cv=none; d=google.com; s=arc-20160816; b=ANgVc7fIvilXj5bAmQpVZSAscu6fqqG2DBofSOcIHhnQLFYsKeTVJ8P58aGC/cyzB4 bBGI6RJF3s0EQl+6ld3zTs9RILD+swYAAuYVGr1EI73D+SUa6sjTMdJK/kLyXGq/5QE3 RwmE+36XuaXxDo6wy8AyJ5Vpn+wEBfHnhsvJkEurnJRIigtLlSmHgceh88IqGZfqOVpP XBu+XKbHgcwGnjQjXK1GxGDi1mS8jDdXO9MOpwGdc4VREDyodLxsMmeR8lBhVrV0uq7B hZy2nUnxehxmBem1cusBkr4YHosmrloc2tnMKw6U9N7EcYzZyBJI6fl9tP3Qu6YwJyIY 7i4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mX+raNE8iAtXTmBsLa/O8T4LoaHTEtK5A2j9A1lVBts=; b=WshT+vEJwqWmjzKMIWy1Kvrzrm7DLvX2C3e1tgqVldommVt1KuJn2Tcbhm5Rb3R0z/ Rlroi47jHdptt7UtrUJdOr7X9r/vyVk13vz+By8NnyCXZorwMPwB8SPntDJWGORLzCTj s68NspWV3DekOn9IaiKyWbdXwZmkvF1vHR2cWJYQwqsBiXvj7yuXnteZiRAi7oPV6T2R EkW4Cz9KpUoeLqbgilSgAsHEgYGDHjV/142uM1IG5h2qy4BoKqcPdrNiqAQtfLHB8yQB ceSz8VzFo/o1hB2FN3iLGD7BkRH/apEi5S0N90tTDwyD11KqAXY4Ojr+hYSYkeYOLVED jEfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cf1mwN53; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si540340edd.145.2021.01.11.16.44.35; Mon, 11 Jan 2021 16:44:59 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cf1mwN53; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728088AbhAKNBW (ORCPT + 99 others); Mon, 11 Jan 2021 08:01:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:48766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbhAKNBU (ORCPT ); Mon, 11 Jan 2021 08:01:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8CF4622527; Mon, 11 Jan 2021 13:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370014; bh=c+VdNQkvnXBrSweCeC/HDTRguVf18HGSP1aDZdj7Yu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cf1mwN53Zsm5NQWlHAXCr7BzxKLoJTRFgTSUxne8axqPQeyhMqtUOXbqoskIKvmk4 lr0el82c2LZwxWBU7Pzo5jBG+d7OOJCt2MQDYjQmMiwML4zt5KBwbAkeL+yyHl14uN OHEwAiEConr4okMuwOjc28Cc9WwR9/xIUHNQTV/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Dike , Jason Wang , "Michael S. Tsirkin" , Jakub Kicinski Subject: [PATCH 4.4 13/38] virtio_net: Fix recursive call to cpus_read_lock() Date: Mon, 11 Jan 2021 14:00:45 +0100 Message-Id: <20210111130033.111954313@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130032.469630231@linuxfoundation.org> References: <20210111130032.469630231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Dike [ Upstream commit de33212f768c5d9e2fe791b008cb26f92f0aa31c ] virtnet_set_channels can recursively call cpus_read_lock if CONFIG_XPS and CONFIG_HOTPLUG are enabled. The path is: virtnet_set_channels - calls get_online_cpus(), which is a trivial wrapper around cpus_read_lock() netif_set_real_num_tx_queues netif_reset_xps_queues_gt netif_reset_xps_queues - calls cpus_read_lock() This call chain and potential deadlock happens when the number of TX queues is reduced. This commit the removes netif_set_real_num_[tr]x_queues calls from inside the get/put_online_cpus section, as they don't require that it be held. Fixes: 47be24796c13 ("virtio-net: fix the set affinity bug when CPU IDs are not consecutive") Signed-off-by: Jeff Dike Acked-by: Jason Wang Acked-by: Michael S. Tsirkin Link: https://lore.kernel.org/r/20201223025421.671-1-jdike@akamai.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1372,14 +1372,16 @@ static int virtnet_set_channels(struct n get_online_cpus(); err = virtnet_set_queues(vi, queue_pairs); - if (!err) { - netif_set_real_num_tx_queues(dev, queue_pairs); - netif_set_real_num_rx_queues(dev, queue_pairs); - - virtnet_set_affinity(vi); + if (err) { + put_online_cpus(); + goto err; } + virtnet_set_affinity(vi); put_online_cpus(); + netif_set_real_num_tx_queues(dev, queue_pairs); + netif_set_real_num_rx_queues(dev, queue_pairs); +err: return err; }