linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices
@ 2026-09-15  5:12 Ravindra
  2026-09-15  7:30 ` [v1] " bluez.test.bot
  2026-09-21 14:10 ` [PATCH v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Ravindra @ 2026-09-15  5:12 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, kiran.k, Ravindra

In btintel_pcie_msix_rx_handle(), the driver processes RX completion
descriptors (urbd1) written by the PCIe device into DMA-coherent memory.
urbd1->frbd_tag (a 16-bit field fully controlled by the device firmware
via DMA) is used directly as an array index into rxq->bufs[] without any
bounds check. rxq->bufs[] has only BTINTEL_PCIE_RX_DESCS_COUNT (64)
entries, while frbd_tag can be any value 0-65535. A malicious or
malfunctioning device can write an out-of-range frbd_tag, causing the
driver to dereference an out-of-bounds data_buf pointer.

Additionally, cr_hia is read from a DMA-shared index array also writable
by the device; if the device sets cr_hia >= rxq->count, the while-loop
never terminates because cr_tia is wrapped via modulo rxq->count and can
never equal an out-of-range cr_hia.

Add bounds validation for cr_hia and frbd_tag in the RX path, and cr_hia
in the TX path. Log invalid values with bt_dev_err before returning.

Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Signed-off-by: Ravindra <ravindra@intel.com>
---
 drivers/bluetooth/btintel_pcie.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 4807361a58a7..444cc50174fb 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -2065,6 +2065,11 @@ static void btintel_pcie_msix_tx_handle(struct btintel_pcie_data *data)
 
 	txq = &data->txq;
 
+	if (cr_hia >= txq->count) {
+		bt_dev_err(data->hdev, "TXQ: invalid cr_hia %u", cr_hia);
+		return;
+	}
+
 	while (cr_tia != cr_hia) {
 		data->tx_wait_done = true;
 		wake_up(&data->tx_wait_q);
@@ -2644,6 +2649,11 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data)
 
 	rxq = &data->rxq;
 
+	if (cr_hia >= rxq->count) {
+		bt_dev_err(hdev, "RXQ: invalid cr_hia %u", cr_hia);
+		return;
+	}
+
 	/* The firmware sends multiple CD in a single MSI-X and it needs to
 	 * process all received CDs in this interrupt.
 	 */
@@ -2651,6 +2661,12 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data)
 		urbd1 = &rxq->urbd1s[cr_tia];
 		ipc_print_urbd1(data->hdev, urbd1, cr_tia);
 
+		if (urbd1->frbd_tag >= rxq->count) {
+			bt_dev_err(hdev, "RXQ: invalid frbd_tag %u",
+				   urbd1->frbd_tag);
+			return;
+		}
+
 		buf = &rxq->bufs[urbd1->frbd_tag];
 		if (!buf) {
 			bt_dev_err(hdev, "RXQ: failed to get the DMA buffer for %d",
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices
  2026-09-15  5:12 [PATCH v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices Ravindra
@ 2026-09-15  7:30 ` bluez.test.bot
  2026-09-21 14:10 ` [PATCH v1] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-15  7:30 UTC (permalink / raw)
  To: linux-bluetooth, ravindra

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1165082/

---Test result---

Test Summary:
CheckPatch                    PASS      0.62 seconds
VerifyFixes                   PASS      0.08 seconds
VerifySignedoff               PASS      0.08 seconds
GitLint                       PASS      0.24 seconds
SubjectPrefix                 PASS      0.07 seconds
BuildKernel                   PASS      28.40 seconds
CheckAllWarning               PASS      33.55 seconds
CheckSparse                   PASS      35.80 seconds
BuildKernel32                 PASS      29.12 seconds
CheckKernelLLVM               PASS      34.83 seconds
TestRunnerSetup               PASS      768.66 seconds
IncrementalBuild              PASS      26.84 seconds



https://github.com/bluez/bluetooth-next/pull/769

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices
  2026-09-15  5:12 [PATCH v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices Ravindra
  2026-09-15  7:30 ` [v1] " bluez.test.bot
@ 2026-09-21 14:10 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-21 14:10 UTC (permalink / raw)
  To: Ravindra
  Cc: linux-bluetooth, ravishankar.srivatsa, chethan.tumkur.narayan,
	kiran.k

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 15 Sep 2026 10:42:15 +0530 you wrote:
> In btintel_pcie_msix_rx_handle(), the driver processes RX completion
> descriptors (urbd1) written by the PCIe device into DMA-coherent memory.
> urbd1->frbd_tag (a 16-bit field fully controlled by the device firmware
> via DMA) is used directly as an array index into rxq->bufs[] without any
> bounds check. rxq->bufs[] has only BTINTEL_PCIE_RX_DESCS_COUNT (64)
> entries, while frbd_tag can be any value 0-65535. A malicious or
> malfunctioning device can write an out-of-range frbd_tag, causing the
> driver to dereference an out-of-bounds data_buf pointer.
> 
> [...]

Here is the summary with links:
  - [v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices
    https://git.kernel.org/bluetooth/bluetooth-next/c/37a111293453

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-21 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15  5:12 [PATCH v1] Bluetooth: btintel_pcie: validate device-supplied DMA indices Ravindra
2026-09-15  7:30 ` [v1] " bluez.test.bot
2026-09-21 14:10 ` [PATCH v1] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).