Received: by 2002:a9a:4c47:0:b029:116:c383:538 with SMTP id u7csp7571085lko; Fri, 30 Jul 2021 06:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsQH3SZnzO6sTIrNCDAKQlTHrxuGg/X3ejPSSBVOeywKJBIlByA5itVYQ1U8nlgH7epI6o X-Received: by 2002:a02:c95a:: with SMTP id u26mr2270238jao.49.1627652578105; Fri, 30 Jul 2021 06:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627652578; cv=none; d=google.com; s=arc-20160816; b=Ytr162dVoHwwWMfzzsPRpgYLwzR+H6WNHXL9NB/+h+TpoxXP3SmpgpXSCRKlKIhNRT YxoAYgnFJbt5o6mcSBmTrO5q1J2BOxigQHQuAGEBrTiVCiypRxqD/yMUGfIjdeuvdQsl /iILiBzWdJ40AgeqTNhUtMh4c8d9V93gMpDimqZDIB0POadYuMoFvRBy8g2YePpvNzxm Y5RbU6ObaX1VaCdbgPbT3WTmGo72quIJPI8PU4r7MVzr5vqv/4VXXjbIdz9o2sUxpGDI PhQUZlJ5xmVSmYCXZr+T6TSODY1K3FzHas8q1mtQLgSmbGduUAGQ9hkkBIVBDsz2TOp9 98bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=V49Tkft/olqWvZwm6niOAOB+VqMG886oLcUacyVHu1Q=; b=m62DTVt4FF4BkAmYqgyvyTH/rSwexufjNixfURe6kVa0Tv6ZY5tSPPr29+zJoWV7E2 G+wtXFCA7zwKzhfjYx5XQs3YkKqXvet5+3g2Wo/uMhTIlmFdAVupavEzTX0jhEs6tYcc HMtxXX6kUprsyYEr6O30SbASqfM184SKozRUy9+WWBVQXQtJeG/ID/36DdZtfV2PIUEM DauDMex0gbwMC1dGwoD0MSyVLiX5neBFZsIlS347LPwlojLJO1xHpE43ZJJow51kmJay A79bn0Dwhewconh87jjHKSW/ET8U5P2UOqBcrEYvgtn76PShq41XPPVSwtgqfGt2WBm/ 7pvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1840811ilm.119.2021.07.30.06.42.28; Fri, 30 Jul 2021 06:42:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239103AbhG3Nkz convert rfc822-to-8bit (ORCPT + 99 others); Fri, 30 Jul 2021 09:40:55 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:35614 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbhG3Nke (ORCPT ); Fri, 30 Jul 2021 09:40:34 -0400 Received: from smtpclient.apple (p5b3d23f8.dip0.t-ipconnect.de [91.61.35.248]) by mail.holtmann.org (Postfix) with ESMTPSA id 754BFCED30; Fri, 30 Jul 2021 15:40:20 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH v3 2/2] Bluetooth: fix inconsistent lock state in rfcomm_connect_ind From: Marcel Holtmann In-Reply-To: <40f38642-faa9-8c63-4306-6477e272cfbe@gmail.com> Date: Fri, 30 Jul 2021 15:40:19 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Jakub Kicinski , Matthieu Baerts , Stefan Schmidt , linux-bluetooth , "open list:NETWORKING [GENERAL]" , open list , skhan@linuxfoundation.org, Greg Kroah-Hartman , linux-kernel-mentees@lists.linuxfoundation.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20210721093832.78081-1-desmondcheongzx@gmail.com> <20210721093832.78081-3-desmondcheongzx@gmail.com> <06E57598-5723-459D-9CE3-4DD8D3145D86@holtmann.org> <40f38642-faa9-8c63-4306-6477e272cfbe@gmail.com> To: Desmond Cheong Zhi Xi X-Mailer: Apple Mail (2.3654.100.0.2.22) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Desmond, >>> Commit fad003b6c8e3d ("Bluetooth: Fix inconsistent lock state with >>> RFCOMM") fixed a lockdep warning due to sk->sk_lock.slock being >>> acquired without disabling softirq while the lock is also used in >>> softirq context. This was done by disabling interrupts before calling >>> bh_lock_sock in rfcomm_sk_state_change. >>> >>> Later, this was changed in commit e6da0edc24ee ("Bluetooth: Acquire >>> sk_lock.slock without disabling interrupts") to disable softirqs >>> only. >>> >>> However, there is another instance of sk->sk_lock.slock being acquired >>> without disabling softirq in rfcomm_connect_ind. This patch fixes this >>> by disabling local bh before the call to bh_lock_sock. >> back in the days, the packet processing was done in a tasklet, but these days it is done in a workqueue. So shouldn’t this be just converted into a lock_sock(). Am I missing something? > > Thanks for the info. I think you're right, I just didn't understand very much when I wrote this patch. > > If I'm understanding correctly, it seems that both the bh_lock_sock in rfcomm_connect_ind, and spin_lock_bh in rfcomm_sk_state_change need to be changed to lock_sock, otherwise they don't provide any synchronization with other functions in RFCOMM that use lock_sock. > > If that sounds correct I can prepare the patch for that. please do so and re-run the tests. Thanks. Regards Marcel