summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/host
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-09-25 18:40:00 +0000
committergVisor bot <gvisor-bot@google.com>2019-09-25 18:40:00 +0000
commitaaf327943e846d7d44a62b79deaacb212f2c8da0 (patch)
tree57a91479370df1c72dc71cf0cac84168fa39bacb /pkg/sentry/fs/host
parent1872bd8d377ea9874de440356662a70fd95e56fc (diff)
parent99c86b8dbdaaaba8724d9946d3137c5f9303d51e (diff)
Merge release-20190806.1-182-g99c86b8 (automated)
Diffstat (limited to 'pkg/sentry/fs/host')
-rwxr-xr-xpkg/sentry/fs/host/host_state_autogen.go2
-rw-r--r--pkg/sentry/fs/host/tty.go15
2 files changed, 14 insertions, 3 deletions
diff --git a/pkg/sentry/fs/host/host_state_autogen.go b/pkg/sentry/fs/host/host_state_autogen.go
index f0e1c4b88..e5c487320 100755
--- a/pkg/sentry/fs/host/host_state_autogen.go
+++ b/pkg/sentry/fs/host/host_state_autogen.go
@@ -117,6 +117,7 @@ func (x *TTYFileOperations) save(m state.Map) {
m.Save("fileOperations", &x.fileOperations)
m.Save("session", &x.session)
m.Save("fgProcessGroup", &x.fgProcessGroup)
+ m.Save("termios", &x.termios)
}
func (x *TTYFileOperations) afterLoad() {}
@@ -124,6 +125,7 @@ func (x *TTYFileOperations) load(m state.Map) {
m.Load("fileOperations", &x.fileOperations)
m.Load("session", &x.session)
m.Load("fgProcessGroup", &x.fgProcessGroup)
+ m.Load("termios", &x.termios)
}
func init() {
diff --git a/pkg/sentry/fs/host/tty.go b/pkg/sentry/fs/host/tty.go
index 2526412a4..90331e3b2 100644
--- a/pkg/sentry/fs/host/tty.go
+++ b/pkg/sentry/fs/host/tty.go
@@ -43,12 +43,15 @@ type TTYFileOperations struct {
// fgProcessGroup is the foreground process group that is currently
// connected to this TTY.
fgProcessGroup *kernel.ProcessGroup
+
+ termios linux.KernelTermios
}
// newTTYFile returns a new fs.File that wraps a TTY FD.
func newTTYFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags, iops *inodeOperations) *fs.File {
return fs.NewFile(ctx, dirent, flags, &TTYFileOperations{
fileOperations: fileOperations{iops: iops},
+ termios: linux.DefaultSlaveTermios,
})
}
@@ -97,9 +100,12 @@ func (t *TTYFileOperations) Write(ctx context.Context, file *fs.File, src userme
t.mu.Lock()
defer t.mu.Unlock()
- // Are we allowed to do the write?
- if err := t.checkChange(ctx, linux.SIGTTOU); err != nil {
- return 0, err
+ // Check whether TOSTOP is enabled. This corresponds to the check in
+ // drivers/tty/n_tty.c:n_tty_write().
+ if t.termios.LEnabled(linux.TOSTOP) {
+ if err := t.checkChange(ctx, linux.SIGTTOU); err != nil {
+ return 0, err
+ }
}
return t.fileOperations.Write(ctx, file, src, offset)
}
@@ -144,6 +150,9 @@ func (t *TTYFileOperations) Ioctl(ctx context.Context, _ *fs.File, io usermem.IO
return 0, err
}
err := ioctlSetTermios(fd, ioctl, &termios)
+ if err == nil {
+ t.termios.FromTermios(termios)
+ }
return 0, err
case linux.TIOCGPGRP: