diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2023-03-08 12:49:10 +0100 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-03-13 19:26:17 +0000 |
| commit | 7c019c62fb32db42e946b15763217518a521404e (patch) | |
| tree | dd8fe777935c6082a9419d5316e61e05ccfb685b /src/syscall/exec_linux.go | |
| parent | 778627f33187d874440ce1f353bb4d7bce55304a (diff) | |
| download | go-7c019c62fb32db42e946b15763217518a521404e.tar.xz | |
syscall: use clone3 syscall with CLONE_NEWTIME
CLONE_NEWTIME can only be used with the clone3 and unshare system calls,
see https://github.com/torvalds/linux/commit/769071ac9f20b6a447410c7eaa55d1a5233ef40c:
> All available clone flags have been used, so CLONE_NEWTIME uses the highest
> bit of CSIGNAL. It means that it can be used only with the unshare() and
> the clone3() system calls.
The clone3 syscall was added in Linux kernel version 5.3 and
CLONE_NEWTIME was added in version 5.6. However, it was non-functional
until version 6.3 (and stable versions with the corresponding fix [1]).
[1] https://lore.kernel.org/lkml/20230308105126.10107-1-tklauser@distanz.ch/
In case CLONE_NEWTIME is set in SysProcAttr.Cloneflags on an unsupported
kernel version, the fork/exec call will fail.
Fixes #49779
Change-Id: Ic3ecfc2b601bafaab12b1805d7f9512955a8c7e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/474356
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/syscall/exec_linux.go')
| -rw-r--r-- | src/syscall/exec_linux.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index a8eb4bf927..d5f00dd33e 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -293,6 +293,11 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att exitSignal: uint64(SIGCHLD), cgroup: uint64(sys.CgroupFD), } + } else if flags&CLONE_NEWTIME != 0 { + clone3 = &cloneArgs{ + flags: uint64(flags), + exitSignal: uint64(SIGCHLD), + } } // About to call fork. |
