Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp626724iog; Mon, 13 Jun 2022 09:24:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uF/wF//wpY4hGVNXpL5gawojUJ3K4Is8eb+XiO5rzPb3gaCnxRo537QaQHQ8QSapN8ofzG X-Received: by 2002:a17:90a:5409:b0:1e8:664e:41dd with SMTP id z9-20020a17090a540900b001e8664e41ddmr575315pjh.173.1655137476861; Mon, 13 Jun 2022 09:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137476; cv=none; d=google.com; s=arc-20160816; b=FNPPDRIj4zwW7a1/3Ke0YE919BU6rmbOISwDZwi8ZAzPHMjN3vK2ImkXIRCXWldrGk svmWc8KtOhO4oyD7PQgfFhTsqAUsCRAx/EBDTpZb3OSpI9BmdXDqWxvW/kifiCT7VWF0 wWw2bkU3dDhSvNn193xdQhQw3tvJO5kUzHMXf0+etc4v5vlk9thr8hKCVEPpxNkuO13r kg22ULO523ZCJGCzKDCrd/DgoAV9JtjhhD7ipFgwxQ4k3jYPbMziQDyy8VMnOyNN4fL2 clkSRt5EdRMTRNnwSn80H3gOqN/W9Ed0dzexPBowV/I5MZ6JX9GzEfLQGOZLm0IDMqYj mWaw== 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=/uoWMMSW/eru3XYj6xeW/ZUQgbWT9Q109A8FqMed4nQ=; b=bq7yZJjFS8A4lIFkDA2zd8fZmIB6GEOPiOnSmWVvtYH62sBhKnJeJ5eEV1xL+VLV4u KUTjG6ZX/kriq0ZIzNp7mNss5Fw76NPyycv718TzwF42VLuOSEcGM6TzEgK5SaOI7itD NEqgBoAubDZW0uBXIJwRwyPDLQclxhNcRx253FYVqsgfdPRhnuvIAP1gBZRUUDacqJZH xyqPKrDwq/z47Xxhe4GuggNPDJ5Ay+rwEfK001QO+X4JtILBhIBnBQ4sApVY1QzT+RcH aaWz+b4XJ+fUyFfFux2l7sS3X0ezKyVTosV/QenNqOPu26Syy/2V3mhGxKAaKrPRkjo6 LrqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oaaWyeBd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i22-20020a63cd16000000b003db97293633si10197726pgg.184.2022.06.13.09.24.24; Mon, 13 Jun 2022 09:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oaaWyeBd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1359535AbiFMNQK (ORCPT + 99 others); Mon, 13 Jun 2022 09:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359274AbiFMNJp (ORCPT ); Mon, 13 Jun 2022 09:09:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF149765E; Mon, 13 Jun 2022 04:19:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7651FB80D31; Mon, 13 Jun 2022 11:19:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3F9EC3411E; Mon, 13 Jun 2022 11:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119192; bh=CEpjbcmExVzwCDja6tm1KJGkaef2pBcfEFZdREugcso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oaaWyeBdZJRAo82kUKg36CTbCSdEmDuN4JvYcrRnfRe8iAz77s8rZdpHKyMzw3STM yXielEBaCjLvL0C5ctogaFHBv8DIigPj/VC9Y9ozCi4XR/vSPLNmrhddru4so31cCa wIi45p5M/eZhZ164rrgPFhzFXvH0LdBlrM2ahOG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Duoming Zhou , Sasha Levin Subject: [PATCH 5.15 174/247] drivers: staging: rtl8192u: Fix deadlock in ieee80211_beacons_stop() Date: Mon, 13 Jun 2022 12:11:16 +0200 Message-Id: <20220613094928.234956324@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094922.843438024@linuxfoundation.org> References: <20220613094922.843438024@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Duoming Zhou [ Upstream commit 806c7b53414934ba2a39449b31fd1a038e500273 ] There is a deadlock in ieee80211_beacons_stop(), which is shown below: (Thread 1) | (Thread 2) | ieee80211_send_beacon() ieee80211_beacons_stop() | mod_timer() spin_lock_irqsave() //(1) | (wait a time) ... | ieee80211_send_beacon_cb() del_timer_sync() | spin_lock_irqsave() //(2) (wait timer to stop) | ... We hold ieee->beacon_lock in position (1) of thread 1 and use del_timer_sync() to wait timer to stop, but timer handler also need ieee->beacon_lock in position (2) of thread 2. As a result, ieee80211_beacons_stop() will block forever. This patch extracts del_timer_sync() from the protection of spin_lock_irqsave(), which could let timer handler to obtain the needed lock. Signed-off-by: Duoming Zhou Link: https://lore.kernel.org/r/20220417135407.109536-1-duoming@zju.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 1a193f900779..2b06706a7071 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -528,9 +528,9 @@ static void ieee80211_beacons_stop(struct ieee80211_device *ieee) spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 0; - del_timer_sync(&ieee->beacon_timer); spin_unlock_irqrestore(&ieee->beacon_lock, flags); + del_timer_sync(&ieee->beacon_timer); } void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) -- 2.35.1