From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452589; b=teOcuHCIXo+dIKn84bmI+MANKRd+UWNYOXLsgWq/HM3EvBKetwgEaJgNjZZXMOEkUs2u QBdSu1RgnoKq8cifd8ecAqWh45m9FyehZpZJblcz/QR4wSYTj975UHVOlgq5npTUw2ak7 2DQgW88juRmVgEJB8j7Xt29/kP2Gv1wY8Qu1ouKyTCKdWOZGijLkBtJM4Kr4z8YalMtBT eJnNlHlQ22bDc+Oux8YCWYhA3unCK1sWRIMaLfxMrNlhYjTLdW1KEvf2bMQZO9Lm5Jeqn Bv7z5g20o2OFOoPHe+dg7inb9LfqIF5mbLPUX084GL30KZ/pdxa9PSgRufaZg19t4xg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452589; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=aUk6LzucK0wpEz1HMEJA9gXbc7lPOhUu7QsTnZ1QmBs=; b=CosLoE0S91o3/wO9kloGBvFTLv5ujSlugrQB6BZskGRfy6+tyf5cO2nccxNPscCBDvsI R/tnH0lxeJ8DZELKFJUK9j+KMUzEnJrQjEadP0E4tmEilWXhoARQyGgt9JadTAbQzrzzE 0xiIVEONzZrCgA3KOglOQ2loxHlVTZnaMvcHo2lF24Fob120DvCukv3lsGbpBt0QBNrJL BXod1E0ygBNFEVd2pkRwzeOMxzuC7xu9cLnwkPKzX06JNw3fLeT0XE44FsT0wIKX+GEZz W1JOMpUTpJOZFtOHvxnarEn6s95ECipCQR2z7mpxSN5/Bvbt6VuRfcXihkugOawCLtg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YUS6M4rh; arc=none smtp.remote-ip=74.125.82.52 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6D1606A33C for ; Sat, 5 Dec 2026 06:36:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3C6D1606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YUS6M4rh Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1a2af4c8d00so11466c88.0 for ; Fri, 04 Dec 2026 22:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452588; x=1797057388; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aUk6LzucK0wpEz1HMEJA9gXbc7lPOhUu7QsTnZ1QmBs=; b=YUS6M4rh3P/N7v0ySlOO+Y0chL8+sVJfosvMtqgt5oZ1CAc/265SO/pEltvoU6AVCQ ZlTIXyWE/AHwx2nc3LeSmHNGDixiNxVX3VjBBBHEKE2LmZ78wJLJ0colAboJYv78+uU2 AxgZYRlSgLP/DEJGNtdFACS8nshsIAhxNcbGxSSup8IgPF1Cj3xmYZvCRRng7ZfOGPd6 Dro8CqHHYbbS0/0EBhXlD9sw7+z1ZVD7xm9X9412xdch9PvKrKPX8NgabkrulKgUmbcZ +mmUUOlqCoLzbisvHNc2f3/MW6+rEgCN7dZPvCLsDpojJseXovKCB6DGnshnCUsbl16i o+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452588; x=1797057388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=aUk6LzucK0wpEz1HMEJA9gXbc7lPOhUu7QsTnZ1QmBs=; b=g1irEfJw4j2J7xXGANe6Bty5QgdEdRjfRjlkni5F6dFNKLXrDmIS5x61B0VfwFM0gw R2SgOv42RFNk5XwQj8yTX4ZVfgxCaMi+9ZzNKomQe235ygmkZro4mwoV5Nc+jHzrZI+t 0IHQE05bQfka5wH6HywR7R+D+aT6u2+M3qftvRmL0LK+cCwK+UstWMYBnsHGPLYw+zYL 8U1EBazEQMSRCTZzGjoB+EA4RF0am6YaQ2DvwZl8H7g3BqJF2SLWXduxMTqyg9aYCVb9 X6B+UiVGsd7sWLvsMR4TdmbqWgpfNwvZjAFEZ4pzuX7iIEPCePzcxBXjqdFT7KNhjgP3 Zrdw== X-Forwarded-Encrypted: i=1; AL+hErGhqffG1yP50mWWGukLA1yzRYKMonHLlCjluvHr9DM9huGjQECQ651My/v9t12aQo44YrgFNMs=@vger.kernel.org X-Gm-Message-State: APuU4Z/GYdbslRbeyEmcmzZJLo8J0LSGwlm7XL0NXvIfoqpoRUpzEjps aVYNByuA6dkauxndTT+blZEikQWe7euFOxuC/UeFy+q0VRXxWnYvhWdv X-Gm-Gg: AZFdTZdJt4xmC0Q6stgg4tmUnrFqapSi07ysBEpVDv9h8GHvlFh+sUgn80+Yayb8sZ4 A12x5fqHr40LFNzGh//4AxV/EN/cHhQFnSKhbtvPoISqmUG7T5AdlLXF0hjvGCihCHY2CWMdWch dCL239Q4LnuueboQEnmAb3OFKaoMBwOA6oxRRepRMVCjrQVwVJp4mBB7uqYrQFht23ocF94nzj7 nDD8M4QmRWnlqABbJlwsKPCCataKBoFsQH0FuwynWELiu1dwzoCQIY+0Ps0kafttuYn/AdhfvIG 9iKuTQj/0gztyzLFCRsZgAr0S9+1d73AYzeYYkHVPX5TyviGvGKEt3noNgl8tnonFv4PGenUSC1 5pDRRQKisP5VC2XQdngoygQTlALK7+muoQjV6NImke7f20RG3wX675hSK+0sOwLVmWBIc5RF3Z1 ZuHocLIUSZo577bDd0QHE5WqercnxYDq1qwjT3SAF0FenrBcY7xtTXKnmhHr/UrhKG/dDDa2LNF HmyNACppPPtovMraUThe02cBjMMdNilAln6gnRDA+XdJ5H8N5WUWF5UoPFikgalo6o8XMNuXuYf W6ZOePGyCYmn1dDGal7IB98OiQ+9e50XvUvsrsACt5huyS49kQnKrzHVfDRXMnQfDFo= X-Received: by 2002:a05:7022:b162:10b0:1a2:2da2:b278 with SMTP id a92af1059eb24-1b5d70f6af1mr4194043c88.14.1796452588385; Fri, 04 Dec 2026 22:36:28 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d642f101sm13623915c88.5.2026.12.04.22.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:36:28 -0800 (PST) From: Praneeth Balasubramanian To: Marcel Holtmann , Luiz Augusto von Dentz Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: btintel: hold req_lock when triggering coredump Date: Fri, 4 Dec 2026 22:36:10 -0800 Message-Id: <20261205063610.2523018-3-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261205063610.2523018-1-praneethb2002@gmail.com> References: <20261205063610.2523018-1-praneethb2002@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit btintel_coredump() calls __hci_cmd_sync() while running from the devcoredump sysfs store, which only holds the device lock. The __hci_cmd_sync() contract requires hdev->req_lock. Without it the coredump trigger command shares hdev->req_status and hdev->req_rsp with the cmd_sync work. A management command issued through MGMT_OP_HCI_CMD_SYNC runs in that work with req_lock held. If both callers are in flight, a single completion stores one skb in hdev->req_rsp and wakes both waiters. Each can read that skb before the other clears the pointer. One path frees it and the other frees it again, a use-after-free followed by a double free. The coredump sysfs file is only writable by root, so the exposure is limited. I found no path in btusb that takes req_lock before the device lock, so taking req_lock here should not deadlock. Wrap the trigger command with hci_req_sync_lock() and hci_req_sync_unlock() so it is serialized against the cmd_sync work as the contract requires. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: af395330abed ("Bluetooth: btintel: Add Intel devcoredump support") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3, then checked against the source and partly rewritten with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64 allmodconfig), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. drivers/bluetooth/btintel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index ca98bd106b86..c6cfbfcfed09 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1713,7 +1713,10 @@ static void btintel_coredump(struct hci_dev *hdev) { struct sk_buff *skb; + hci_req_sync_lock(hdev); skb = __hci_cmd_sync(hdev, 0xfc4e, 0, NULL, HCI_CMD_TIMEOUT); + hci_req_sync_unlock(hdev); + if (IS_ERR(skb)) { bt_dev_err(hdev, "Coredump failed (%ld)", PTR_ERR(skb)); return; -- 2.25.1