The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup
@ 2024-04-22 13:57 Johan Hovold
  2024-04-22 13:57 ` [PATCH RESEND 1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johan Hovold @ 2024-04-22 13:57 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zhengping Jiang, linux-bluetooth, linux-kernel, Johan Hovold

Qualcomm Bluetooth controllers can be registered either from a serdev
driver or from the Bluetooth line discipline. In the latter case, the
HCI UART serdev pointer is NULL, something which the driver needs to
handle without crashing.

This series fixes one such issue at setup() time which incidentally
masked a similar crash at suspend. Fix this in two separate patches so
that the latter issue is addressed in pre-6.2 stable kernels.

Johan


Johan Hovold (2):
  Bluetooth: qca: fix NULL-deref on non-serdev suspend
  Bluetooth: qca: fix NULL-deref on non-serdev setup

 drivers/bluetooth/hci_qca.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
2.43.2


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

* [PATCH RESEND 1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend
  2024-04-22 13:57 [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
@ 2024-04-22 13:57 ` Johan Hovold
  2024-04-22 13:57 ` [PATCH RESEND 2/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
  2024-04-22 15:30 ` [PATCH RESEND 0/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2024-04-22 13:57 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zhengping Jiang, linux-bluetooth, linux-kernel, Johan Hovold,
	stable

Qualcomm ROME controllers can be registered from the Bluetooth line
discipline and in this case the HCI UART serdev pointer is NULL.

Add the missing sanity check to prevent a NULL-pointer dereference when
wakeup() is called for a non-serdev controller during suspend.

Just return true for now to restore the original behaviour and address
the crash with pre-6.2 kernels, which do not have commit e9b3e5b8c657
("Bluetooth: hci_qca: only assign wakeup with serial port support") that
causes the crash to happen already at setup() time.

Fixes: c1a74160eaf1 ("Bluetooth: hci_qca: Add device_may_wakeup support")
Cc: stable@vger.kernel.org      # 5.13
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/bluetooth/hci_qca.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 92fa20f5ac7d..94c85f4fbf3b 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1672,6 +1672,9 @@ static bool qca_wakeup(struct hci_dev *hdev)
 	struct hci_uart *hu = hci_get_drvdata(hdev);
 	bool wakeup;
 
+	if (!hu->serdev)
+		return true;
+
 	/* BT SoC attached through the serial bus is handled by the serdev driver.
 	 * So we need to use the device handle of the serdev driver to get the
 	 * status of device may wakeup.
-- 
2.43.2


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

* [PATCH RESEND 2/2] Bluetooth: qca: fix NULL-deref on non-serdev setup
  2024-04-22 13:57 [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
  2024-04-22 13:57 ` [PATCH RESEND 1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend Johan Hovold
@ 2024-04-22 13:57 ` Johan Hovold
  2024-04-22 15:30 ` [PATCH RESEND 0/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2024-04-22 13:57 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zhengping Jiang, linux-bluetooth, linux-kernel, Johan Hovold,
	stable

Qualcomm ROME controllers can be registered from the Bluetooth line
discipline and in this case the HCI UART serdev pointer is NULL.

Add the missing sanity check to prevent a NULL-pointer dereference when
setup() is called for a non-serdev controller.

Fixes: e9b3e5b8c657 ("Bluetooth: hci_qca: only assign wakeup with serial port support")
Cc: stable@vger.kernel.org      # 6.2
Cc: Zhengping Jiang <jiangzp@google.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/bluetooth/hci_qca.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 94c85f4fbf3b..b621a0a40ea4 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1958,8 +1958,10 @@ static int qca_setup(struct hci_uart *hu)
 		qca_debugfs_init(hdev);
 		hu->hdev->hw_error = qca_hw_error;
 		hu->hdev->cmd_timeout = qca_cmd_timeout;
-		if (device_can_wakeup(hu->serdev->ctrl->dev.parent))
-			hu->hdev->wakeup = qca_wakeup;
+		if (hu->serdev) {
+			if (device_can_wakeup(hu->serdev->ctrl->dev.parent))
+				hu->hdev->wakeup = qca_wakeup;
+		}
 	} else if (ret == -ENOENT) {
 		/* No patch/nvm-config found, run with original fw/config */
 		set_bit(QCA_ROM_FW, &qca->flags);
-- 
2.43.2


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

* Re: [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup
  2024-04-22 13:57 [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
  2024-04-22 13:57 ` [PATCH RESEND 1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend Johan Hovold
  2024-04-22 13:57 ` [PATCH RESEND 2/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
@ 2024-04-22 15:30 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2024-04-22 15:30 UTC (permalink / raw)
  To: Johan Hovold; +Cc: marcel, luiz.dentz, jiangzp, linux-bluetooth, linux-kernel

Hello:

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

On Mon, 22 Apr 2024 15:57:46 +0200 you wrote:
> Qualcomm Bluetooth controllers can be registered either from a serdev
> driver or from the Bluetooth line discipline. In the latter case, the
> HCI UART serdev pointer is NULL, something which the driver needs to
> handle without crashing.
> 
> This series fixes one such issue at setup() time which incidentally
> masked a similar crash at suspend. Fix this in two separate patches so
> that the latter issue is addressed in pre-6.2 stable kernels.
> 
> [...]

Here is the summary with links:
  - [RESEND,1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend
    https://git.kernel.org/bluetooth/bluetooth-next/c/8185331e953d
  - [RESEND,2/2] Bluetooth: qca: fix NULL-deref on non-serdev setup
    https://git.kernel.org/bluetooth/bluetooth-next/c/9201f29be2c9

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] 4+ messages in thread

end of thread, other threads:[~2024-04-22 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-22 13:57 [PATCH RESEND 0/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
2024-04-22 13:57 ` [PATCH RESEND 1/2] Bluetooth: qca: fix NULL-deref on non-serdev suspend Johan Hovold
2024-04-22 13:57 ` [PATCH RESEND 2/2] Bluetooth: qca: fix NULL-deref on non-serdev setup Johan Hovold
2024-04-22 15:30 ` [PATCH RESEND 0/2] " 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