We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ubuntu1~20.04 go version go1.20.6 linux/amd64 gcc version 9.4.0
package lib import ( "bytes" "encoding/binary" "log" "os" "syscall" "unsafe" sg "github.com/seccomp/libseccomp-golang" ) func Seccomp(allowed_syscalls []int, allowed_not_kill_syscalls []int) error { log.Println("Starting Seccomp configuration") ctx, err := sg.NewFilter(sg.ActKillProcess) if err != nil { log.Printf("Failed to create new filter: %v", err) return err } reader, writer, err := os.Pipe() if err != nil { log.Printf("Failed to create pipe: %v", err) return err } defer reader.Close() defer writer.Close() for _, syscall := range allowed_syscalls { ctx.AddRule(sg.ScmpSyscall(syscall), sg.ActAllow) } for _, syscall := range allowed_not_kill_syscalls { ctx.AddRule(sg.ScmpSyscall(syscall), sg.ActErrno) } file := os.NewFile(uintptr(writer.Fd()), "pipe") ctx.ExportBPF(file) log.Println("BPF exported successfully") // read from pipe data := make([]byte, 4096) n, err := reader.Read(data) if err != nil { log.Printf("Failed to read from pipe: %v", err) return err } log.Printf("Read %d bytes from pipe", n) // load bpf sock_filters := make([]syscall.SockFilter, n/8) bytesBuffer := bytes.NewBuffer(data) err = binary.Read(bytesBuffer, binary.LittleEndian, &sock_filters) if err != nil { log.Printf("Failed to decode sock filters: %v", err) return err } log.Println("Sock filters decoded successfully") bpf := syscall.SockFprog{ Len: uint16(len(sock_filters)), Filter: &sock_filters[0], } _, _, err2 := syscall.Syscall( SYS_SECCOMP, uintptr(SeccompSetModeFilter), uintptr(SeccompFilterFlagTSYNC), uintptr(unsafe.Pointer(&bpf)), ) if err2 != 0 { return err2 } return nil }
The above code is executed at "sg. NewFilter (sg. ActKillProcess)": "Failed to create new filter: could not create filter"
The text was updated successfully, but these errors were encountered:
This means that seccomp_init(3) failed. Note that sg.ActKillProcess requires API level 3 from the kernel -- this might be the reason for a failure.
seccomp_init(3)
sg.ActKillProcess
You can get more information by using strace(1).
Sorry, something went wrong.
No branches or pull requests
ubuntu1~20.04
go version go1.20.6 linux/amd64
gcc version 9.4.0
The above code is executed at "sg. NewFilter (sg. ActKillProcess)": "Failed to create new filter: could not create filter"
The text was updated successfully, but these errors were encountered: