Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2452716rwr; Fri, 28 Apr 2023 10:28:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KWZTgl9rLHo21wI+WF7FHPaNb2mQYOog6mzhlyfuFLeVP0oXkQ25Ob9UU2uhBY8Sx8fRc X-Received: by 2002:a05:6a20:4421:b0:ee:788b:45e0 with SMTP id ce33-20020a056a20442100b000ee788b45e0mr7650111pzb.40.1682702929835; Fri, 28 Apr 2023 10:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682702929; cv=none; d=google.com; s=arc-20160816; b=YnjPLmCTDgOeYJdATaZ5t16GNhV8Mnf77Eb6A3+b62mnnxlvVSKQ0NZyjoJjPRT09M lmHiR1D1ljOXGQWuw9pc41QJITMsb9QPyxXSj+VRm3YIkE6BuPdqC9FlOGa4N21FCg9r EmzHWFohzQpBKj2msJz/0k43bqXP11RvOQFQyigUh7bQzMGyRdtgw6UgUTO0PGF8o1F6 j2pv8+Jg8SGXEivUYPEQSzreg9m8WHOzQxMDpxCCIUBcAprreTM9U/lMu4EQmb1OZIF6 e+Xwk9EBe0MCBhc8+dP8/f7aXYKg9ee97QEai3SWItnVXoI0N68qhgnMnFX/vNJS6txw SJLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EB1JFeiQIaiAd+BcemyeU1EieGRkJBzun23zhdJkDaw=; b=am7vbnuNjCt7WsJ0W5oWP9XLIgCzFIE8XufPc70YEeu2VMj+ElMGVJ0LaRjzHCIKAw ihq+KpFb9Rw94i6C162r8m49oxC53th+Vh40Q0wLeCvap88OzoECxzsFjiYfiJ6lUKpN XoRqjs45by3BFCRvma7SRj5auKhy97jZTfGpC75ti4sLH6lTxFYdorHg7ooDmFMazO8M gIYxk6mqNewjSHhYphR0g0txMapAw7aCkCquB0Yuu6K1dI1MWCM9aIQnnGXm1zsLjRZm QIAhnONTKiW5IvphwtU0Zxq4qDjqVTeT2yploQGPKXhkKooOv5vHv7Hq7l4Ij5asxYNB BeRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=aCPUNh3L; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020aa79ae9000000b0063d6362a486si19915483pfp.106.2023.04.28.10.28.20; Fri, 28 Apr 2023 10:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@amazon.com header.s=amazon201209 header.b=aCPUNh3L; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346116AbjD1R1r (ORCPT + 99 others); Fri, 28 Apr 2023 13:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346239AbjD1R1p (ORCPT ); Fri, 28 Apr 2023 13:27:45 -0400 Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B5C4EC7; Fri, 28 Apr 2023 10:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1682702858; x=1714238858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EB1JFeiQIaiAd+BcemyeU1EieGRkJBzun23zhdJkDaw=; b=aCPUNh3LbRr8q4S8x5/m5xkA5v1rhnPOEbiCtvcKTqdKFYgynetyFjJ5 BQhdpYu+OOAiX8i4RTRuXInAHRVnKSFPt2Y/TQq4JzZZCtdQ0YDAj/TuM A2MM3E6o0UnHND7pL7PjonbhjM7QVjJeNBsN3BV0CYqaS3aNI+ISF7wIZ Y=; X-IronPort-AV: E=Sophos;i="5.99,235,1677542400"; d="scan'208";a="209268543" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-9694bb9e.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2023 17:27:35 +0000 Received: from EX19MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-m6i4x-9694bb9e.us-east-1.amazon.com (Postfix) with ESMTPS id 0744B845B3; Fri, 28 Apr 2023 17:27:32 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 28 Apr 2023 17:27:32 +0000 Received: from 88665a182662.ant.amazon.com (10.106.101.39) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 28 Apr 2023 17:27:29 +0000 From: Kuniyuki Iwashima To: CC: , , , , , Subject: Re: Fw: [Bug 217383] New: Bluetooth: L2CAP: possible data race in __sco_sock_close() Date: Fri, 28 Apr 2023 10:27:21 -0700 Message-ID: <20230428172721.56267-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230428085239.1cb74647@hermes.local> References: <20230428085239.1cb74647@hermes.local> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.106.101.39] X-ClientProxiedBy: EX19D044UWA001.ant.amazon.com (10.13.139.100) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR 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-bluetooth@vger.kernel.org From: Stephen Hemminger Date: Fri, 28 Apr 2023 08:52:39 -0700 > Begin forwarded message: > > Date: Fri, 28 Apr 2023 10:22:28 +0000 > From: bugzilla-daemon@kernel.org > To: stephen@networkplumber.org > Subject: [Bug 217383] New: Bluetooth: L2CAP: possible data race in __sco_sock_close() > > > https://bugzilla.kernel.org/show_bug.cgi?id=217383 > > Bug ID: 217383 > Summary: Bluetooth: L2CAP: possible data race in > __sco_sock_close() > Product: Networking > Version: 2.5 > Hardware: All > OS: Linux > Status: NEW > Severity: normal > Priority: P3 > Component: Other > Assignee: stephen@networkplumber.org > Reporter: islituo@gmail.com > Regression: No > > 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) Those two sockets have different proto, BTPROTO_L2CAP and BTPROTO_SCO. Also, we cannot shutdown() for not-yet-accepted socket, and both l2cap_sock_accept() and sco_sock_shutdown() take lock_sock(). > > 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 > > -- > You may reply to this email to add a comment. > > You are receiving this mail because: > You are the assignee for the bug.