From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DA2CA0ECB for ; Mon, 11 Sep 2023 21:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355238AbjIKV5e (ORCPT ); Mon, 11 Sep 2023 17:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240075AbjIKOfx (ORCPT ); Mon, 11 Sep 2023 10:35:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC195F2 for ; Mon, 11 Sep 2023 07:35:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F09CDC433C7; Mon, 11 Sep 2023 14:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694442948; bh=Esuh7iL3XVB0dPUTzmEdFnm0XDrM/IyPSMbAxKfeYJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goNVq2h5/0B0JwKxnM5lL3vd4CCj6+WnAgr77o9ihn2Wdei/XWEiGM2A3cbVL+zHk v9ryIplaOnb2QFaP1tnljX2rF4tDjF7eoPCAiyzaHhqcxM5hOfty0ICT9ikqcZSzbg TNf4xRTzX8wZSGRjxh+L5fzsNKYpqDkkqlHJIRjE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Manish Mandlik , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.4 204/737] Bluetooth: hci_sync: Avoid use-after-free in dbg for hci_add_adv_monitor() Date: Mon, 11 Sep 2023 15:41:03 +0200 Message-ID: <20230911134656.296383301@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.286315610@linuxfoundation.org> References: <20230911134650.286315610@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manish Mandlik [ Upstream commit a2bcd2b63271a93a695fabbfbf459c603d956d48 ] KSAN reports use-after-free in hci_add_adv_monitor(). While adding an adv monitor, hci_add_adv_monitor() calls -> msft_add_monitor_pattern() calls -> msft_add_monitor_sync() calls -> msft_le_monitor_advertisement_cb() calls in an error case -> hci_free_adv_monitor() which frees the *moniter. This is referenced by bt_dev_dbg() in hci_add_adv_monitor(). Fix the bt_dev_dbg() by using handle instead of monitor->handle. Fixes: b747a83690c8 ("Bluetooth: hci_sync: Refactor add Adv Monitor") Signed-off-by: Manish Mandlik Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 04b51ffd946b7..2c845c9a26be0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1957,7 +1957,7 @@ int hci_add_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor) case HCI_ADV_MONITOR_EXT_MSFT: status = msft_add_monitor_pattern(hdev, monitor); bt_dev_dbg(hdev, "add monitor %d msft status %d", - monitor->handle, status); + handle, status); break; } -- 2.40.1