]> Cypherpunks repositories - gostls13.git/commit
runtime: properly compute whether PC is inside vDSO pages
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 25 Sep 2024 23:14:18 +0000 (01:14 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 26 Sep 2024 16:51:09 +0000 (16:51 +0000)
commitba42120723a8bb4161c4f54c93f7ab3234923473
tree70410398bdec8348dc26b3c195c55cb6ffa884d9
parent4aa5aa63c94976009c0ae747ca04d9268272c773
runtime: properly compute whether PC is inside vDSO pages

The old calculation just looked whether PC was within a page of a vDSO
symbol. This doesn't work because the vDSO .text might span two whole
pages, with trampolines and such redirecting PC around between them.

This manifests itself with the new vDSO getrandom() function, where on
PowerPC, the trampoline is quite far away from the actual C function it
jumps into. The effect is that the signal handler doesn't know it's
interrupting a vDSO call and forgets to restore g to R30, resulting in a
crash.

Fix this by storing the start and end of the LOAD section from the
program headers. We could be more specific and parse out the .text
section, but PT_LOAD is good enough and appears to work well.

Change-Id: I3cf16955177eedb51e28b3b1a0191b32c3327a42
Reviewed-on: https://go-review.googlesource.com/c/go/+/616015
Auto-Submit: Jason Donenfeld <Jason@zx2c4.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/runtime/vdso_linux.go