go/api/next
Kir Kolyshkin bca17d16ca syscall: add CgroupFD support for ForkExec on Linux
Implement CLONE_INTO_CGROUP feature, allowing to put a child in a
specified cgroup in a clean and simple way. Note that the feature only
works for cgroup v2, and requires Linux kernel 5.7 or newer.

Using the feature requires a new syscall, clone3. Currently this is the
only reason to use clone3, but the code is structured in a way so that
other cases may be easily added in the future.

Add a test case.

While at it, try to simplify the syscall calling code in
forkAndExecInChild1, which became complicated over time because:

1. It was using either rawVforkSyscall or RawSyscall6 depending on
   whether CLONE_NEWUSER was set.

2. On Linux/s390, the first two arguments to clone(2) system call are
   swapped (which deserved a mention in Linux ABI hall of shame). It
   was worked around in rawVforkSyscall on s390, but had to be
   implemented via a switch/case when using RawSyscall6, making the code
   less clear.

Let's

 - modify rawVforkSyscall to have two arguments (which is also required
   for clone3);

 - remove the arguments workaround from s390 asm, instead implementing
   arguments swap in the caller (which still looks ugly but at least
   it's done once and is clearly documented now);

 - use rawVforkSyscall for all cases (since it is essentially similar to
   RawSyscall6, except for having less parameters, not returning r2, and
   saving/restoring the return address before/after syscall on 386 and
   amd64).

Updates #51246.

Change-Id: Ifcd418ebead9257177338ffbcccd0bdecb94474e
Reviewed-on: https://go-review.googlesource.com/c/go/+/417695
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-09 15:34:16 +00:00
..
41773.txt net/http: add Server.DisableOptionsHandler for custom handling of OPTIONS * 2022-08-15 18:57:35 +00:00
42537.txt strings, bytes: add CutPrefix and CutSuffix 2022-08-16 19:48:39 +00:00
43620.txt testing: add Elapsed method to testing.B 2022-08-25 17:58:32 +00:00
45038.txt bytes: add Clone function 2022-08-15 19:17:20 +00:00
45899.txt io: add OffsetWriter, NewOffsetWriter 2022-08-19 17:03:55 +00:00
46731.txt cmd/cgo: add and use runtime/cgo.Incomplete instead of //go:notinheap 2022-08-28 16:04:49 +00:00
46746.txt reflect: add Value.{Comparable,Equal} 2022-08-26 20:56:48 +00:00
47209.txt path/filepath, io/fs: add SkipAll 2022-08-25 18:50:37 +00:00
50429.txt go/ast: add Range token.Pos to RangeStmt 2022-09-05 08:12:37 +00:00
51246.txt syscall: add CgroupFD support for ForkExec on Linux 2022-09-09 15:34:16 +00:00
51668.txt fmt: add a function to recover the original format string given a State 2022-08-06 09:19:31 +00:00
51896.txt unicode/utf16: add AppendRune 2022-08-19 16:45:08 +00:00
52221.txt crypto/ecdh: new package 2022-08-12 00:03:39 +00:00
52376.txt reflect: add Value.SetZero 2022-08-26 17:15:08 +00:00
52746.txt time: add DateTime, DateOnly, and TimeOnly 2022-08-09 14:33:24 +00:00
53002.txt net/http/httputil: add ReverseProxy.Rewrite 2022-08-16 20:01:36 +00:00
53021.txt crypto/subtle: add XORBytes 2022-08-17 18:47:33 +00:00
53200.txt go/token: add (*FileSet).RemoveFile(*File) method 2022-08-16 16:27:35 +00:00
53346.txt encoding/xml: add (*Encoder).Close 2022-08-23 18:24:30 +00:00
53356.txt debug/elf: fix reloc number of R_PPC64_SECTOFF_LO_DS 2022-08-27 02:36:28 +00:00
53482.txt net: add FlagRunning to exactly reflect the states of an interface. 2022-08-27 05:42:03 +00:00
54222.txt debug/elf: add new-style LoongArch reloc types 2022-08-11 19:32:40 +00:00
54251.txt debug/pe: add IMAGE_FILE_MACHINE_RISCV{32,64,128} 2022-08-09 01:21:43 +00:00
54345.txt debug/elf: define additional PPC64 ELFv2 relocations 2022-09-08 13:31:46 +00:00