Skip to content

Commit b36a155

Browse files
nefigtuttorvalds
authored andcommitted
Bluetooth: hci_uart: check for missing tty operations
Certain ttys operations (pty_unix98_ops) lack tiocmget() and tiocmset() functions which are called by the certain HCI UART protocols (hci_ath, hci_bcm, hci_intel, hci_mrvl, hci_qca) via hci_uart_set_flow_control() or directly. This leads to an execution at NULL and can be triggered by an unprivileged user. Fix this by adding a helper function and a check for the missing tty operations in the protocols code. This fixes CVE-2019-10207. The Fixes: lines list commits where calls to tiocm[gs]et() or hci_uart_set_flow_control() were added to the HCI UART protocols. Link: https://syzkaller.appspot.com/bug?id=1b42faa2848963564a5b1b7f8c837ea7b55ffa50 Reported-by: [email protected] Cc: [email protected] # v2.6.36+ Fixes: b3190df ("Bluetooth: Support for Atheros AR300x serial chip") Fixes: 118612f ("Bluetooth: hci_bcm: Add suspend/resume PM functions") Fixes: ff28955 ("Bluetooth: hci_intel: Add Intel baudrate configuration support") Fixes: 162f812 ("Bluetooth: hci_uart: Add Marvell support") Fixes: fa9ad87 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990") Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Reviewed-by: Yu-Chen, Cho <[email protected]> Tested-by: Yu-Chen, Cho <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1b7e816 commit b36a155

File tree

7 files changed

+29
-0
lines changed

7 files changed

+29
-0
lines changed

drivers/bluetooth/hci_ath.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ static int ath_open(struct hci_uart *hu)
9898

9999
BT_DBG("hu %p", hu);
100100

101+
if (!hci_uart_has_flow_control(hu))
102+
return -EOPNOTSUPP;
103+
101104
ath = kzalloc(sizeof(*ath), GFP_KERNEL);
102105
if (!ath)
103106
return -ENOMEM;

drivers/bluetooth/hci_bcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ static int bcm_open(struct hci_uart *hu)
406406

407407
bt_dev_dbg(hu->hdev, "hu %p", hu);
408408

409+
if (!hci_uart_has_flow_control(hu))
410+
return -EOPNOTSUPP;
411+
409412
bcm = kzalloc(sizeof(*bcm), GFP_KERNEL);
410413
if (!bcm)
411414
return -ENOMEM;

drivers/bluetooth/hci_intel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ static int intel_open(struct hci_uart *hu)
391391

392392
BT_DBG("hu %p", hu);
393393

394+
if (!hci_uart_has_flow_control(hu))
395+
return -EOPNOTSUPP;
396+
394397
intel = kzalloc(sizeof(*intel), GFP_KERNEL);
395398
if (!intel)
396399
return -ENOMEM;

drivers/bluetooth/hci_ldisc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,19 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
292292
return 0;
293293
}
294294

295+
/* Check the underlying device or tty has flow control support */
296+
bool hci_uart_has_flow_control(struct hci_uart *hu)
297+
{
298+
/* serdev nodes check if the needed operations are present */
299+
if (hu->serdev)
300+
return true;
301+
302+
if (hu->tty->driver->ops->tiocmget && hu->tty->driver->ops->tiocmset)
303+
return true;
304+
305+
return false;
306+
}
307+
295308
/* Flow control or un-flow control the device */
296309
void hci_uart_set_flow_control(struct hci_uart *hu, bool enable)
297310
{

drivers/bluetooth/hci_mrvl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ static int mrvl_open(struct hci_uart *hu)
5959

6060
BT_DBG("hu %p", hu);
6161

62+
if (!hci_uart_has_flow_control(hu))
63+
return -EOPNOTSUPP;
64+
6265
mrvl = kzalloc(sizeof(*mrvl), GFP_KERNEL);
6366
if (!mrvl)
6467
return -ENOMEM;

drivers/bluetooth/hci_qca.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ static int qca_open(struct hci_uart *hu)
473473

474474
BT_DBG("hu %p qca_open", hu);
475475

476+
if (!hci_uart_has_flow_control(hu))
477+
return -EOPNOTSUPP;
478+
476479
qca = kzalloc(sizeof(struct qca_data), GFP_KERNEL);
477480
if (!qca)
478481
return -ENOMEM;

drivers/bluetooth/hci_uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ int hci_uart_wait_until_sent(struct hci_uart *hu);
104104
int hci_uart_init_ready(struct hci_uart *hu);
105105
void hci_uart_init_work(struct work_struct *work);
106106
void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed);
107+
bool hci_uart_has_flow_control(struct hci_uart *hu);
107108
void hci_uart_set_flow_control(struct hci_uart *hu, bool enable);
108109
void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed,
109110
unsigned int oper_speed);

0 commit comments

Comments
 (0)