Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1003763imu; Fri, 11 Jan 2019 13:06:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7IIOMoedGIG+N+hdgPZ1N1sHAFoDBD2YCsBZ83AJadfP8SYXrr1Gom1ykrkNenY7oKwA+h X-Received: by 2002:a17:902:2:: with SMTP id 2mr16563518pla.228.1547240785177; Fri, 11 Jan 2019 13:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547240785; cv=none; d=google.com; s=arc-20160816; b=vOFvWYnV/9TuSyi0NzxMVlzu3MGOunyb0SRPHwQAyjxsh0eG42oY0+Nmt/4M/j19Sv MhAIx/q8lrKvdFvWgcTD/4V1JwhtZ+nHalvLyIwbuQIUnfZchMn7MEnFZVw+rul+ypRK 4h3qVsuZrz9IW2jIJ6C91Phtvnv/2yf1sKt0Z47XrnEhce8Lr9m72SgHkS6niV9ZS0dA UIoCmY5EnVXSYa8LqJV3HIXZ2AxApz3vtqETDDVn49znLUsgTTELtHGbItbZPSsBSPAB ZK8PU9bl1z1xyF+8ubfqwbTnYxcTB8L0IbsPBMY7eVriNyHofowqB6cs3FYqOmz1vYDL jl9Q== 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=LIE0DJQvffwm/jEwEsd87Z+HpoxrshSbVUUVsDxFBA4=; b=BGOj9PlGACLj+s45sKyXgDvvllrUrb5jdkuvgDkdCSTwssWKxA4SKl45+bcUb5um51 1PNBjVwNoStZ+O8ohHFuX4lKK5iGvkXeEcawR5VhgOkvnBzVeNbdrppVQVXZ855YIywQ +eopnkfWIPUmTvd2coyYht8N3mWockqekGArBzf/MBzW01iZtee5dVPXSRkHN+PlFAUI Y2FYF7ZJTcjZCeih99is0BFGCMIcXKTnHGtL1FAmN6qNYf05yf1YpOF0jv1hVBltAmsw TYTV+TSoSJTz0U7t/mhDzo6DUrdBxlpN9lx54i0yR4QXEYf0ugf3hrcB+m/9ifXL5O/5 KuqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PyPsXlSj; 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 a9si9159702plp.323.2019.01.11.13.06.09; Fri, 11 Jan 2019 13:06:25 -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=@kernel.org header.s=default header.b=PyPsXlSj; 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 S2388643AbfAKTdH (ORCPT + 99 others); Fri, 11 Jan 2019 14:33:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:33598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388593AbfAKTdC (ORCPT ); Fri, 11 Jan 2019 14:33:02 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 4468C218C3; Fri, 11 Jan 2019 19:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547235181; bh=WsNfx33BzIsjnY5yiFog9pEDVAqaiJ1DB5eYd1qgUdA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PyPsXlSjGuj6393JasHvCtv+SI2rh3+81KfdhlJVXQ0QJeOF6bDlJ1r+4NoHKvAUJ eHJmPlkfyBmxMfprhj3nms5+fYXNRHuEkDMV64ScGKSd5KRN/RyOo1mr0H5wL9D2Zk rp3OnGi9Dv9gA7/68wcqngVaXRL6EFIZKgXwwGIE= Date: Fri, 11 Jan 2019 20:32:59 +0100 From: Greg Kroah-Hartman To: Nicolas Pitre Cc: Dmitry Safonov , Jiri Slaby , Mark Rutland , Tetsuo Handa , Tycho Andersen , Dave Mielke , linux-kernel@vger.kernel.org Subject: Re: commit 83d817f410 broke my ability to use Linux with a braille display Message-ID: <20190111193259.GA14966@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 01:33:09PM -0500, Nicolas Pitre wrote: > I use Linux with the help of a braille display and the brltty daemon. It > turns out that the latest mainline kernel I can work with comes from > commit 231f8fd0cc. Anything past that and I lose the ability to read the > console barely a few seconds after the system has booted as brltty is > thrown a wrench and the braille display becomes completely inoperable. > > Things get somewhat better with commit c96cf923a9 as brltty is not > longer incapacitated, but some programs would randomly crash. Even the > very first login attempt won't work as I soon as I hit enter after my > user name the password prompt is skipped over, just like if the enter > key had been hit twice. Then lynx (the text web browser) would crash as > soon as I switch the virtual console with LeftAlt+FN. Mind you, this > isn't easy to perform bisection in those conditions. > > And the worst commit i.e. 83d817f410 is marked for stable! :-( > > Some interaction with brltty must be at play here otherwise such > breakage would never have survived up to the mainline kernel. > > As far as latest mainline is concerned, I managed to reproduce at least > one of the unwelcome behavior change (hoping that's all there is to this > issue) with a very simple test case so you won't have to learn braille > to debug this: > > # from any vt, make sure tty40 is allocated and empty > openvt -c 40 -f -- true > > # open it and wait on read() > cat /dev/tty40 > > # from a second vt, simply open tty40 again > true < /dev/tty40 > > # come back to the first vt and watch cat bailing out with EAGAIN. > > Please fix. Please try the patch below, it was just queued up to my tree and should resolve the issue. If not, please let us know. thanks, greg k-h From d3736d82e8169768218ee0ef68718875918091a0 Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Wed, 9 Jan 2019 01:17:40 +0000 Subject: tty: Don't hold ldisc lock in tty_reopen() if ldisc present Try to get reference for ldisc during tty_reopen(). If ldisc present, we don't need to do tty_ldisc_reinit() and lock the write side for line discipline semaphore. Effectively, it optimizes fast-path for tty_reopen(), but more importantly it won't interrupt ongoing IO on the tty as no ldisc change is needed. Fixes user-visible issue when tty_reopen() interrupted login process for user with a long password, observed and reported by Lukas. Fixes: c96cf923a98d ("tty: Don't block on IO when ldisc change is pending") Fixes: 83d817f41070 ("tty: Hold tty_ldisc_lock() during tty_reopen()") Cc: Jiri Slaby Reported-by: Lukas F. Hartmann Tested-by: Lukas F. Hartmann Cc: stable Signed-off-by: Dmitry Safonov Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_io.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index bfe9ad85b362..23c6fd238422 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1256,7 +1256,8 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct * static int tty_reopen(struct tty_struct *tty) { struct tty_driver *driver = tty->driver; - int retval; + struct tty_ldisc *ld; + int retval = 0; if (driver->type == TTY_DRIVER_TYPE_PTY && driver->subtype == PTY_TYPE_MASTER) @@ -1268,13 +1269,18 @@ static int tty_reopen(struct tty_struct *tty) if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) return -EBUSY; - retval = tty_ldisc_lock(tty, 5 * HZ); - if (retval) - return retval; + ld = tty_ldisc_ref_wait(tty); + if (ld) { + tty_ldisc_deref(ld); + } else { + retval = tty_ldisc_lock(tty, 5 * HZ); + if (retval) + return retval; - if (!tty->ldisc) - retval = tty_ldisc_reinit(tty, tty->termios.c_line); - tty_ldisc_unlock(tty); + if (!tty->ldisc) + retval = tty_ldisc_reinit(tty, tty->termios.c_line); + tty_ldisc_unlock(tty); + } if (retval == 0) tty->count++; -- 2.20.1