From: Tzu-Chiao Yeh Date: Wed, 2 Sep 2020 02:53:39 +0000 (+0800) Subject: net/http/fcgi: fix race in child.serve connection read X-Git-Tag: go1.16beta1~1141 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7432bee7b372efbbd09b16c4e3176b69fbb6878a;p=gostls13.git net/http/fcgi: fix race in child.serve connection read Guards the connection read with a mutex, because typeStdin asynchronously and concurrently writes to the underlying conn. Fixes #41167 Change-Id: Ia2610f4fde0bd4b108c54164095ea293980b0301 Reviewed-on: https://go-review.googlesource.com/c/go/+/252417 Run-TryBot: Emmanuel Odeke TryBot-Result: Gobot Gobot Reviewed-by: Emmanuel Odeke --- diff --git a/src/net/http/fcgi/child.go b/src/net/http/fcgi/child.go index 30a6b2ce2d..0e91042543 100644 --- a/src/net/http/fcgi/child.go +++ b/src/net/http/fcgi/child.go @@ -155,9 +155,12 @@ func (c *child) serve() { defer c.cleanUp() var rec record for { + c.conn.mutex.Lock() if err := rec.read(c.conn.rwc); err != nil { + c.conn.mutex.Unlock() return } + c.conn.mutex.Unlock() if err := c.handleRecord(&rec); err != nil { return }