Skip to content

Commit 2ba894f

Browse files
committed
vfork: fix asm on other architectures
doc: update #13
1 parent 10235ab commit 2ba894f

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ Notice: Only works on Linux since ptrace, unshare, cgroup are available only on
1313
## Build & Install
1414

1515
- install latest go compiler from [golang/download](https://golang.org/dl/)
16-
- install libseccomp library: (for Ubuntu) `apt install libseccomp-dev`
17-
- build & install: `go install github.com/criyle/go-sandbox/...`
16+
- download repository: `git clone githuc.com/criyle/go-sandbox`
17+
- build: `go build ./cmd/runprog`
18+
- or install directly: `go install github.com/criyle/go-sandbox/cmd/runprog@latest`
1819

1920
## Technologies
2021

@@ -45,6 +46,12 @@ Default file access syscall check:
4546
2. Use Linux Control Groups to limit & acct CPU & memory (eliminated wait4.rusage)
4647
3. Container tech with execveat memfd, sethostname, setdomainname
4748

49+
### prefork containers
50+
51+
Utilize the linux namespace + cgroup but create container in advance to reduce the duplicated effort of creating mount points. See Pre-forked container protocol and environment for design details.
52+
53+
On kernel >= 5.7 with cgroup v2, the new `clone3(CLONE_INTO_CGROUP)` with `vfork` is available to reduce the resource consumption of create new address spaces as well.
54+
4855
## Design
4956

5057
### Result Status

pkg/forkexec/vfork/asm_linux_386.s

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#include "textflag.h"
66

7+
// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
8+
// instead of the glibc-specific "CALL 0x10(GS)".
9+
#define INVOKE_SYSCALL INT $0x80
10+
711
// func RawVforkSyscall(trap, a1, a2, a3 uintptr) (r1, err uintptr)
812
TEXT ·RawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-24
913
MOVL trap+0(FP), AX // syscall entry
@@ -22,4 +26,4 @@ TEXT ·RawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-24
2226
ok:
2327
MOVL AX, r1+16(FP)
2428
MOVL $0, err+20(FP)
25-
RET
29+
RET

pkg/forkexec/vfork/asm_linux_amd64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ TEXT ·RawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-48
2525
ok2:
2626
MOVQ AX, r1+32(FP)
2727
MOVQ $0, err+40(FP)
28-
RET
28+
RET

pkg/forkexec/vfork/asm_linux_arm.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ ok:
2323
MOVW R0, r1+16(FP)
2424
MOVW $0, R0
2525
MOVW R0, err+20(FP)
26-
RET
26+
RET

0 commit comments

Comments
 (0)