Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1375060rwb; Fri, 5 Aug 2022 00:15:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR7uB395iDIPyCSsWFPICVhRJzvko+UloMwkWqgWMTOZ3/Kv5biJpquCNbA4qaLHZvEIRUyN X-Received: by 2002:a17:90b:390c:b0:1f5:8859:ac76 with SMTP id ob12-20020a17090b390c00b001f58859ac76mr1971278pjb.137.1659683716041; Fri, 05 Aug 2022 00:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659683716; cv=none; d=google.com; s=arc-20160816; b=sxU/p9P/euDoNpHaTDasUR8L6jucrANxJO9CEGVIvxtASGgDZLmL0gYZvvHxAT4Uha PgrB6W7aUKIMejJkEzCtYny0sPCa93k2WRUPw72zuz1ij3+dwJTSZ88dt8xYATShiLcx xkXjjjOpXA1chcSoLEaSEPVfGAF1p8gBWdmhu1VazWhbOU2aSIGmqMzz7V6NK8uDHSoG MPeNa10VZA75qICzY+pghJCw/1VYTj04zXgnPuHsg/Yz9+TmLyi+N2vC9r2tTSq5YohM Zet55ceaR/1kupdLbr0eUmb/NuNWBTyxI79cFPxTsdXZOuToQDqGzaB5leG0VQi48foi Rf6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc:to:from :references:content-language:subject:user-agent:mime-version:date :message-id; bh=bqMH9ODacCoXZm3o82DKTn1M0YkWXO5qdYOSvLy/Mng=; b=UJZ9fuar9sawhJlEX1OUX8x/hqL6spln+DGDUqGBUMFTOuIby5iBqcfABk2VDxjI9d zLm0hKXAdc0u8eH11jsUzO7CkvmeJU0Pns0u670Wn8qfVZfzA2fCmb/ViDh2c1IvYU+6 12Ua9IZ7d6/TGbtIRfJ82KSVNA2TBz6GHgPIbgNI6nATZAkLgditeIy7giHMmT+3PWf1 PN32rdbObudiWrNOALAQg/UbCgSnaVCC25pA1ojtV13yRx+uYAboTGk9GyrdHTuNK1EK Q8YK8e9okiEtMmKtKOU0wUOz+n/nOrze67XekPDZrGxglTvghYhdXFQ0U4j//8ijdUed OzQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a63c145000000b0041c2c83b15bsi2449697pgi.639.2022.08.05.00.14.48; Fri, 05 Aug 2022 00:15:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240160AbiHEHM3 (ORCPT + 99 others); Fri, 5 Aug 2022 03:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240233AbiHEHM2 (ORCPT ); Fri, 5 Aug 2022 03:12:28 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1A513D13 for ; Fri, 5 Aug 2022 00:12:23 -0700 (PDT) Received: from fsav415.sakura.ne.jp (fsav415.sakura.ne.jp [133.242.250.114]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 2757CLI8078107; Fri, 5 Aug 2022 16:12:21 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav415.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp); Fri, 05 Aug 2022 16:12:21 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 2757CKom078102 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 5 Aug 2022 16:12:20 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <244af2fe-5340-9e63-a354-d5ab7d155dc4@I-love.SAKURA.ne.jp> Date: Fri, 5 Aug 2022 16:12:18 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: [PATCH (urgent)] Bluetooth: don't try to cancel uninitialized works at mgmt_index_removed() Content-Language: en-US References: <00000000000008dcfa05e5672b3a@google.com> From: Tetsuo Handa To: Brian Gix , Luiz Augusto von Dentz Cc: Marcel Holtmann , Johan Hedberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "linux-bluetooth@vger.kernel.org" In-Reply-To: <00000000000008dcfa05e5672b3a@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 syzbot is reporting attempt to cancel uninitialized work at mgmt_index_removed() [1], for calling cancel_delayed_work_sync() without INIT_DELAYED_WORK() is not permitted. INIT_DELAYED_WORK() is called from mgmt_init_hdev() via chan->hdev_init() from hci_mgmt_cmd(), but cancel_delayed_work_sync() is unconditionally called from mgmt_index_removed(). Call cancel_delayed_work_sync() only if HCI_MGMT flag was set, for mgmt_init_hdev() sets HCI_MGMT flag when calling INIT_DELAYED_WORK(). Link: https://syzkaller.appspot.com/bug?extid=b8ddd338a8838e581b1c [1] Reported-by: syzbot Signed-off-by: Tetsuo Handa Fixes: 0ef08313cefdd60d ("Bluetooth: Convert delayed discov_off to hci_sync") --- I can't test this patch due to lack of reproducer. But please review and send to linux.git as soon as possible, for currently syzbot can't test changes for 6.0-rc1 due to this problem (please see "Instances:" table at https://syzkaller.appspot.com/upstream ). syzbot was unable to test linux-next.git since 20220628 due to a different bug. As an unfortunate result, this bug (being there since 20220725) which would have been already found and fixed in linux-next.git arrived at linux.git... net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f0bb2fc883d7..6e31023b84f5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8935,6 +8935,8 @@ void mgmt_index_removed(struct hci_dev *hdev) HCI_MGMT_EXT_INDEX_EVENTS); /* Cancel any remaining timed work */ + if (!hci_dev_test_flag(hdev, HCI_MGMT)) + return; cancel_delayed_work_sync(&hdev->discov_off); cancel_delayed_work_sync(&hdev->service_cache); cancel_delayed_work_sync(&hdev->rpa_expired); -- 2.34.1