diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2023-08-16 19:20:54 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-07 19:11:15 +0000 |
| commit | da7ee57f40069eda3488b2e51dfa878bdd5816af (patch) | |
| tree | d0830dc406737df376008d1ff52f684a66ed1039 /src/syscall/asm_linux_amd64.s | |
| parent | 584d646559eb6c5942410f2ba2d2806f2627c2a2 (diff) | |
| download | go-da7ee57f40069eda3488b2e51dfa878bdd5816af.tar.xz | |
syscall: add support to get pidfd from ForkExec on Linux
Add PidFD support, so that if the PidFD pointer in SysProcAttr is not
nil, ForkExec (and thus all its users) obtains a pidfd from the kernel
during clone(), and writes the result (or -1, if the functionality
is not supported by the kernel) into *PidFD.
The functionality to get pidfd is implemented for both clone3 and clone.
For the latter, an extra argument to rawVforkSyscall is needed, thus the
change in asm files.
Add a trivial test case checking the obtained pidfd can be used to send
a signal to a process, using pidfd_send_signal. To test clone3 code path,
add a flag available to tests only.
Updates #51246.
Change-Id: I2212b69e1a657163c31b4a6245b076bc495777a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/520266
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Diffstat (limited to 'src/syscall/asm_linux_amd64.s')
| -rw-r--r-- | src/syscall/asm_linux_amd64.s | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/syscall/asm_linux_amd64.s b/src/syscall/asm_linux_amd64.s index 00d6fedc62..da170c52ed 100644 --- a/src/syscall/asm_linux_amd64.s +++ b/src/syscall/asm_linux_amd64.s @@ -11,11 +11,11 @@ #define SYS_gettimeofday 96 -// func rawVforkSyscall(trap, a1, a2 uintptr) (r1, err uintptr) -TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-40 +// func rawVforkSyscall(trap, a1, a2, a3 uintptr) (r1, err uintptr) +TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-48 MOVQ a1+8(FP), DI MOVQ a2+16(FP), SI - MOVQ $0, DX + MOVQ a3+24(FP), DX MOVQ $0, R10 MOVQ $0, R8 MOVQ $0, R9 @@ -25,13 +25,13 @@ TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-40 PUSHQ R12 CMPQ AX, $0xfffffffffffff001 JLS ok2 - MOVQ $-1, r1+24(FP) + MOVQ $-1, r1+32(FP) NEGQ AX - MOVQ AX, err+32(FP) + MOVQ AX, err+40(FP) RET ok2: - MOVQ AX, r1+24(FP) - MOVQ $0, err+32(FP) + MOVQ AX, r1+32(FP) + MOVQ $0, err+40(FP) RET // func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) |
