aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_s390x.s
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-09-06 17:21:59 -0700
committerIan Lance Taylor <iant@golang.org>2018-09-07 22:50:28 +0000
commit43f54c8d2e3bddfc6ad7887286eb6564986cb6ad (patch)
tree4883ebc958846178fbcf544e44d22a6599b42be6 /src/runtime/sys_linux_s390x.s
parentceb7745cc846f798531ef019162dd9f1dabfea12 (diff)
downloadgo-43f54c8d2e3bddfc6ad7887286eb6564986cb6ad.tar.gz
go-43f54c8d2e3bddfc6ad7887286eb6564986cb6ad.zip
runtime: use tgkill for raise
raise uses tkill to send a signal to the current thread. For this use, tgkill is functionally equivalent to tkill expect that it also takes the pid as the first argument. Using tgkill makes it simpler to run a Go program in a strict sandbox. With kill and tgkill, the sandbox policy (e.g., seccomp) can prevent the program from sending signals to other processes by checking that the first argument == getpid(). With tkill, the policy must whitelist all tids in the process, which is effectively impossible given Go's dynamic thread creation. Fixes #27548 Change-Id: I8ed282ef1f7215b02ef46de144493e36454029ea Reviewed-on: https://go-review.googlesource.com/133975 Run-TryBot: Michael Pratt <mpratt@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.s12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/runtime/sys_linux_s390x.s b/src/runtime/sys_linux_s390x.s
index 1ff110c232..95401af62e 100644
--- a/src/runtime/sys_linux_s390x.s
+++ b/src/runtime/sys_linux_s390x.s
@@ -31,9 +31,9 @@
#define SYS_madvise 219
#define SYS_mincore 218
#define SYS_gettid 236
-#define SYS_tkill 237
#define SYS_futex 238
#define SYS_sched_getaffinity 240
+#define SYS_tgkill 241
#define SYS_exit_group 248
#define SYS_epoll_create 249
#define SYS_epoll_ctl 250
@@ -129,11 +129,15 @@ TEXT runtimeĀ·gettid(SB),NOSPLIT,$0-4
RET
TEXT runtimeĀ·raise(SB),NOSPLIT|NOFRAME,$0
+ MOVW $SYS_getpid, R1
+ SYSCALL
+ MOVW R2, R10
MOVW $SYS_gettid, R1
SYSCALL
- MOVW R2, R2 // arg 1 tid
- MOVW sig+0(FP), R3 // arg 2
- MOVW $SYS_tkill, R1
+ MOVW R2, R3 // arg 2 tid
+ MOVW R10, R2 // arg 1 pid
+ MOVW sig+0(FP), R4 // arg 2
+ MOVW $SYS_tgkill, R1
SYSCALL
RET