mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tuo Li <islituo@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: marcel@holtmann.org, johan.hedberg@gmail.com,
	"David S. Miller" <davem@davemloft.net>,
	edumazet@google.com, Jakub Kicinski <kuba@kernel.org>,
	pabeni@redhat.com, linux-bluetooth@vger.kernel.org,
	netdev@vger.kernel.org,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	baijiaju1990@outlook.com
Subject: Re: [BUG][RESEND] Bluetooth: L2CAP: possible data race in __sco_sock_close()
Date: Mon, 1 May 2023 17:51:20 +0800	[thread overview]
Message-ID: <d9633b9b-c39f-699a-4b05-1c0c55e2dec9@gmail.com> (raw)
In-Reply-To: <CABBYNZJCbYnxodwXAeq8F9NerzGWFva0OG6SfUWfJ_Grz=Xq6Q@mail.gmail.com>

Thanks for your reply and interests. Our static analysis tool is still 
to be improved, and any feedback on it would be appreciated.

On 2023/4/29 5:24, Luiz Augusto von Dentz wrote:
> Hi,
>
> On Fri, Apr 28, 2023 at 3:27 AM Li Tuo <islituo@gmail.com> wrote:
>>    Hello,
>>
>> Our static analysis tool finds a possible data race in the l2cap protocol
>> in Linux 6.3.0-rc7:
>>
>> In most calling contexts, the variable sk->sk_socket is accessed
>> with holding the lock sk->sk_callback_lock. Here is an example:
>>
>>    l2cap_sock_accept() --> Line 346 in net/bluetooth/l2cap_sock.c
>>        bt_accept_dequeue() --> Line 368 in net/bluetooth/l2cap_sock.c
>>            sock_graft() --> Line 240 in net/bluetooth/af_bluetooth.c
>>                write_lock_bh(&sk->sk_callback_lock); --> Line 2081 in include/net/sock.h (Lock sk->sk_callback_lock)
>>                sk_set_socket() --> Line 2084 in include/net/sock.h
>>                    sk->sk_socket = sock; --> Line 2054 in include/net/sock.h (Access sk->sk_socket)
>>
>> However, in the following calling context:
>>
>>    sco_sock_shutdown() --> Line 1227 in net/bluetooth/sco.c
>>        __sco_sock_close() --> Line 1243 in net/bluetooth/sco.c
>>            BT_DBG(..., sk->sk_socket); --> Line 431 in net/bluetooth/sco.c (Access sk->sk_socket)
>>
>> the variable sk->sk_socket is accessed without holding the lock
>> sk->sk_callback_lock, and thus a data race may occur.
>>
>> Reported-by: BassCheck <bass@buaa.edu.cn>
> Need to check in detail what it means to hold the sk_callback_lock,
> btw is this static analysis tool of yours something public that we can
> use in our CI to detect these problems?
>
>


      reply	other threads:[~2023-05-01  9:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CADm8TemwbUWDP0R_t7axFk4=4-srnm5c+2oJSy7aeSzdKFSVCA@mail.gmail.com>
2023-04-28 21:24 ` Luiz Augusto von Dentz
2023-05-01  9:51   ` Tuo Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9633b9b-c39f-699a-4b05-1c0c55e2dec9@gmail.com \
    --to=islituo@gmail.com \
    --cc=baijiaju1990@outlook.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johan.hedberg@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®