| 1 |
//go:build linux && !landlocktsync |
| 2 |
|
| 3 |
package syscall |
| 4 |
|
| 5 |
import ( |
| 6 |
"syscall" |
| 7 |
|
| 8 |
"golang.org/x/sys/unix" |
| 9 |
"kernel.org/pub/linux/libs/security/libcap/psx" |
| 10 |
) |
| 11 |
|
| 12 |
// AllThreadsLandlockRestrictSelf enforces the given ruleset on all OS |
| 13 |
// threads belonging to the current process. |
| 14 |
// |
| 15 |
// For Landlock ABI V8 and higher, we recommend using |
| 16 |
// [LandlockRestrictSelf] with the [FlagRestrictSelfTSync] flag instead. |
| 17 |
func AllThreadsLandlockRestrictSelf(rulesetFd int, flags uint32) (err error) { |
| 18 |
_, _, e1 := psx.Syscall3(unix.SYS_LANDLOCK_RESTRICT_SELF, uintptr(rulesetFd), uintptr(flags), 0) |
| 19 |
if e1 != 0 { |
| 20 |
err = syscall.Errno(e1) |
| 21 |
} |
| 22 |
return |
| 23 |
} |
| 24 |
|
| 25 |
// AllThreadsPrctl is like unix.Prctl, but gets applied on all OS threads at the same time. |
| 26 |
func AllThreadsPrctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) { |
| 27 |
_, _, e1 := psx.Syscall6(unix.SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) |
| 28 |
if e1 != 0 { |
| 29 |
err = syscall.Errno(e1) |
| 30 |
} |
| 31 |
return |
| 32 |
} |