]> Cypherpunks repositories - gostls13.git/commit
runtime: ensure that searchAddr always refers to inUse memory
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 28 Jan 2020 19:59:19 +0000 (19:59 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 28 Jan 2020 22:08:43 +0000 (22:08 +0000)
commite7f9e17b7927cad7a93c5785e864799e8d9b4381
tree063cb55d984d173adc88b115578b9663d1703d31
parentb13ce14c4a6aa59b7b041ad2b6eed2d23e15b574
runtime: ensure that searchAddr always refers to inUse memory

This change formalizes an assumption made by the page allocator, which
is that (*pageAlloc).searchAddr should never refer to memory that is not
represented by (*pageAlloc).inUse. The portion of address space covered
by (*pageAlloc).inUse reflects the parts of the summary arrays which are
guaranteed to mapped, and so looking at any summary which is not
reflected there may cause a segfault.

In fact, this can happen today. This change thus also removes a
micro-optimization which is the only case which may cause
(*pageAlloc).searchAddr to point outside of any region covered by
(*pageAlloc).inUse, and adds a test verifying that the current segfault
can no longer occur.

Change-Id: I98b534f0ffba8656d3bd6d782f6fc22549ddf1c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/216697
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/export_test.go
src/runtime/mpagealloc.go
src/runtime/mpagealloc_test.go
src/runtime/mpallocbits.go