Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3282870ybb; Tue, 31 Mar 2020 02:03:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsgfe36rECDlgJJF1ySH8+wbipspqocVvTG50FAx4VZOXXej5GDv2qU3gEZ63InjGtgWd9M X-Received: by 2002:a4a:da1a:: with SMTP id e26mr12495865oou.19.1585645386985; Tue, 31 Mar 2020 02:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645386; cv=none; d=google.com; s=arc-20160816; b=POU7+c14zMMgHu3T8S7CNdE4ytxuLwr/WGNd/gDypX0IndCVQHQdGQNuh4220pP4+D zwgq/60Y0HunAOqEeMdCyAu5QA68HjojS2C2dnt+TNL7oSzYFdHMBIR3kPF2dWhPXBQz Rk9EtYlqwUGRul+5CWNmq0Iyqk9Uu1KT2oUupowhaCN9L3wMBeimZtixGqcnhC56gZl+ 107J1tN6zlrIixtsE8uyeFrYuwEN4qM5KN1xlK8fYbqo3ZCGeNp07GgvQKVV4NUpAeFO l20qCASEE4QTHvym4oNSMOP+shi01j2C1EzJuh6OSA4NhZxwEg6xkPXbXsYo5yHir2MV Varw== 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=PR50U6Ypu8KRKRl9zr4qaTpRhYliPMFT4l6qTXSPukM=; b=GyH3c7cdhAhxJ+Ak7mWZ1ZSjVV0Ha+aoG5GS2M10oxGCqFmKuEik3YCHNPMAVMzFTw W8BpdLx0lQHHzreV0SRzwxx7ME8DetbhUbv1iN1yy7+4n+zhbV3SQc4pnuoMw6ilaAYC UAwCdYKFITDF82HrSiq1o5X38Yw4yP7rLKy5+YcV4/hHattiaYMqjtmK4ijVh1rgK8t6 ga6SrkbSkRT99EVLU9OW9ap03EoM1lq07lQX4O7I9NcpY6xS6nYilFKC2sXsgRgzmC9I +CKSCYBSGnzLdo2Nbre+T7x2uUdqW1NgvA2f702TNHD6tEBLSaqEdu09UxtA1IKI7Ijr 6wGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vZHkW7py; 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 u136si6992432oif.197.2020.03.31.02.02.54; Tue, 31 Mar 2020 02:03:06 -0700 (PDT) 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=vZHkW7py; 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 S1730524AbgCaJBO (ORCPT + 99 others); Tue, 31 Mar 2020 05:01:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:40234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730511AbgCaJBK (ORCPT ); Tue, 31 Mar 2020 05:01:10 -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 8895F20B1F; Tue, 31 Mar 2020 09:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645269; bh=0CeNMpF2I3Al+pQh8jpMHNjh0FrwPZUcwKc7/Wt+lBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZHkW7pywEw7jrJUP/epusbbENeOLD5eldSRhK/H8ZhqvSM3q7LYWiy4+DZ4fgguT xRSvETtkTVu9hmCJowjvGNLHLju9PCvdpJNgh57ypzvckgH2ihqqPKPLeQXO6hRWhV Hzdc2bciZGNoK6JRLu6wmjoiRH6gdofFRTm509Ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 5.6 16/23] staging: wfx: annotate nested gc_list vs tx queue locking Date: Tue, 31 Mar 2020 10:59:28 +0200 Message-Id: <20200331085315.519262911@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085308.098696461@linuxfoundation.org> References: <20200331085308.098696461@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: Michał Mirosław commit e2525a95cc0887c7dc0549cb5d0ac3e796e1d54c upstream. Lockdep is complaining about recursive locking, because it can't make a difference between locked skb_queues. Annotate nested locks and avoid double bh_disable/enable. [...] insmod/815 is trying to acquire lock: cb7d6418 (&(&list->lock)->rlock){+...}, at: wfx_tx_queues_clear+0xfc/0x198 [wfx] but task is already holding lock: cb7d61f4 (&(&list->lock)->rlock){+...}, at: wfx_tx_queues_clear+0xa0/0x198 [wfx] [...] Possible unsafe locking scenario: CPU0 ---- lock(&(&list->lock)->rlock); lock(&(&list->lock)->rlock); Cc: stable@vger.kernel.org Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Signed-off-by: Michał Mirosław Link: https://lore.kernel.org/r/5e30397af95854b4a7deea073b730c00229f42ba.1581416843.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -130,12 +130,12 @@ static void wfx_tx_queue_clear(struct wf spin_lock_bh(&queue->queue.lock); while ((item = __skb_dequeue(&queue->queue)) != NULL) skb_queue_head(gc_list, item); - spin_lock_bh(&stats->pending.lock); + spin_lock_nested(&stats->pending.lock, 1); for (i = 0; i < ARRAY_SIZE(stats->link_map_cache); ++i) { stats->link_map_cache[i] -= queue->link_map_cache[i]; queue->link_map_cache[i] = 0; } - spin_unlock_bh(&stats->pending.lock); + spin_unlock(&stats->pending.lock); spin_unlock_bh(&queue->queue.lock); } @@ -207,9 +207,9 @@ void wfx_tx_queue_put(struct wfx_dev *wd ++queue->link_map_cache[tx_priv->link_id]; - spin_lock_bh(&stats->pending.lock); + spin_lock_nested(&stats->pending.lock, 1); ++stats->link_map_cache[tx_priv->link_id]; - spin_unlock_bh(&stats->pending.lock); + spin_unlock(&stats->pending.lock); spin_unlock_bh(&queue->queue.lock); } @@ -237,11 +237,11 @@ static struct sk_buff *wfx_tx_queue_get( __skb_unlink(skb, &queue->queue); --queue->link_map_cache[tx_priv->link_id]; - spin_lock_bh(&stats->pending.lock); + spin_lock_nested(&stats->pending.lock, 1); __skb_queue_tail(&stats->pending, skb); if (!--stats->link_map_cache[tx_priv->link_id]) wakeup_stats = true; - spin_unlock_bh(&stats->pending.lock); + spin_unlock(&stats->pending.lock); } spin_unlock_bh(&queue->queue.lock); if (wakeup_stats) @@ -259,10 +259,10 @@ int wfx_pending_requeue(struct wfx_dev * spin_lock_bh(&queue->queue.lock); ++queue->link_map_cache[tx_priv->link_id]; - spin_lock_bh(&stats->pending.lock); + spin_lock_nested(&stats->pending.lock, 1); ++stats->link_map_cache[tx_priv->link_id]; __skb_unlink(skb, &stats->pending); - spin_unlock_bh(&stats->pending.lock); + spin_unlock(&stats->pending.lock); __skb_queue_tail(&queue->queue, skb); spin_unlock_bh(&queue->queue.lock); return 0;