Skip to contentSkip to conversation

Bluetooth: qca: fix NULL-deref on non-serdev setup

PATCH Superseded Johan Hovold 5 participants 17 messages Mar 19, 2024 – Apr 22, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Bluetooth: qca: fix NULL-deref on non-serdev setup

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 address 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(-)
Signature · 1 line
2.43.2
#1 lore raw

PATCH 1/2 Bluetooth: qca: fix NULL-deref on non-serdev suspend

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")
---
 drivers/bluetooth/hci_qca.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/bluetooth/hci_qca.c +3 -0
index c73481c57741..84f728943962 100644
@@ -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.
Signature · 1 line
2.43.2
#3 lore raw

PATCH 2/2 Bluetooth: qca: fix NULL-deref on non-serdev setup

In reply to Johan Hovold

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 Zhengping Jiang <[email protected]>
---
 drivers/bluetooth/hci_qca.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +4 -2
index 84f728943962..6a69a7f9ef64 100644
@@ -1960,8 +1960,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);
Signature · 1 line
2.43.2
#2 lore raw
In reply to Johan Hovold

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/project/bluetooth/list/?series=836459

---Test result---

Test Summary:

CheckPatch                    PASS      1.37 seconds
GitLint                       PASS      0.68 seconds
SubjectPrefix                 PASS      0.26 seconds
BuildKernel                   PASS      28.52 seconds
CheckAllWarning               PASS      31.44 seconds
CheckSparse                   PASS      37.17 seconds
CheckSmatch                   PASS      100.28 seconds
BuildKernel32                 PASS      28.14 seconds
TestRunnerSetup               PASS      519.52 seconds
TestRunner_l2cap-tester       PASS      20.20 seconds
TestRunner_iso-tester         PASS      30.52 seconds
TestRunner_bnep-tester        PASS      4.81 seconds
TestRunner_mgmt-tester        FAIL      108.33 seconds
TestRunner_rfcomm-tester      PASS      7.41 seconds
TestRunner_sco-tester         PASS      15.08 seconds
TestRunner_ioctl-tester       PASS      7.89 seconds
TestRunner_mesh-tester        PASS      5.91 seconds
TestRunner_smp-tester         PASS      6.93 seconds
TestRunner_userchan-tester    PASS      5.04 seconds
IncrementalBuild              PASS      32.26 seconds

Details
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2

Failed Test Cases
LL Privacy - Add Device 7 (AL is full) Failed 0.202 seconds

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Johan Hovold

Hi Luiz,

Quoted 5 lines · 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.

Quoted 7 lines

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 address in pre-6.2 stable kernels.

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

Johan

#5 lore raw
Quoted 16 lines · Johan Hovold

Hi Luiz,

Quoted 5 lines · 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.

Quoted 7 lines

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 address in pre-6.2 stable kernels.

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

Quoted 8 lines

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

Johan

Hi johan,
could you share the patch links for me to review. i can 't find them now

#6 lore raw
Quoted 7 lines · quic_zijuhu
Quoted 6 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Quoted 8 lines
Quoted 5 lines

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

	https://lore.kernel.org/lkml/[email protected]/

Johan

#7 lore raw
Quoted 17 lines · Johan Hovold
Quoted 7 lines · quic_zijuhu
Quoted 6 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Quoted 8 lines
Quoted 5 lines

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Quoted 6 lines

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

	https://lore.kernel.org/lkml/[email protected]/

Johan

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].
NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

#8 lore raw
Quoted 18 lines · quic_zijuhu
Quoted 17 lines · Johan Hovold
Quoted 15 lines · quic_zijuhu
Quoted 11 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Quoted 7 lines
Quoted 4 lines

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

	https://lore.kernel.org/lkml/[email protected]/

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

The fix does not depend on your btattach series, which has also been rejected.

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan

[1] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m8e495666a71eb0e7ae54c82554dfff1fc96983e7
[2] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#med0610646a8fd8b3c8586abca9895b124b2d2534

#14 lore raw
In reply to Johan Hovold

Hi Johan,

Quoted 15 lines · Johan Hovold
Quoted 12 lines · quic_zijuhu
Quoted 11 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

Quoted 7 lines
Quoted 2 lines

could you share the patch links for me to review. i can 't find them now

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

        https://lore.kernel.org/lkml/[email protected]/

Did you send these to linux-bluetooth? I don't see them in:

https://patchwork.kernel.org/project/bluetooth/list/

Signature · 1 line
Luiz Augusto von Dentz
#16 lore raw

Hi Johan,

Quoted 8 lines · Johan Hovold
Quoted 6 lines · Luiz Augusto von Dentz
Quoted 1 line · Johan Hovold
        https://lore.kernel.org/lkml/[email protected]/

Did you send these to linux-bluetooth? I don't see them in:

Quoted 8 lines
Quoted 1 line

https://patchwork.kernel.org/project/bluetooth/list/

Yes, I did and they are in the linux-bluetooth archives on lore. Not sure why they don't show up in the tracker.

Do you want me to resend?

Johan

Yes, please resend them.

Signature · 1 line
Luiz Augusto von Dentz
#9 lore raw
In reply to Johan Hovold
Quoted 30 lines · Johan Hovold
Quoted 18 lines · quic_zijuhu
Quoted 17 lines · Johan Hovold
Quoted 15 lines · quic_zijuhu
Quoted 11 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Quoted 7 lines
Quoted 4 lines

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

	https://lore.kernel.org/lkml/[email protected]/

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 7 lines
Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

The fix does not depend on your btattach series, which has also been rejected.

these my v1 and v2 for this issue which are earlier then yours. they are not rejected but not responded.

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

Quoted 9 lines

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan

[1] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m8e495666a71eb0e7ae54c82554dfff1fc96983e7
[2] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#med0610646a8fd8b3c8586abca9895b124b2d2534

#10 lore raw

Hi Quic_zijuhu,

Quoted 36 lines · quic_zijuhu
Quoted 34 lines · Johan Hovold
Quoted 18 lines · quic_zijuhu
Quoted 17 lines · Johan Hovold
Quoted 15 lines · quic_zijuhu
Quoted 11 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Quoted 7 lines
Quoted 4 lines

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

    https://lore.kernel.org/lkml/[email protected]/

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

Quoted 19 lines
Quoted 3 lines

The fix does not depend on your btattach series, which has also been rejected.

these my v1 and v2 for this issue which are earlier then yours. they are not rejected but not responded.

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

Quoted 9 lines

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan

[1] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m8e495666a71eb0e7ae54c82554dfff1fc96983e7
[2] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#med0610646a8fd8b3c8586abca9895b124b2d2534

They probably need to be resend as well, you have so many sets pending that makes it hard to know which should go first, next time please wait until each set is merged before sending the next since I can't know if they are really independent of each other or not.

Signature · 1 line
Luiz Augusto von Dentz
#11 lore raw
Quoted 55 lines · Luiz Augusto von Dentz

Hi Quic_zijuhu,

Quoted 52 lines · quic_zijuhu
Quoted 30 lines · Johan Hovold
Quoted 18 lines · quic_zijuhu
Quoted 17 lines · Johan Hovold
Quoted 15 lines · quic_zijuhu
Quoted 11 lines · Johan Hovold
Quoted 3 lines · Johan Hovold

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

Could you pick these up for 6.9 or 6.10?

The patches are marked for stable backport and only privileged users can set the N_HCI line discipline these days (even if I'm not sure about pre-5.14 kernels...) so it may be fine to wait for 6.10 if you prefer.

could you share the patch links for me to review. i can 't find them now

Quoted 7 lines
Quoted 4 lines

Sure, but you should bookmark lore.kernel.org in your browser as you can search the archives there yourself:

    https://lore.kernel.org/lkml/[email protected]/

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 7 lines
Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

The fix does not depend on your btattach series, which has also been rejected.

these my v1 and v2 for this issue which are earlier then yours. they are not rejected but not responded.

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

Quoted 7 lines

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

[1] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#m8e495666a71eb0e7ae54c82554dfff1fc96983e7
[2] https://lore.kernel.org/linux-bluetooth/[email protected]/T/#med0610646a8fd8b3c8586abca9895b124b2d2534

They probably need to be resend as well, you have so many sets pending that makes it hard to know which should go first, next time please wait until each set is merged before sending the next since I can't know if they are really independent of each other or not.

okay. let me also provide a list of patches required for BT maintainers in another thread.

#12 lore raw
In reply to quic_zijuhu
Quoted 14 lines · quic_zijuhu
Quoted 13 lines · Johan Hovold
Quoted 4 lines · quic_zijuhu

On 4/22/2024 9:20 PM, Johan Hovold wrote:

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

Quoted 8 lines
Quoted 3 lines

The fix does not depend on your btattach series, which has also been rejected.

these my v1 and v2 for this issue which are earlier then yours. they are not rejected but not responded.

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

Here is your *v3* as part of the rejected btattach series:

	https://lore.kernel.org/all/[email protected]/

Apparently you had earlier also sent it separately, I see now in lore. It's all a big mess.

Quoted 4 lines
Quoted 4 lines

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan

#13 lore raw
Quoted 21 lines · Johan Hovold
Quoted 20 lines · quic_zijuhu
Quoted 9 lines · Johan Hovold
Quoted 4 lines · quic_zijuhu

On 4/22/2024 9:20 PM, Johan Hovold wrote:

NAK for your [PATCH 1/2] since the null checking is redundant with your [PATCH 2/2].

I explained in the cover letter why it is split up like this. If you don't bother reading, then we will not bother listening to you.

Quoted 7 lines
Quoted 3 lines

NAK for your [PATCH 2/2], since it is same with my earlier fix
https://lore.kernel.org/all/[email protected]/
my new patchset for btattach tool still has this change.

The fix does not depend on your btattach series, which has also been rejected.

these my v1 and v2 for this issue which are earlier then yours. they are not rejected but not responded.

Quoted 7 lines
Quoted 2 lines

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

Here is your *v3* as part of the rejected btattach series:

	https://lore.kernel.org/all/[email protected]/

no, v3 is a separate patch here and not was rejected.
https://lore.kernel.org/all/[email protected]/
and it was sent after your patch.

then i included the fix into a patch serials for tool btattach shown by below link
https://lore.kernel.org/all/[email protected]/
you reviewed my the serials and also did not rejected the fix. and it also doesn't get any negative comments.

Quoted 9 lines

Apparently you had earlier also sent it separately, I see now in lore. It's all a big mess.

Quoted 4 lines
Quoted 4 lines

You clearly have some learning to do on how to interact with the kernel community and to write proper commit messages and patches. If you start listening to feedback and try not to piss everyone off perhaps you can even get your patches merged one day. [1][2]

Johan