]> Cypherpunks repositories - gostls13.git/commit
syscall: use CLONE_VFORK safely
authorAustin Clements <austin@google.com>
Tue, 20 Jun 2017 19:12:12 +0000 (15:12 -0400)
committerAustin Clements <austin@google.com>
Tue, 20 Jun 2017 19:55:45 +0000 (19:55 +0000)
commit67e537541c043c701001f002bed0cda70ce72767
treeabd25ba42c2cc7d69e8708bfcd7f0c99415b172f
parent5a5ac34133f31eedf39e0cc6bef06085190317d2
syscall: use CLONE_VFORK safely

Currently, CLONE_VFORK is used without much regard to the stack. This
is dangerous, because anything the child does to the stack is visible
to the parent. For example, if the compiler were to reuse named stack
slots (which it currently doesn't do), it would be easy for the child
running in the same stack frame as the parent to corrupt local
variables that the parent then depended on. We're not sure of anything
specific going wrong in this code right now, but it is at best a
ticking time bomb.

CLONE_VFORK can only safely be used if we ensure the child does not
execute in any of the active stack frames of the parent. This commit
implements this by arranging for the parent to return immediately from
the frame the child will operate in, and for the child to never return
to the frame the parent will operate in.

Fixes #20732.

Change-Id: Iad5b4ddc2b994c082bd278bfd52ef53bd38c037f
Reviewed-on: https://go-review.googlesource.com/46173
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/syscall/exec_linux.go