Skip to contentSkip to conversation

Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO

PATCH In review Lee, Chun-Yi 2 participants 2 messages Jul 10, 2023 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO

This patch adds code to check HCI_UART_PROTO_READY flag before accessing hci_uart->proto. It fixs the race condition in hci_uart_tty_ioctl() between HCIUARTSETPROTO and HCIUARTGETPROTO. This issue bug found by Yu Hao and Weiteng Chen:

BUG: general protection fault in hci_uart_tty_ioctl

https://lore.kernel.org/all/CA+UBctC3p49aTgzbVgkSZ2+TQcqq4fPDO7yZitFT5uBPDeCO2g@mail.gmail.com/

The information of C reproducer can also reference here:
https://lore.kernel.org/lkml/CA+UBctDPEvHdkHMwD340=n02rh+jNRJNNQ5LBZNA+Wm4Keh2ow@mail.gmail.com/T/

---
 drivers/bluetooth/hci_ldisc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_ldisc.c +2 -1
index efdda2c3fce8..a76eb98c0047 100644
@@ -770,7 +770,8 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 		break;
 
 	case HCIUARTGETPROTO:
-		if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
+		if (test_bit(HCI_UART_PROTO_SET, &hu->flags) &&
+		    test_bit(HCI_UART_PROTO_READY, &hu->flags))
 			err = hu->proto->id;
 		else
 			err = -EUNATCH;
Signature · 1 line
2.35.3
#1 lore raw

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=763894

---Test result---

Test Summary:

CheckPatch                    FAIL      0.82 seconds
GitLint                       FAIL      0.52 seconds
SubjectPrefix                 PASS      0.08 seconds
BuildKernel                   PASS      32.42 seconds
CheckAllWarning               PASS      35.37 seconds
CheckSparse                   PASS      39.97 seconds
CheckSmatch                   PASS      111.21 seconds
BuildKernel32                 PASS      30.96 seconds
TestRunnerSetup               PASS      472.90 seconds
TestRunner_l2cap-tester       PASS      22.50 seconds
TestRunner_iso-tester         PASS      40.91 seconds
TestRunner_bnep-tester        PASS      10.39 seconds
TestRunner_mgmt-tester        PASS      211.46 seconds
TestRunner_rfcomm-tester      PASS      15.46 seconds
TestRunner_sco-tester         PASS      16.31 seconds
TestRunner_ioctl-tester       PASS      17.21 seconds
TestRunner_mesh-tester        PASS      12.78 seconds
TestRunner_smp-tester         PASS      13.88 seconds
TestRunner_userchan-tester    PASS      10.72 seconds
IncrementalBuild              PASS      29.83 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO
WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line) #88:
https://lore.kernel.org/lkml/CA+UBctDPEvHdkHMwD340=n02rh+jNRJNNQ5LBZNA+Wm4Keh2ow@mail.gmail.com/T/

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #90:

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report #91:

WARNING: From:/Signed-off-by: email address mismatch: 'From: "Lee, Chun-Yi" <[email protected]>' != 'Signed-off-by: "Lee, Chun-Yi" <[email protected]>'

total: 0 errors, 4 warnings, 9 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/src/13306348.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.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
9: B1 Line exceeds max length (95>80): "https://lore.kernel.org/all/CA+UBctC3p49aTgzbVgkSZ2+TQcqq4fPDO7yZitFT5uBPDeCO2g@mail.gmail.com/"
12: B1 Line exceeds max length (98>80): "https://lore.kernel.org/lkml/CA+UBctDPEvHdkHMwD340=n02rh+jNRJNNQ5LBZNA+Wm4Keh2ow@mail.gmail.com/T/"

---
Regards,
Linux Bluetooth