Bluetooth: qca: fix NULL-deref on non-serdev setup
Subsystems (3)
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 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(-)
Signature · 1 line
2.43.2
PATCH RESEND 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.
--- drivers/bluetooth/hci_qca.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/hci_qca.c +3 -0
@@ -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
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=846689
---Test result---
Test Summary:
CheckPatch PASS 1.25 seconds GitLint PASS 0.55 seconds SubjectPrefix PASS 0.20 seconds BuildKernel PASS 30.52 seconds CheckAllWarning PASS 33.41 seconds CheckSparse PASS 39.05 seconds CheckSmatch FAIL 35.60 seconds BuildKernel32 PASS 29.92 seconds TestRunnerSetup PASS 532.50 seconds TestRunner_l2cap-tester PASS 18.42 seconds TestRunner_iso-tester FAIL 31.55 seconds TestRunner_bnep-tester PASS 4.68 seconds TestRunner_mgmt-tester FAIL 112.15 seconds TestRunner_rfcomm-tester PASS 7.39 seconds TestRunner_sco-tester PASS 15.04 seconds TestRunner_ioctl-tester PASS 7.75 seconds TestRunner_mesh-tester PASS 5.84 seconds TestRunner_smp-tester PASS 6.80 seconds TestRunner_userchan-tester PASS 4.99 seconds IncrementalBuild PASS 33.50 seconds
Details
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:
Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139 make[4]: *** Deleting file 'net/bluetooth/hci_core.o'
make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: net] Error 2
make[2]: *** Waiting for unfinished jobs....
Segmentation fault (core dumped)
make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139 make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o'
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 122, Passed: 121 (99.2%), Failed: 1, Not Run: 0
Failed Test Cases
ISO Connect2 Suspend - Success Failed 4.245 seconds
##############################
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.195 seconds
---
Regards,
Linux Bluetooth
PATCH RESEND 2/2 Bluetooth: qca: fix NULL-deref on non-serdev setup
In reply to Johan HovoldQualcomm 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.
--- drivers/bluetooth/hci_qca.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +4 -2
@@ -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);
Signature · 1 line
2.43.2
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 10 lines · 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html