]> Cypherpunks repositories - gostls13.git/commit
runtime: avoid overflow from linearAlloc
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 30 Apr 2020 19:35:12 +0000 (19:35 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 7 May 2020 21:40:09 +0000 (21:40 +0000)
commit2e455ec2eb447a65f10b3dc929833f6aa19d526e
tree7379652b18ad4d67b9750dee4372445581752f78
parent14ae846f54c105f4d48f1afa5aa5446e4b9e7cdc
runtime: avoid overflow from linearAlloc

Currently linearAlloc manages an exclusive "end" address for the top of
its reserved space. While unlikely for a linearAlloc to be allocated
with an "end" address hitting the top of the address space, it is
possible and could lead to overflow.

Avoid overflow by chopping off the last byte from the linearAlloc if
it's bumping up against the top of the address space defensively. In
practice, this means that if 32-bit platforms map the top of the address
space and use the linearAlloc to acquire arenas, the top arena will not
be usable.

Fixes #35954.

Change-Id: I512cddcd34fd1ab15cb6ca92bbf899fc1ef22ff6
Reviewed-on: https://go-review.googlesource.com/c/go/+/231338
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/malloc.go