git: 8cf912b017a0 - main - ttydev_write: prevent stops while terminal is busied

Konstantin Belousov kib at FreeBSD.org
Tue May 18 18:05:13 UTC 2021


The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8cf912b017a04a2eec01fbaa1f7b9ef556403ede

commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede
Author:     Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-05-13 01:35:06 +0000
Commit:     Konstantin Belousov <kib at FreeBSD.org>
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 <j.piecuch96 at gmail.com>
    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);
 	}


More information about the dev-commits-src-all mailing list