Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1619074rdb; Thu, 7 Dec 2023 04:35:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvZw1As6z0xw4uFXL3lPYSiqrKly4RLPVxxrxygMBJLxknJO2VvekH10mBn97YHd06wgdF X-Received: by 2002:a17:90a:bf0a:b0:286:6cc1:288 with SMTP id c10-20020a17090abf0a00b002866cc10288mr2217186pjs.83.1701952502350; Thu, 07 Dec 2023 04:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701952502; cv=none; d=google.com; s=arc-20160816; b=qpCFGgbyuGfl4cFuLkYtLtG6VRziRk8RG3K3/B1uiiKb58v8XaDWvUurYuc1fPYviF +6DwooUEEekzxYUPDeHdr9Q0yIznBYQCeMln8w2U9Lw6xRlw4gMWBYqf0u2Vt0x8WbCz 5ildMKSG4yZH5hqp52FiyJKB8FPOQe6igUYRmSO/DoGj/5YXLQJqTSuxO461aMn1KnmL m06TDKh0FVPpkw06+tSiTiShXX0eoCeqBZT1RSIAO10BRmKUMC+P1AAgBWr+WaNEqGC0 8U/uggzFEQ8rfOnXjkIobmTjnJbzhr2Za9KYH+Nb7pc0tSgfLmArpZvyvTvfJ8jiaSaJ lrYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=XORpo+8lcz89CRmiL8wFYI/hY18FJ/e3tPn8ROqODEk=; fh=m4AgftYF7wCI/LpnzBfsOb0qoWNw7odDcx6P/is3tZk=; b=0Lt8XHrjbk69Io3nEDd7IeH01vGlDIM0rS8o2zarCDIwsgU6UNTQLCQMTtWLUl8PYn f4gZzBIHE/CX5KqVKnbpQKC2TcWYdgVo6UILhfmeXu//wNvBeZRF1UHrb/aiyBXXBmFi h8kcBW/2hz68CKfEGhRVH/Awc/qvJ6IOne+CAnQetVc13eNdtuORRMoUNkPodNa5yrBR VPBXGZq630LR91ZV04TXqeQkdJf6/k6arCv0eHogE7nkn0DaoHyegmbji6VlNs1IAWYn L/TviY5NFeCaNC5lnOIGE8z/LlNitpGdyqLIyswlvRM3oYPGXWH7yAvTjlgIm3565e9w hykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JSx4jOPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id o19-20020a170902779300b001cc2ef72ab2si1068954pll.68.2023.12.07.04.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 04:35:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JSx4jOPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id CB897810F679; Thu, 7 Dec 2023 04:34:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232609AbjLGMep (ORCPT + 99 others); Thu, 7 Dec 2023 07:34:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232604AbjLGMem (ORCPT ); Thu, 7 Dec 2023 07:34:42 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E07FF10C7; Thu, 7 Dec 2023 04:34:45 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d06819a9cbso5961125ad.1; Thu, 07 Dec 2023 04:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701952485; x=1702557285; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XORpo+8lcz89CRmiL8wFYI/hY18FJ/e3tPn8ROqODEk=; b=JSx4jOPRLraJk8G0biNuad5XPq405S95GWR1LS0peT3WgFsmWjNBwytR2QR2/VyTVg Ow4OujdnYE1nogbnc27ipu439H6a+oiaC1Obvbvc1X09tAD077VOP4j35bRET0yQaPTG L0490k7aFuS5p94HcYGb3jcwUu1LbIi5VKUiiRaL+baJE97X4vje4vu1MPOxRnsV9X8L cszXrrwrcK+hKG5fqm+QOZl/Sb6vZrc2x4gQjYFebSMHqPf1wU9bY+NTk+0c72pzr9+i Z+6EZdTvaRJIBGXOT7JsyqrNiRlbAhc0N/qFe4gYE9RXeMdIKnVf6cCM93EZDIjXXfD2 T/Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701952485; x=1702557285; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XORpo+8lcz89CRmiL8wFYI/hY18FJ/e3tPn8ROqODEk=; b=WkoOx2R2DvJlnxfsjgw+xTRM2N/MpSglMdHoX6vYlhe+4OWqzc/THDnuMUkg744NsR SY7ggOR0YJQSeQyq0D7KutfBr3l9ybrxcIEIbXBpC8bT7iDvcEfdvNKHnttv9Utzsa+B nW76ziAN2lv9HkGRt/6nRFnRxY6DZlMM55Eg6ao6X2x1Ae/g8362idrjx7/lG1rKYib+ I170D7iTnq4ZMejUgXxHp6bX4A00Xm00J4iCtfKdKlNuvaS1Ss7/jinU6cvbMjxkCn16 w5FUJifIOEavSLTefujX6z1HsTUAopc0+TPEBdBx+QU67xwT7VZiU85Oz8VBL2bgMBgm XbvQ== X-Gm-Message-State: AOJu0Yzdo261DHb7q6KlJwOWR9931foui6BxQ0saz7+df4/mJ6SDJO2v E1tg+FKfsB2/wvttKVYQX9c= X-Received: by 2002:a17:903:2808:b0:1d0:75d8:6ce2 with SMTP id kp8-20020a170903280800b001d075d86ce2mr1706140plb.82.1701952485112; Thu, 07 Dec 2023 04:34:45 -0800 (PST) Received: from 377044c6c369.cse.ust.hk (191host097.mobilenet.cse.ust.hk. [143.89.191.97]) by smtp.gmail.com with ESMTPSA id i10-20020a170902c94a00b001cfad034756sm1288367pla.138.2023.12.07.04.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 04:34:44 -0800 (PST) From: Chengfeng Ye To: 3chas3@gmail.com, davem@davemloft.net, horms@kernel.org, kuba@kernel.org Cc: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chengfeng Ye Subject: [PATCH v3 1/2] atm: solos-pci: Fix potential deadlock on &cli_queue_lock Date: Thu, 7 Dec 2023 12:34:37 +0000 Message-Id: <20231207123437.42669-1-dg573847474@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 04:34:59 -0800 (PST) As &card->cli_queue_lock is acquired under softirq context along the following call chain from solos_bh(), other acquisition of the same lock inside process context should disable at least bh to avoid double lock. console_show() --> spin_lock(&card->cli_queue_lock) --> solos_bh() --> spin_lock(&card->cli_queue_lock) This flaw was found by an experimental static analysis tool I am developing for irq-related deadlock. To prevent the potential deadlock, the patch uses spin_lock_bh() on the card->cli_queue_lock under process context code consistently to prevent the possible deadlock scenario. Fixes: 9c54004ea717 ("atm: Driver for Solos PCI ADSL2+ card.") Signed-off-by: Chengfeng Ye --- V3: change to spin_lock_bh() V2: add fix tag, and slipt into two patches drivers/atm/solos-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index 94fbc3abe60e..95f768b28a5e 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c @@ -449,9 +449,9 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr, struct sk_buff *skb; unsigned int len; - spin_lock(&card->cli_queue_lock); + spin_lock_bh(&card->cli_queue_lock); skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); - spin_unlock(&card->cli_queue_lock); + spin_unlock_bh(&card->cli_queue_lock); if(skb == NULL) return sprintf(buf, "No data.\n"); -- 2.17.1