runtime: avoid overflow in markrootBlock
runtime: avoid overflow in markrootBlock

In a position independent executable the data or BSS may be located
close to the end of memory. If it is placed closer than
rootBlockBytes, then the calculations in markrootBlock would overflow,
and the test that ensures that n is not larger than n0 would fail.
This would then cause scanblock to scan data that it shouldn't,
using an effectively random ptrmask, leading to program crashes.

No test because the only way to test it is to build a PIE and convince
the kernel to put the data section near the end of memory, and I don't
know how to do that. Or perhaps we could use a linker script, but that
is painful.

The new code is algebraically identical to the original code, but
avoids the potential overflow of b+rootBlockBytes.

Change-Id: Ieb4e5465174bb762b063d2491caeaa745017345e
Reviewed-on: https://go-review.googlesource.com/c/go/+/195717
Run-TryBot: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>

golang/go,akutz/go,akutz/go,golang/go,cloudflare/go,nawawi/go,nawawi/go,akutz/go,nawawi/go,cloudflare/go,nawawi/go,CAFxX/go,akutz/go,akutz/go,cloudflare/go,CAFxX/go,CAFxX/go,nawawi/go,CAFxX/go,golang/go,CAFxX/go,akutz/go,golang/go,CAFxX/go,nawawi/go,cloudflare/go,golang/go,nawawi/go,nawawi/go,golang/go,cloudflare/go,CAFxX/go,cloudflare/go,CAFxX/go,cloudflare/go,golang/go,cloudflare/go,akutz/go,golang/go,akutz/go