From d6dbe6e5ca5445dac278d3b6654af8d13379878a Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Tue, 9 Feb 2021 01:32:55 -0800 Subject: pipe: writeLocked has to return ErrWouldBlock if the pipe is full PiperOrigin-RevId: 356450303 --- pkg/sentry/kernel/pipe/pipe.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/sentry/kernel/pipe') diff --git a/pkg/sentry/kernel/pipe/pipe.go b/pkg/sentry/kernel/pipe/pipe.go index c551acd99..2c8668fc4 100644 --- a/pkg/sentry/kernel/pipe/pipe.go +++ b/pkg/sentry/kernel/pipe/pipe.go @@ -247,11 +247,15 @@ func (p *Pipe) writeLocked(count int64, f func(safemem.BlockSeq) (uint64, error) return 0, syscall.EPIPE } - // POSIX requires that a write smaller than atomicIOBytes (PIPE_BUF) be - // atomic, but requires no atomicity for writes larger than this. avail := p.max - p.size + if avail == 0 { + return 0, syserror.ErrWouldBlock + } short := false if count > avail { + // POSIX requires that a write smaller than atomicIOBytes + // (PIPE_BUF) be atomic, but requires no atomicity for writes + // larger than this. if count <= atomicIOBytes { return 0, syserror.ErrWouldBlock } -- cgit v1.2.3