Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6705932imu; Wed, 30 Jan 2019 21:14:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN4OdQODVPbOp/hvPEh4EbUF/F1tU2obOZiLPoK3p39nC/BEmObNCYEiRE8n0r6wLTKMtK3t X-Received: by 2002:a63:83c1:: with SMTP id h184mr30038062pge.437.1548911659157; Wed, 30 Jan 2019 21:14:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548911659; cv=none; d=google.com; s=arc-20160816; b=yOuxQN6koRVkI56W3SsFL+tolmJTPM8PvtoRQuWjbT3Wsui6M14Xy23ZarJqH+vrIz ZjH5rud1tJ0c8dtlKAfM5GJR8opcgQQRW2PokKCPcqUQtc1Wq2g/EpqDQW5OfX2ZDX1e mmvBnptsVc0g3NxVaYFsU4/McBj3TLh/2i3kdNpCOPkuaVzcStBGEzszfFji8ofV57hA g5yrF/Gccn6IPG4mMA2nYYuE2l39e+Nvw7Fr/Y3anJ61WoUKGCZIztOnm3n5RorewwFe lzagkG6IvTYcxcrVEyXmyGI4kQTfp6UX6qLpKHFQOH99zCkWudxW7ghMqGnnWg4c6snS 11CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uGCyb3jEk8HZWIH52FnaNnYunQZQ/C84AsHyCYpT0Yo=; b=OImCKtv7LnYtxcTl+1h/Mi1nzdaU6fojlex8pNlfRq44T0/llETVw4xRoA4dNr/maR Ysk5ccLH0r2jIInTELQ6+BEExk2o1Wel08UJ19Z0CLVQknbg2UbTjVYT5JPgdwCA7zDm +g0oW5fKh+UpmdUqApZXjAIaVnwIBShJiFiZXW82HoXYqqIV1E5jxhuX32CegjQnx0b7 SfPCdl8g8otUSzFJPp1q9zTrL0lz3mvvyyZmldxlM6QNwWve1wm7g/VLqK+w/+559Qky pXzo9n5iRD8cc59aVUwnxS9Z/DFovT4T4VAr33Zs88mppKL563y3l47xcm5eVYJOQlCD n4Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PxKKrtON; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc17si3750390plb.265.2019.01.30.21.14.03; Wed, 30 Jan 2019 21:14:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PxKKrtON; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726172AbfAaFN5 (ORCPT + 99 others); Thu, 31 Jan 2019 00:13:57 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37572 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbfAaFN5 (ORCPT ); Thu, 31 Jan 2019 00:13:57 -0500 Received: by mail-pl1-f196.google.com with SMTP id b5so952948plr.4; Wed, 30 Jan 2019 21:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uGCyb3jEk8HZWIH52FnaNnYunQZQ/C84AsHyCYpT0Yo=; b=PxKKrtON4an60EfsUF4wXv5hX3l23d6iqObZTc9DvAoZCSECI+PUHObSXY97fLFaN/ 7aNCZ5hh1A7EwHWMHYWZc8NRjAPx68MKvSsiVeCKyynjR+IfwK2joKTR7Nt3MhCQe/uv rERJzPXH5erWYo+s1uFSYkFh1XD8Yek+go1WnlijTDlE034fHsZhhpotufzR+ptNYevj NdgGZd7xF4WSC/Es8nH63VVw22ufgtiY3dvZ8C76c8TyZEiBXV6ScTDpo6LzOQZZ6OQM qt5dSXq6PRFkfw71fw+vf0Z0Nwa+M42+fpxaox2eAsMv/mm/Re1ipoF7KyOHppH059gp f3Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uGCyb3jEk8HZWIH52FnaNnYunQZQ/C84AsHyCYpT0Yo=; b=TNxMG9XCDoUujyhWGKE4aeLT2Z7t5/o6pzCmAEOMyERWXejrzr8RmElNEeOa2vPmqy HyKsEOkf7kfnUmR/sqAOUxcDB3FSPdVNBBdBaSIlhbLleKxGXYXGGmiTRF8qxzysamyh Vq8DwYFO46m4/nEPyvWlbT3vIo8697+oEL1gz4qyqpn/uFvCtb8JHwO4EMfSIUixmBGQ jBDYGJ3sIWEBn9SsLPQeQAYvo2m6BxpAoqcf4H20M9SKwIaxyLB4uvNJbsX+eluXEy2H BhyDQnI93W7yElqHUskESXY9Uh2KreOgOKAoyFckGa6nS9Nts+7zI/KQO99QIscBtrvU HOsA== X-Gm-Message-State: AJcUukdixOdGSzwuqM9Ry/Ukts59bvHa10f94o1wjwkPTCSdcp4nYIaA KjPvnCW2g9hCs21t2XJQtXg= X-Received: by 2002:a17:902:8607:: with SMTP id f7mr32503360plo.123.1548911636414; Wed, 30 Jan 2019 21:13:56 -0800 (PST) Received: from myunghoj-Precision-5530 (cpe-76-176-3-80.san.res.rr.com. [76.176.3.80]) by smtp.gmail.com with ESMTPSA id x27sm8859067pfe.178.2019.01.30.21.13.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 21:13:56 -0800 (PST) Date: Wed, 30 Jan 2019 21:13:53 -0800 From: Myungho Jung To: Johan Hovold Cc: Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Bluetooth: hci_uart: Switch pty driver to slave side in tty_set_termios() Message-ID: <20190131051352.GB31677@myunghoj-Precision-5530> References: <20190128065259.GA2976@myunghoj-Precision-5530> <20190130100738.GQ3691@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190130100738.GQ3691@localhost> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 11:07:38AM +0100, Johan Hovold wrote: > On Sun, Jan 27, 2019 at 10:53:02PM -0800, Myungho Jung wrote: > > tty_set_termios() should be called with slave side of pty driver. So, If > > tty driver is pty master, it needs to be switched to ->link. > > I'm not sure that's the right solution. PTYs are virtual devices used > for IPC and neither end (master or slave) have support for modem > control or baud rates. > > > Reported-by: syzbot+a950165cbb86bdd023a4@syzkaller.appspotmail.com > > Signed-off-by: Myungho Jung > > --- > > drivers/bluetooth/hci_ldisc.c | 20 +++++++++++++++----- > > 1 file changed, 15 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c > > index fbf7b4df23ab..90c5ea8c399b 100644 > > --- a/drivers/bluetooth/hci_ldisc.c > > +++ b/drivers/bluetooth/hci_ldisc.c > > @@ -299,10 +299,18 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb) > > return 0; > > } > > > > +/* If driver is pty master, return slave side */ > > +static struct tty_struct *hci_uart_get_real_tty(struct tty_struct *tty) > > +{ > > + return (tty->driver->type == TTY_DRIVER_TYPE_PTY && > > + tty->driver->subtype == PTY_TYPE_MASTER) ? tty->link : tty; > > +} > > + > > /* Flow control or un-flow control the device */ > > void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) > > { > > struct tty_struct *tty = hu->tty; > > + struct tty_struct *real_tty; > > struct ktermios ktermios; > > int status; > > unsigned int set = 0; > > @@ -314,11 +322,12 @@ void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) > > return; > > } > > > > + real_tty = hci_uart_get_real_tty(tty); > > if (enable) { > > /* Disable hardware flow control */ > > - ktermios = tty->termios; > > + ktermios = real_tty->termios; > > ktermios.c_cflag &= ~CRTSCTS; > > - status = tty_set_termios(tty, &ktermios); > > + status = tty_set_termios(real_tty, &ktermios); > > BT_DBG("Disabling hardware flow control: %s", > > status ? "failed" : "success"); > > So instead of these pointless calls to set the slave termios and > modem-control state, you might as well bail out early above (and > similarly in set_baudrate()). > > Using n_hci for a master pty really makes no sense at all, so we could > even bail out at ldisc open, but perhaps that can be discussed and > addressed later. > > Johan Hi Johan, I fixed it to just return -EOPNOTSUPP if NULL in ath_setup(). Thanks, Myungho