From owner-dev-commits-src-all@freebsd.org Tue May 18 18:05:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC6406531FF; Tue, 18 May 2021 18:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fl3nP5y91z3r55; Tue, 18 May 2021 18:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4A6C23E27; Tue, 18 May 2021 18:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14II5DoA017577; Tue, 18 May 2021 18:05:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14II5DTG017576; Tue, 18 May 2021 18:05:13 GMT (envelope-from git) Date: Tue, 18 May 2021 18:05:13 GMT Message-Id: <202105181805.14II5DTG017576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8cf912b017a0 - main - ttydev_write: prevent stops while terminal is busied MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8cf912b017a04a2eec01fbaa1f7b9ef556403ede Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 18:05:13 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf912b017a04a2eec01fbaa1f7b9ef556403ede commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede Author: Konstantin Belousov AuthorDate: 2021-05-13 01:35:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-18 17:52:03 +0000 ttydev_write: prevent stops while terminal is busied Since busy state is checked by all blocked writes, stopping a process which waits in ttydisc_write() causes cascade. Utilize sigdeferstop() to avoid the issue. Submitted by: Jakub Piecuch PR: 255816 MFC after: 1 week --- sys/kern/tty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 00b4df675311..8700eb8f9ef1 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -525,7 +525,7 @@ static int ttydev_write(struct cdev *dev, struct uio *uio, int ioflag) { struct tty *tp = dev->si_drv1; - int error; + int defer, error; error = ttydev_enter(tp); if (error) @@ -549,7 +549,9 @@ ttydev_write(struct cdev *dev, struct uio *uio, int ioflag) } tp->t_flags |= TF_BUSY_OUT; + defer = sigdeferstop(SIGDEFERSTOP_ERESTART); error = ttydisc_write(tp, uio, ioflag); + sigallowstop(defer); tp->t_flags &= ~TF_BUSY_OUT; cv_signal(&tp->t_outserwait); }