Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3401670imu; Mon, 28 Jan 2019 04:19:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7PUAMvcl7hBOX9k42hGpQY0Lv2JoO4Ot0B7FzIq7nvG5ngwpQQplOe93Hv3Z0OitaHkdAa X-Received: by 2002:a62:5003:: with SMTP id e3mr22369776pfb.23.1548677960869; Mon, 28 Jan 2019 04:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548677960; cv=none; d=google.com; s=arc-20160816; b=xQ3PjqbYaEv82U386T34SeqtjpvbgdhFEUzl/gYQ29xXO9g43pmF/zf9dRpNeK6+LW inEkNGhhXOEwgnxY3j3+AZ9C6IwV/rk5dpY79605WRLdMDG+itwNmd+1cqO55PZpuW4A g2fhexRIkVFygr9CL+GXYkOjFnHevIcUOuP/6nKkg02U2oYY/qRXYWG+EdzmAF97/+xl yBEGHpJ/CFp/sWW6SZaCLUbD7QfjbzprhGhoVTLk3teBO6iCNEAUSyscPdsUSkx7jkng y4l9oRStYZ2y/Scw3b4HtHBjnPC66Ke3B15FihOgclnXpdEodlle1hn1q1M8YbhHNT04 gEiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=SsTMAAMsDXFmT14dNlosjsHNLSjAvUL7TTwJoIGMBOE=; b=OhVNBi675zfBWDYr6Zd/b6teNPIqDQyqP22kmoNSJxdaBEjZ1iTI8KYnzxr541/R4o WgRutG2tH2B6BiakF9uklje1kMaYpb3rfS0zZsq/o00UIOUoPtpYZ5QQF3dUEikXyTJ7 MEiuFV92JtGxkEc0R1jKhMxm1exPGLH2V76ghoePlPcrFvr7gT0GkBz8PR7WWtzQ1UuA w3lu9s+dK8+kmG67tGORmEB2AXTQGbVIxQaLP9i9AdSuQwiA9joqS1iWFV5DWheY8/7c AHx+0m4RVi/8k2ehrL+eZkVZY8V6i+Yebo1by6H4+ywRaDTBPEcDsKzJLWW4pwj6qopc SDtw== ARC-Authentication-Results: i=1; mx.google.com; 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 123si33222926pfx.109.2019.01.28.04.19.04; Mon, 28 Jan 2019 04:19:20 -0800 (PST) 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; 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 S1726879AbfA1MQp convert rfc822-to-8bit (ORCPT + 99 others); Mon, 28 Jan 2019 07:16:45 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:57437 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfA1MQo (ORCPT ); Mon, 28 Jan 2019 07:16:44 -0500 Received: from marcel-macpro.fritz.box (p4FF9FD60.dip0.t-ipconnect.de [79.249.253.96]) by mail.holtmann.org (Postfix) with ESMTPSA id EB9C2CF2B6; Mon, 28 Jan 2019 13:24:30 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] Bluetooth: Add NULL check for tiocmget() and tiocmset() From: Marcel Holtmann In-Reply-To: <20190128065910.GA14959@myunghoj-Precision-5530> Date: Mon, 28 Jan 2019 13:16:42 +0100 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <0D7C928B-8E3E-4986-A6D2-AFCFF4F0E274@holtmann.org> References: <20190128065910.GA14959@myunghoj-Precision-5530> To: Myungho Jung X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Myungho, > tiocmget() and tiocmset() operations are optional and some tty drivers > like pty miss the operations. We need NULL check before referencing > them. > > Reported-by: syzbot+a950165cbb86bdd023a4@syzkaller.appspotmail.com > Signed-off-by: Myungho Jung > --- > drivers/bluetooth/hci_ath.c | 13 ++++++++----- > drivers/bluetooth/hci_ldisc.c | 5 +++++ > 2 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c > index d568fbd94d6c..076700a1e9a8 100644 > --- a/drivers/bluetooth/hci_ath.c > +++ b/drivers/bluetooth/hci_ath.c > @@ -94,11 +94,14 @@ static void ath_hci_uart_work(struct work_struct *work) > hu = ath->hu; > tty = hu->tty; > > - /* verify and wake up controller */ > - if (ath->cur_sleep) { > - status = ath_wakeup_ar3k(tty); > - if (!(status & TIOCM_CTS)) > - return; > + /* tiocmget() and tiocmset() operations are optional */ > + if (tty->driver->ops->tiocmget && tty->driver->ops->tiocmset) { > + /* verify and wake up controller */ > + if (ath->cur_sleep) { > + status = ath_wakeup_ar3k(tty); > + if (!(status & TIOCM_CTS)) > + return; > + } > } actually in case of hci_ath.c I would prefer that the setup actually fails. There is no point in continuing here. These are vendor specific hardware routines and you will not run them over TTYs that don’t support it. So instead of ignoring the operating, fail hard and cleanly during setup. > /* Ready to send Data */ > diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c > index fbf7b4df23ab..9f88a8563cf6 100644 > --- a/drivers/bluetooth/hci_ldisc.c > +++ b/drivers/bluetooth/hci_ldisc.c > @@ -314,6 +314,11 @@ void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) > return; > } > > + /* tiocmget() and tiocmset() operations are optional */ > + if (!tty->driver->ops->tiocmget || !tty->driver->ops->tiocmset) { > + return; > + } > + No { } here please. > if (enable) { > /* Disable hardware flow control */ > ktermios = tty->termios; Regards Marcel