aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/syscall.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-20 00:27:45 +0900
committerOphestra <cat@gensokyo.uk>2025-08-20 00:43:55 +0900
commit13c7083bc028616e258e5e6919db7b11c6e739a6 (patch)
tree0a2e0d1cc85a8211bd1ddb72c628ab9eb0556abe /container/syscall.go
parent6947ff04e067bc7df1d9cf0ad993e3cab3568bf4 (diff)
container: ptrace protection via Yama LSM
This is only a nice to have feature as the init process has no additional privileges and the monitor process was never reachable anyway. Closes #4. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/syscall.go')
-rw-r--r--container/syscall.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/container/syscall.go b/container/syscall.go
index 62b85c55..8fb41e7d 100644
--- a/container/syscall.go
+++ b/container/syscall.go
@@ -9,6 +9,14 @@ const (
SUID_DUMP_USER
)
+func SetPtracer(pid uintptr) error {
+ _, _, errno := syscall.Syscall(syscall.SYS_PRCTL, syscall.PR_SET_PTRACER, pid, 0)
+ if errno == 0 {
+ return nil
+ }
+ return errno
+}
+
func SetDumpable(dumpable uintptr) error {
// linux/sched/coredump.h
if _, _, errno := syscall.Syscall(syscall.SYS_PRCTL, syscall.PR_SET_DUMPABLE, dumpable, 0); errno != 0 {