diff options
| author | Austin Clements <austin@google.com> | 2017-10-16 20:28:29 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2017-10-18 19:22:08 +0000 |
| commit | 193088b246f4bbe9a7d3a84ec7f4cc6786dac043 (patch) | |
| tree | 5798ac6c11085c6364b3af1120233b64a5c902da /src/runtime/sys_linux_s390x.s | |
| parent | 3ba818c894a1aa1e616a8531a1262d4f9d54f02a (diff) | |
| download | go-193088b246f4bbe9a7d3a84ec7f4cc6786dac043.tar.xz | |
runtime: separate error result for mmap
Currently mmap returns an unsafe.Pointer that encodes OS errors as
values less than 4096. In practice this is okay, but it borders on
being really unsafe: for example, the value has to be checked
immediately after return and if stack copying were ever to observe
such a value, it would panic. It's also not remotely idiomatic.
Fix this by making mmap return a separate pointer value and error,
like a normal Go function.
Updates #22218.
Change-Id: Iefd965095ffc82cc91118872753a5d39d785c3a6
Reviewed-on: https://go-review.googlesource.com/71270
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/sys_linux_s390x.s')
| -rw-r--r-- | src/runtime/sys_linux_s390x.s | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/runtime/sys_linux_s390x.s b/src/runtime/sys_linux_s390x.s index ed2077bfe4..72b024434f 100644 --- a/src/runtime/sys_linux_s390x.s +++ b/src/runtime/sys_linux_s390x.s @@ -251,7 +251,7 @@ TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 BR runtime·sigtramp(SB) // func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer -TEXT runtime·mmap(SB),NOSPLIT,$48-40 +TEXT runtime·mmap(SB),NOSPLIT,$48-48 MOVD addr+0(FP), R2 MOVD n+8(FP), R3 MOVW prot+16(FP), R4 @@ -272,9 +272,14 @@ TEXT runtime·mmap(SB),NOSPLIT,$48-40 MOVW $SYS_mmap, R1 SYSCALL MOVD $-4095, R3 - CMPUBLT R2, R3, 2(PC) + CMPUBLT R2, R3, ok NEG R2 - MOVD R2, ret+32(FP) + MOVD $0, p+32(FP) + MOVD R2, err+40(FP) + RET +ok: + MOVD R2, p+32(FP) + MOVD $0, err+40(FP) RET TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0 |
