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_amd64.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_amd64.s')
-rw-r--r-- | src/runtime/sys_linux_amd64.s | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index 62d80247be..4492dad02e 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -36,12 +36,12 @@ #define SYS_sigaltstack 131 #define SYS_arch_prctl 158 #define SYS_gettid 186 -#define SYS_tkill 200 #define SYS_futex 202 #define SYS_sched_getaffinity 204 #define SYS_epoll_create 213 #define SYS_exit_group 231 #define SYS_epoll_ctl 233 +#define SYS_tgkill 234 #define SYS_openat 257 #define SYS_faccessat 269 #define SYS_epoll_pwait 281 @@ -137,11 +137,15 @@ TEXT runtimeĀ·gettid(SB),NOSPLIT,$0-4 RET TEXT runtimeĀ·raise(SB),NOSPLIT,$0 + MOVL $SYS_getpid, AX + SYSCALL + MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL - MOVL AX, DI // arg 1 tid - MOVL sig+0(FP), SI // arg 2 - MOVL $SYS_tkill, AX + MOVL AX, SI // arg 2 tid + MOVL R12, DI // arg 1 pid + MOVL sig+0(FP), DX // arg 3 + MOVL $SYS_tgkill, AX SYSCALL RET |