Linux bluetooth development
 help / color / mirror / Atom feed
From: ZhaoJinming <zhaojinming@uniontech.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	 Marcel Holtmann <marcel@holtmann.org>,
	Paul Menzel <pmenzel@molgen.mpg.de>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] Bluetooth: btintel_pcie: Fix off-by-one bounds checks in synchronous paths
Date: Thu, 20 Aug 2026 17:17:38 +0800	[thread overview]
Message-ID: <20260820-btintel_pcie_bounds_fixes-v1-1-c9dcd1ac8bf6@uniontech.com> (raw)
In-Reply-To: <20260820-btintel_pcie_bounds_fixes-v1-0-c9dcd1ac8bf6@uniontech.com>

Fix two off-by-one errors where '>' should have been '>=' when
checking array indices against queue count:

1. btintel_pcie_send_sync(): tfd_index from tr_hia is used to index
   txq->tfds[] and txq->bufs[]. When tfd_index == txq->count (32),
   btintel_pcie_prepare_tx() writes past the end of both arrays.

2. btintel_pcie_submit_rx(): frbd_index from tr_hia is used to index
   rxq->frbds[] and rxq->bufs[]. When frbd_index == rxq->count (64),
   btintel_pcie_prepare_rx() writes past the end of both arrays.

Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
---
 drivers/bluetooth/btintel_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 2b7231be5973d399f7f2fde344032b2f3e394365..fe50c5699e12ef3819577e0f0bd1b79d4340bd9e 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -401,7 +401,7 @@ static int btintel_pcie_send_sync(struct btintel_pcie_data *data,
 
 	tfd_index = data->ia.tr_hia[BTINTEL_PCIE_TXQ_NUM];
 
-	if (tfd_index > txq->count)
+	if (tfd_index >= txq->count)
 		return -ERANGE;
 
 	/* Firmware raises alive interrupt on HCI_OP_RESET or
@@ -502,7 +502,7 @@ static int btintel_pcie_submit_rx(struct btintel_pcie_data *data)
 
 	frbd_index = data->ia.tr_hia[BTINTEL_PCIE_RXQ_NUM];
 
-	if (frbd_index > rxq->count)
+	if (frbd_index >= rxq->count)
 		return -ERANGE;
 
 	/* Prepare for RX submit. It updates the FRBD with the address of DMA

-- 
2.51.0


  reply	other threads:[~2026-08-20  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  9:17 [PATCH 0/3] Bluetooth: btintel_pcie: Fix array bounds of device-controlled indices ZhaoJinming
2026-08-20  9:17 ` ZhaoJinming [this message]
2026-08-20  9:50   ` bluez.test.bot
2026-08-20  9:17 ` [PATCH 2/3] Bluetooth: btintel_pcie: Fix bounds checks in TX completion handler ZhaoJinming
2026-08-20  9:17 ` [PATCH 3/3] Bluetooth: btintel_pcie: Fix bounds checks in RX " ZhaoJinming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260820-btintel_pcie_bounds_fixes-v1-1-c9dcd1ac8bf6@uniontech.com \
    --to=zhaojinming@uniontech.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=pmenzel@molgen.mpg.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox