Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BB8FC4332F for ; Wed, 1 Dec 2021 21:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343846AbhLAVNF (ORCPT ); Wed, 1 Dec 2021 16:13:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbhLAVM7 (ORCPT ); Wed, 1 Dec 2021 16:12:59 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3E5C061574 for ; Wed, 1 Dec 2021 13:09:38 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id y16so32684416ioc.8 for ; Wed, 01 Dec 2021 13:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SDcnRnl8WP6Hhxu22CYqrzttmdFEJ6bFnF0IuQOZgnM=; b=HIo8SsAV/jdz9Ezru0XkiaGCYNseoT0H9XCbHbUEUQxxnhdW+xPryVmgZIs8RchCVS iVjIkQfiWSh3hFCK3p5QzB243IfIiojauSMYHCnbtSyBlDlAOxTbjKOkl4xk0dvFGjNb +S8xtG82gzw4TCMF/rs/NDRUeqgrwF5zbweeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SDcnRnl8WP6Hhxu22CYqrzttmdFEJ6bFnF0IuQOZgnM=; b=QHPVmGervRB4d2bpLYPZPhYQQhZek11W66tCv/GigFmlAE6BiNojlOa6+bismo7aYe jRIa2heN9neCazAfhoOLQjYkJ5iFtox3Dxl77Gy6yzJ8C71JVBgDcFvZFxtEAFPosaWQ bM4rdSLXblfvHoFPvC74LMLVzzDIPkW2m4M63Pplx89XFoEhFJpkaME6xtsBFwfLHyQE nH1nxgRzCZcmaSuz3Joh1TK8pY5iDwYpWTSj+j3O3Q8LSe6Hk43ah5H/4WNqPJnkQeVO DNjSbev+k6t/FG2aO/8ajMTyb75+loeksJavQJ5v87ec+rqGWI6dTW7JELwo+NDfgEQe oWmQ== X-Gm-Message-State: AOAM5335D6vvOV3oRO1/kzCIDsOr+rAXbHzJcMSPc7ALcDH0jcq0763Q tmNkxDFjl/Uam3hR1D9gKCgpWjQWYVulEQ== X-Google-Smtp-Source: ABdhPJyI9NVGwb44cUTtII9x4AQR24+xui/cOVRgrKaaPqiKnJzyAtq2IaCQcCOg+2S7Hm1m0S4IRA== X-Received: by 2002:a5e:8d12:: with SMTP id m18mr10005893ioj.116.1638392977848; Wed, 01 Dec 2021 13:09:37 -0800 (PST) Received: from mail-il1-f175.google.com (mail-il1-f175.google.com. [209.85.166.175]) by smtp.gmail.com with ESMTPSA id z12sm656266ilu.27.2021.12.01.13.09.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Dec 2021 13:09:36 -0800 (PST) Received: by mail-il1-f175.google.com with SMTP id i9so26880820ilu.1 for ; Wed, 01 Dec 2021 13:09:36 -0800 (PST) X-Received: by 2002:a92:ca0e:: with SMTP id j14mr10532883ils.27.1638392976093; Wed, 01 Dec 2021 13:09:36 -0800 (PST) MIME-Version: 1.0 References: <0e495b14-efbb-e0da-37bd-af6bd677ee2c@gmail.com> In-Reply-To: From: Doug Anderson Date: Wed, 1 Dec 2021 13:09:24 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mwifiex: Fix possible ABBA deadlock To: Brian Norris Cc: Jia-Ju Bai , amitkarwar@gmail.com, ganapathi017@gmail.com, sharvari.harisangam@nxp.com, huxinming820@gmail.com, kvalo@codeaurora.org, David Miller , kuba@kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Nov 29, 2021 at 4:47 PM Brian Norris wrote: > > Quoting Jia-Ju Bai : > > mwifiex_dequeue_tx_packet() > spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 1432 (Lock A) > mwifiex_send_addba() > spin_lock_bh(&priv->sta_list_spinlock); --> Line 608 (Lock B) > > mwifiex_process_sta_tx_pause() > spin_lock_bh(&priv->sta_list_spinlock); --> Line 398 (Lock B) > mwifiex_update_ralist_tx_pause() > spin_lock_bh(&priv->wmm.ra_list_spinlock); --> Line 941 (Lock A) > > Similar report for mwifiex_process_uap_tx_pause(). > > While the locking expectations in this driver are a bit unclear, the > Fixed commit only intended to protect the sta_ptr, so we can drop the > lock as soon as we're done with it. > > IIUC, this deadlock cannot actually happen, because command event > processing (which calls mwifiex_process_sta_tx_pause()) is > sequentialized with TX packet processing (e.g., > mwifiex_dequeue_tx_packet()) via the main loop (mwifiex_main_process()). > But it's good not to leave this potential issue lurking. > > Fixes: ("f0f7c2275fb9 mwifiex: minor cleanups w/ sta_list_spinlock in cfg80211.c") > Cc: Douglas Anderson > Reported-by: TOTE Robot > Link: https://lore.kernel.org/linux-wireless/0e495b14-efbb-e0da-37bd-af6bd677ee2c@gmail.com/ > Signed-off-by: Brian Norris > --- > > On Tue, Nov 23, 2021 at 11:31:34AM +0800, Jia-Ju Bai wrote: > > I am not quite sure whether these possible deadlocks are real and how to fix > > them if they are real. > > Any feedback would be appreciated, thanks :) > > I think these are at least theoretically real, and so we should take > something like the $subject patch probably. But I don't believe we can > actually hit this due to the main-loop structure of this driver. > > Anyway, see the surrounding patch. > > Thanks, > Brian > > > drivers/net/wireless/marvell/mwifiex/sta_event.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Though I'm by no means an expert on this code and I wrote the patch in question a long time ago, this seems reasonable to me. Thanks for fixing. Reviewed-by: Douglas Anderson