Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5905458rwr; Mon, 24 Apr 2023 10:34:37 -0700 (PDT) X-Google-Smtp-Source: AKy350b24/HqQLDnJIpdnpuhhxDLOOwLB3IhjO1xRfHAjPAofsp9MfOO5xXpYefuX4cbMBQbQ8zC X-Received: by 2002:aa7:88d0:0:b0:636:f899:46a0 with SMTP id k16-20020aa788d0000000b00636f89946a0mr20261504pff.15.1682357677489; Mon, 24 Apr 2023 10:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682357677; cv=none; d=google.com; s=arc-20160816; b=YmSO/cusGLBnF6Nef4+NsllDwMM9/9a0PgHEL9IhhvQW1G8BxmRloe8t30gu6QBP20 TsUYvBK58UXwzsWybVgkafNGlthTI4qIM6EWu1YYw3NXz9pGuFB5BVM8ogZEhV+vcRU2 Y2ErWJPzoowSuynxoG2eBJwyzYdYu86JuozdKDZQ/cCU8nGMCiaUCY5cu3e4mNjI4j59 0WlCQ3kRZJzRaRHkSB21nMskmak94T7LXg59ofF84Yu61t1hoqjopwabkFySYd2Yqm/8 W/NHNrPV59StOfWcVcoEXSSeSqGZ9iLXiEhy3Xv5nxZQB+mBL+KxkF6PBB0uvv9UJolS /zEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=mdZMqXmTjXshW4E/eEgL1QKpY1NylxDe1EMTOVylnec=; b=HJUBH/v2ST76ZsywSPYLaNHpLC+/Bdp0d3V7kcfXC9fBMEf80RCOKymcSTy1JK3LUt I567XwZXjQTmo+BSCW29taIiyuFKeXDdBuZ4pbBuBykftQu2Rn1+pKaWjgiHTU7uhdr3 hfcZzAw7oZl/o9WOuBoMXvoZ31Qq1z+PFOGv3MbD2cUP5fztAIn8vYM5lX5+Qtkgj6E8 H0Rs+tvraW9JEvZqEcESigKQ5YgA6DrpdZ7BYtdl1kMr+EFmRCX58/YQ2p2cHPzCtbBS gFzGxAbOLuUacfmpqDsRrQoBhjy2airfCwz9Z+RY1usOn02Lfw9bzJ4xTUAG3TdRYenl IpQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=a+PYMYR9; 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=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x29-20020aa78f1d000000b0063b8f3a4d42si11368204pfr.163.2023.04.24.10.34.24; Mon, 24 Apr 2023 10:34:37 -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=@sipsolutions.net header.s=mail header.b=a+PYMYR9; 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=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232097AbjDXR1O (ORCPT + 99 others); Mon, 24 Apr 2023 13:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjDXR1N (ORCPT ); Mon, 24 Apr 2023 13:27:13 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3C8FC; Mon, 24 Apr 2023 10:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=mdZMqXmTjXshW4E/eEgL1QKpY1NylxDe1EMTOVylnec=; t=1682357231; x=1683566831; b=a+PYMYR9pAvR9UOUYkoyPBdh3x+hKv1pVNe2riawuZomjz5 IqTjOiy0ffA0nc4sWnAO16aaF/Nswxlsvh2M6MDL6K2h+W+CmXLO9tG+/wAgeAsQ/uVtj/h2fC3fm /xoN1qUjxLmmeMywFDNNVY4PebuzcWeDwES0rWacQD4syZ7Ge/ZxQvDRGCRzWd1/fjhB+LdKiOXwb guxJdySVUMdSOMpdMYQyoxufJOKsb71P76CAe0UY77KkrcJDQHLl8QFHu8+uv8TZR/JHbilNklSCK icbSB0DiZzed7HrCgWyQ1KeipNPqd8C9U/BewYGZddJiN6Ub6hkXQpoSBmvhJ+TA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pqzy1-007KKJ-1A; Mon, 24 Apr 2023 19:27:09 +0200 Message-ID: <017c5178594e2df6ca02f2d7ffa9109755315c56.camel@sipsolutions.net> Subject: Re: [PATCH RFC v1 1/1] net: mac80211: fortify the spinlock against deadlock in interrupt From: Johannes Berg To: Mirsad Goran Todorovac , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexander Wetzel Date: Mon, 24 Apr 2023 19:27:08 +0200 In-Reply-To: <20230423082403.49143-1-mirsad.todorovac@alu.unizg.hr> References: <20230423082403.49143-1-mirsad.todorovac@alu.unizg.hr> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Sun, 2023-04-23 at 10:24 +0200, Mirsad Goran Todorovac wrote: > In the function ieee80211_tx_dequeue() there is a locking sequence: >=20 > begin: > spin_lock(&local->queue_stop_reason_lock); > q_stopped =3D local->queue_stop_reasons[q]; > spin_unlock(&local->queue_stop_reason_lock); >=20 > However small the chance (increased by ftracetest), an asynchronous > interrupt can occur in between of spin_lock() and spin_unlock(), > and the interrupt routine will attempt to lock the same > &local->queue_stop_reason_lock again. >=20 > This is the only remaining spin_lock() on local->queue_stop_reason_lock > that did not disable interrupts and could have possibly caused the deadlo= ck > on the same CPU (core). >=20 > This will cause a costly reset of the CPU and wifi device or an > altogether hang in the single CPU and single core scenario. >=20 > This is the probable reproduce of the deadlock: >=20 > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: Possible unsafe locking = scenario: > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: CPU0 > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: ---- > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: lock(&local->queue_stop= _reason_lock); > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: lock(&local->queue_st= op_reason_lock); > Apr 10 00:58:33 marvin-IdeaPad-3-15ITL6 kernel: > *** DEADLOCK *** >=20 > Fixes: 4444bc2116ae That fixes tag is wrong, should be Fixes: 4444bc2116ae ("wifi: mac80211: Proper mark iTXQs for resumption") Otherwise seems fine to me, submit it properly? johannes