diff options
author | Michael Pratt <mpratt@google.com> | 2018-09-06 17:21:59 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2018-09-07 22:50:28 +0000 |
commit | 43f54c8d2e3bddfc6ad7887286eb6564986cb6ad (patch) | |
tree | 4883ebc958846178fbcf544e44d22a6599b42be6 /src/runtime/sys_linux_arm64.s | |
parent | ceb7745cc846f798531ef019162dd9f1dabfea12 (diff) | |
download | go-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_arm64.s')
-rw-r--r-- | src/runtime/sys_linux_arm64.s | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s index 1c8fce3db6..086c8ddc63 100644 --- a/src/runtime/sys_linux_arm64.s +++ b/src/runtime/sys_linux_arm64.s @@ -36,7 +36,7 @@ #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 -#define SYS_tkill 130 +#define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 @@ -143,11 +143,15 @@ TEXT runtimeĀ·gettid(SB),NOSPLIT,$0-4 RET TEXT runtimeĀ·raise(SB),NOSPLIT|NOFRAME,$0 + MOVD $SYS_getpid, R8 + SVC + MOVW R0, R19 MOVD $SYS_gettid, R8 SVC - MOVW R0, R0 // arg 1 tid - MOVW sig+0(FP), R1 // arg 2 - MOVD $SYS_tkill, R8 + MOVW R0, R1 // arg 2 tid + MOVW R19, R0 // arg 1 pid + MOVW sig+0(FP), R2 // arg 3 + MOVD $SYS_tgkill, R8 SVC RET |