Message ID | c7f1e8e5-e752-9ea7-ffe7-0ecc282bd92a@salutedevices.com (mailing list archive) |
---|---|
State | Accepted |
Commit | e2040fe3b82b6c9b430a5b272e5924e8ace9a8f0 |
Headers | show |
Series | [RESEND,v1] Bluetooth: hci_uart: fix race during initialization | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/SubjectPrefix | success | Gitlint PASS |
tedd_an/BuildKernel | success | BuildKernel PASS |
tedd_an/CheckAllWarning | success | CheckAllWarning PASS |
tedd_an/CheckSparse | success | CheckSparse PASS |
tedd_an/BuildKernel32 | success | BuildKernel32 PASS |
tedd_an/TestRunnerSetup | success | TestRunnerSetup PASS |
tedd_an/TestRunner_l2cap-tester | success | TestRunner PASS |
tedd_an/TestRunner_iso-tester | success | TestRunner PASS |
tedd_an/TestRunner_bnep-tester | success | TestRunner PASS |
tedd_an/TestRunner_mgmt-tester | fail | TestRunner_mgmt-tester: Total: 490, Passed: 482 (98.4%), Failed: 4, Not Run: 4 |
tedd_an/TestRunner_rfcomm-tester | success | TestRunner PASS |
tedd_an/TestRunner_sco-tester | success | TestRunner PASS |
tedd_an/TestRunner_ioctl-tester | success | TestRunner PASS |
tedd_an/TestRunner_mesh-tester | success | TestRunner PASS |
tedd_an/TestRunner_smp-tester | success | TestRunner PASS |
tedd_an/TestRunner_userchan-tester | success | TestRunner PASS |
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=933244 ---Test result--- Test Summary: CheckPatch PENDING 0.41 seconds GitLint PENDING 0.30 seconds SubjectPrefix PASS 0.07 seconds BuildKernel PASS 25.16 seconds CheckAllWarning PASS 27.80 seconds CheckSparse PASS 31.43 seconds BuildKernel32 PASS 25.03 seconds TestRunnerSetup PASS 440.87 seconds TestRunner_l2cap-tester PASS 21.05 seconds TestRunner_iso-tester PASS 32.42 seconds TestRunner_bnep-tester PASS 4.93 seconds TestRunner_mgmt-tester FAIL 117.81 seconds TestRunner_rfcomm-tester PASS 7.76 seconds TestRunner_sco-tester PASS 9.54 seconds TestRunner_ioctl-tester PASS 8.47 seconds TestRunner_mesh-tester PASS 6.26 seconds TestRunner_smp-tester PASS 7.20 seconds TestRunner_userchan-tester PASS 5.15 seconds IncrementalBuild PENDING 0.86 seconds Details ############################## Test: CheckPatch - PENDING Desc: Run checkpatch.pl script Output: ############################## Test: GitLint - PENDING Desc: Run gitlint Output: ############################## Test: TestRunner_mgmt-tester - FAIL Desc: Run mgmt-tester with test-runner Output: Total: 490, Passed: 482 (98.4%), Failed: 4, Not Run: 4 Failed Test Cases LL Privacy - Add Device 3 (AL is full) Failed 0.205 seconds LL Privacy - Set Flags 1 (Add to RL) Failed 0.154 seconds LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.191 seconds LL Privacy - Set Device Flag 1 (Device Privacy) Failed 0.141 seconds ############################## Test: IncrementalBuild - PENDING Desc: Incremental build with the patches in the series Output: --- Regards, Linux Bluetooth
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Wed, 12 Feb 2025 18:59:46 +0300 you wrote: > Do not set 'HCI_UART_PROTO_READY' before call 'hci_uart_register_dev()'. > Possible race is when someone calls 'hci_tty_uart_close()' after this bit > is set, but 'hci_uart_register_dev()' wasn't done. This leads to access > to uninitialized fields. To fix it let's set this bit after device was > registered (as before patch c411c62cc133) and to fix previous problem let's > add one more bit in addition to 'HCI_UART_PROTO_READY' which allows to > perform power up without original bit set (pls see commit c411c62cc133). > > [...] Here is the summary with links: - [RESEND,v1] Bluetooth: hci_uart: fix race during initialization https://git.kernel.org/bluetooth/bluetooth-next/c/e2040fe3b82b You are awesome, thank you!
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 2651e2e33f2a1..2f322f890b81f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -102,7 +102,8 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) if (!skb) { percpu_down_read(&hu->proto_lock); - if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) + if (test_bit(HCI_UART_PROTO_READY, &hu->flags) || + test_bit(HCI_UART_PROTO_INIT, &hu->flags)) skb = hu->proto->dequeue(hu); percpu_up_read(&hu->proto_lock); @@ -124,7 +125,8 @@ int hci_uart_tx_wakeup(struct hci_uart *hu) if (!percpu_down_read_trylock(&hu->proto_lock)) return 0; - if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags) && + !test_bit(HCI_UART_PROTO_INIT, &hu->flags)) goto no_schedule; set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); @@ -278,7 +280,8 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb) percpu_down_read(&hu->proto_lock); - if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags) && + !test_bit(HCI_UART_PROTO_INIT, &hu->flags)) { percpu_up_read(&hu->proto_lock); return -EUNATCH; } @@ -585,7 +588,8 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty) if (tty != hu->tty) return; - if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) + if (test_bit(HCI_UART_PROTO_READY, &hu->flags) || + test_bit(HCI_UART_PROTO_INIT, &hu->flags)) hci_uart_tx_wakeup(hu); } @@ -611,7 +615,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, percpu_down_read(&hu->proto_lock); - if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags) && + !test_bit(HCI_UART_PROTO_INIT, &hu->flags)) { percpu_up_read(&hu->proto_lock); return; } @@ -707,13 +712,16 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id) hu->proto = p; - set_bit(HCI_UART_PROTO_READY, &hu->flags); + set_bit(HCI_UART_PROTO_INIT, &hu->flags); err = hci_uart_register_dev(hu); if (err) { return err; } + set_bit(HCI_UART_PROTO_READY, &hu->flags); + clear_bit(HCI_UART_PROTO_INIT, &hu->flags); + return 0; } diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index fbf3079b92a53..5ea5dd80e297c 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -90,6 +90,7 @@ struct hci_uart { #define HCI_UART_REGISTERED 1 #define HCI_UART_PROTO_READY 2 #define HCI_UART_NO_SUSPEND_NOTIFIER 3 +#define HCI_UART_PROTO_INIT 4 /* TX states */ #define HCI_UART_SENDING 1