Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1266288ybi; Fri, 2 Aug 2019 12:16:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBf/1ifhzQXbRo/6PAui55a7JsWA9cbxaCaJ1wr7FD6U5nKCdXxcZ4vTJY5Fpir5+euFHm X-Received: by 2002:aa7:8705:: with SMTP id b5mr8687601pfo.27.1564773376793; Fri, 02 Aug 2019 12:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564773376; cv=none; d=google.com; s=arc-20160816; b=ZwPUJs1IXr+pvEoTbD4Oge4OoqwDvtR85x3rd7Ta0XISXIusOFunJnAcXEThHP740/ zSwufhVcE7EPSfjdzqj1nThgWe0HtQT0i87Gk3B0e32+HVxELN6zoWc/uv0R35NQriK7 IrXFuT8ZHLaMHkasVM0dAcf7HOhtv4UTgQtiAtljPqXwwjMMbpH6MyCTSeoshrsdsOhz EO6VAEhwJEm1BRI77YLTcvgHQw01ywWeUB4ktJV2eL1Ikl7rx8/fEz1tTNfrtsiVPd/a +prVA9OuQ7aSrnIAOb89Qpyg9Lizp/xETaLbRxl6Uj1SLWDH9oIrL/YUP4R8nmvMh36k gtXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oO83gEciOjisEssW8F+dl7W8FWCB+lm6Nza08JZ5fZU=; b=koyyRDYuFUsboT4WMfhJD8Mgw2Rd3shjMe8pGaTzmvLJdbRkp2VpLl8zasquruw1qN GycBJeO3ZANd4+AtMpqCYn6FwEaE8zJet/qsecQXDgtZ0lvPqPzwiJsXr8ZUxT6soj2o OS6DmbQO3BZfcvNj8mZJcGtDjpX3dyqiXDhGWF12JrIYBeROmVCd457JSIWW+yt06ogq xb7fROtkP+pzODEhfwo0C/eULDS29aut8+VZZGeRBieYBNj8HNCe1WH/Vz/zHcnJQRIK Q2I9K2vfZki8DIgS6nujHxdvCVybxNY5jHx6WjGc4M0291TtNFbyLdsZqAhNkULsR5CR 3O7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2MbfF/er"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si6855840pgj.498.2019.08.02.12.16.01; Fri, 02 Aug 2019 12:16:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2MbfF/er"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406377AbfHBJ4b (ORCPT + 99 others); Fri, 2 Aug 2019 05:56:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:35316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404798AbfHBJ43 (ORCPT ); Fri, 2 Aug 2019 05:56:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9927020665; Fri, 2 Aug 2019 09:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739788; bh=JSb30u6ZZcU6mTVsvJ37BEW+XfA9T4IV9PfS53PeFsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2MbfF/er/8bXqsiVxyQWg663Y+wiRnv5HjH7Ac3e9FB+tD/TC+04ZvVVurTx7pL1A +tkWTnInv/t+NblgWAJAuiiKtq5ruJEyqFWBjG4ZdNT8eDv5ctXqm4Sj+pAZIrN3YO 1BWjdzDfn5ofP0JQZkqEp9jhjbHTbTWL5poeiR9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+79337b501d6aa974d0f6@syzkaller.appspotmail.com, Vladis Dronov , Marcel Holtmann , "Yu-Chen, Cho" , Linus Torvalds Subject: [PATCH 4.9 220/223] Bluetooth: hci_uart: check for missing tty operations Date: Fri, 2 Aug 2019 11:37:25 +0200 Message-Id: <20190802092250.874085831@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladis Dronov commit b36a1552d7319bbfd5cf7f08726c23c5c66d4f73 upstream. 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: syzbot+79337b501d6aa974d0f6@syzkaller.appspotmail.com Cc: stable@vger.kernel.org # v2.6.36+ Fixes: b3190df62861 ("Bluetooth: Support for Atheros AR300x serial chip") Fixes: 118612fb9165 ("Bluetooth: hci_bcm: Add suspend/resume PM functions") Fixes: ff2895592f0f ("Bluetooth: hci_intel: Add Intel baudrate configuration support") Fixes: 162f812f23ba ("Bluetooth: hci_uart: Add Marvell support") Fixes: fa9ad876b8e0 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990") Signed-off-by: Vladis Dronov Signed-off-by: Marcel Holtmann Reviewed-by: Yu-Chen, Cho Tested-by: Yu-Chen, Cho Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_ath.c | 3 +++ drivers/bluetooth/hci_bcm.c | 3 +++ drivers/bluetooth/hci_intel.c | 3 +++ drivers/bluetooth/hci_ldisc.c | 9 +++++++++ drivers/bluetooth/hci_mrvl.c | 3 +++ drivers/bluetooth/hci_uart.h | 1 + 6 files changed, 22 insertions(+) --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -101,6 +101,9 @@ static int ath_open(struct hci_uart *hu) BT_DBG("hu %p", hu); + if (!hci_uart_has_flow_control(hu)) + return -EOPNOTSUPP; + ath = kzalloc(sizeof(*ath), GFP_KERNEL); if (!ath) return -ENOMEM; --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -279,6 +279,9 @@ static int bcm_open(struct hci_uart *hu) bt_dev_dbg(hu->hdev, "hu %p", hu); + if (!hci_uart_has_flow_control(hu)) + return -EOPNOTSUPP; + bcm = kzalloc(sizeof(*bcm), GFP_KERNEL); if (!bcm) return -ENOMEM; --- a/drivers/bluetooth/hci_intel.c +++ b/drivers/bluetooth/hci_intel.c @@ -407,6 +407,9 @@ static int intel_open(struct hci_uart *h BT_DBG("hu %p", hu); + if (!hci_uart_has_flow_control(hu)) + return -EOPNOTSUPP; + intel = kzalloc(sizeof(*intel), GFP_KERNEL); if (!intel) return -ENOMEM; --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -263,6 +263,15 @@ static int hci_uart_send_frame(struct hc return 0; } +/* Check the underlying device or tty has flow control support */ +bool hci_uart_has_flow_control(struct hci_uart *hu) +{ + if (hu->tty->driver->ops->tiocmget && hu->tty->driver->ops->tiocmset) + return true; + + return false; +} + /* Flow control or un-flow control the device */ void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) { --- a/drivers/bluetooth/hci_mrvl.c +++ b/drivers/bluetooth/hci_mrvl.c @@ -66,6 +66,9 @@ static int mrvl_open(struct hci_uart *hu BT_DBG("hu %p", hu); + if (!hci_uart_has_flow_control(hu)) + return -EOPNOTSUPP; + mrvl = kzalloc(sizeof(*mrvl), GFP_KERNEL); if (!mrvl) return -ENOMEM; --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -109,6 +109,7 @@ int hci_uart_tx_wakeup(struct hci_uart * int hci_uart_init_ready(struct hci_uart *hu); void hci_uart_init_tty(struct hci_uart *hu); void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed); +bool hci_uart_has_flow_control(struct hci_uart *hu); void hci_uart_set_flow_control(struct hci_uart *hu, bool enable); void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed, unsigned int oper_speed);