summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/tty/line_discipline.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2020-01-17 11:20:29 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-17 11:22:10 -0800
commit80d0f9304484897e4307c9701ddbfaacb925715d (patch)
treeb9f80fe992b37209c5bc07367a64e1fa92a259bb /pkg/sentry/fs/tty/line_discipline.go
parent8e8d0f96f651ce161dfe6003d738dbda28f7cb0e (diff)
Fix data race in tty.queue.readableSize.
We were setting queue.readable without holding the lock. PiperOrigin-RevId: 290306922
Diffstat (limited to 'pkg/sentry/fs/tty/line_discipline.go')
-rw-r--r--pkg/sentry/fs/tty/line_discipline.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/sentry/fs/tty/line_discipline.go b/pkg/sentry/fs/tty/line_discipline.go
index 894964260..9fe02657e 100644
--- a/pkg/sentry/fs/tty/line_discipline.go
+++ b/pkg/sentry/fs/tty/line_discipline.go
@@ -140,8 +140,10 @@ func (l *lineDiscipline) setTermios(ctx context.Context, io usermem.IO, args arc
// buffer to its read buffer. Anything already in the read buffer is
// now readable.
if oldCanonEnabled && !l.termios.LEnabled(linux.ICANON) {
- l.inQueue.pushWaitBuf(l)
+ l.inQueue.mu.Lock()
+ l.inQueue.pushWaitBufLocked(l)
l.inQueue.readable = true
+ l.inQueue.mu.Unlock()
l.slaveWaiter.Notify(waiter.EventIn)
}