Bluetooth: hci_uart: Fix NULL deref in recv callbacks when priv is uninitialized
PATCH 1/1 Bluetooth: hci_uart: Fix NULL deref in recv callbacks when priv is uninitialized
When a fault is injected during hci_uart line discipline setup, the proto open() callback may fail leaving hu->priv as NULL. A subsequent TIOCSTI ioctl can trigger the recv() callback before priv is initialized, causing a NULL pointer dereference.
Fix all four affected HCI UART protocol drivers by adding a NULL check on hu->priv at the start of their recv() callbacks: h4, h5, ath and bcsp.
--- drivers/bluetooth/hci_ath.c | 3 +++ drivers/bluetooth/hci_bcsp.c | 3 +++ drivers/bluetooth/hci_h4.c | 3 +++ drivers/bluetooth/hci_h5.c | 3 +++ 4 files changed, 12 insertions(+)
drivers/bluetooth/hci_ath.c +3 -0
@@ -191,6 +191,9 @@ static int ath_recv(struct hci_uart *hu, const void *data, int count) {struct ath_struct *ath = hu->priv; +if (!ath) +return -ENODEV ; + ath->rx_skb =h4_recv_buf (hu, ath->rx_skb, data, count, ath_recv_pkts,ARRAY_SIZE (ath_recv_pkts));if (IS_ERR (ath->rx_skb)) {
drivers/bluetooth/hci_bcsp.c +3 -0
@@ -585,6 +585,9 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)if (!test_bit (HCI_UART_REGISTERED , &hu->flags))return -EUNATCH ; +if (!bcsp) +return -ENODEV ; +BT_DBG ("hu %p count %d rx_state %d rx_count %ld" , hu, count, bcsp->rx_state, bcsp->rx_count);
drivers/bluetooth/hci_h4.c +3 -0
@@ -109,6 +109,9 @@ static int h4_recv(struct hci_uart *hu, const void *data, int count) {struct h4_struct *h4 = hu->priv; +if (!h4) +return -ENODEV ; + h4->rx_skb =h4_recv_buf (hu, h4->rx_skb, data, count, h4_recv_pkts,ARRAY_SIZE (h4_recv_pkts));if (IS_ERR (h4->rx_skb)) {
drivers/bluetooth/hci_h5.c +3 -0
@@ -587,6 +587,9 @@ static int h5_recv(struct hci_uart *hu, const void *data, int count)struct h5 *h5 = hu->priv;const unsigned char *ptr = data; +if (!h5) +return -ENODEV ; +BT_DBG ("%s pending %zu count %d" , hu->hdev->name, h5->rx_pending, count);
Signature · 1 line
2.53.0
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=1083813
---Test result---
Test Summary:
CheckPatch FAIL 1.16 seconds GitLint PASS 0.21 seconds SubjectPrefix PASS 0.06 seconds BuildKernel PASS 27.17 seconds CheckAllWarning PASS 29.88 seconds CheckSparse PASS 28.56 seconds BuildKernel32 PASS 26.33 seconds TestRunnerSetup PASS 586.79 seconds IncrementalBuild PASS 25.74 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
Bluetooth: hci_uart: Fix NULL deref in recv callbacks when priv is uninitialized
WARNING: Non-standard signature: Assisted-by:
#96:
ERROR: Unrecognized email address: 'Claude:claude-sonnet-4-6' #96:
WARNING: The commit message has 'syzkaller', perhaps it also needs a 'Fixes:' tag?
total: 1 errors, 2 warnings, 36 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14532478.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
https://github.com/bluez/bluetooth-next/pull/110
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 10 lines · On Tue, 21 Apr 2026 15:53:31 +0200 you wrote:
When a fault is injected during
hci_uartline discipline setup, the protoopen()callback may fail leavinghu->privas NULL. A subsequent TIOCSTI ioctl can trigger therecv()callback before priv is initialized, causing a NULL pointer dereference.Fix all four affected HCI UART protocol drivers by adding a NULL check on
hu->privat the start of theirrecv()callbacks: h4, h5, ath and bcsp.[...]
Here is the summary with links:
- Bluetooth: hci_uart: Fix NULL deref in recv callbacks when priv is uninitialized
https://git.kernel.org/bluetooth/bluetooth-next/c/259c0a6e10fb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html