Compare commits
188 Commits
0c0013c440
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
b390640376
|
|||
|
ad2c9f36cd
|
|||
|
67db3fbb8d
|
|||
|
560cb626a1
|
|||
|
c33a6a5b7e
|
|||
|
952082bd9b
|
|||
|
24a9b24823
|
|||
|
c2e61e7987
|
|||
|
86787b3bc5
|
|||
|
cdfcfe6ce0
|
|||
|
68a2f0c240
|
|||
|
7319c7adf9
|
|||
|
e9c890cbb2
|
|||
|
6f924336fc
|
|||
|
bd88f10524
|
|||
|
e34e3b917e
|
|||
|
b0ba165107
|
|||
|
351d6c5a35
|
|||
|
f23f73701c
|
|||
|
876917229a
|
|||
|
0558032c2d
|
|||
|
c61cdc505f
|
|||
|
062edb3487
|
|||
|
e4355279a1
|
|||
|
289fdebead
|
|||
|
9c9e190db9
|
|||
|
d7d42c69a1
|
|||
|
c758e762bd
|
|||
|
10f8b1c221
|
|||
|
6907700d67
|
|||
|
0243f3ffbd
|
|||
|
cd0beeaf8e
|
|||
|
a69273ab2a
|
|||
|
4cd0f57e48
|
|||
|
33a0e6c01b
|
|||
|
d58f5c7590
|
|||
|
1da992e342
|
|||
|
9641805ec2
|
|||
|
0738f4889a
|
|||
|
7de3cfe221
|
|||
|
8b0648dd5d
|
|||
|
4667fac76c
|
|||
|
52e5443b0e
|
|||
|
130e470b60
|
|||
|
ba5ee8e3ee
|
|||
|
d1cef30877
|
|||
|
0188a3f0c7
|
|||
|
04fe3b24ce
|
|||
|
93ad551054
|
|||
|
3d54d1f176
|
|||
|
9feac7738f
|
|||
|
591a60bac9
|
|||
|
5093a06026
|
|||
|
50c1d7f880
|
|||
|
9e63633fbc
|
|||
|
61f981a34a
|
|||
|
d717c41bbe
|
|||
|
b896eec9b7
|
|||
|
8ab99e5e40
|
|||
|
2b6160ef7d
|
|||
|
4dcac7f133
|
|||
|
966fd4df9e
|
|||
|
a2cf59b989
|
|||
|
e87f59c4e4
|
|||
|
3b221c3e77
|
|||
|
ff3b385b12
|
|||
|
c6920e6ab7
|
|||
|
59b25d45fe
|
|||
|
9b99650eb1
|
|||
|
15bff9e1a6
|
|||
|
b948525c07
|
|||
|
9acbd16e9a
|
|||
|
64e5a1068b
|
|||
|
b6cbd49d8c
|
|||
|
6913b9224a
|
|||
|
9584958ecc
|
|||
|
389844b1ea
|
|||
|
5b7ab35633
|
|||
|
52b1a5a725
|
|||
|
6b78df8714
|
|||
|
dadf170a46
|
|||
|
9594832302
|
|||
|
91a2d4d6e1
|
|||
|
a854719b9f
|
|||
|
f03c0fb249
|
|||
|
a6600be34a
|
|||
|
b5592633f5
|
|||
|
584e302168
|
|||
|
141958656f
|
|||
|
648079f42c
|
|||
|
19c76e0831
|
|||
|
71fcc972ba
|
|||
|
62002efd08
|
|||
|
e33294db9c
|
|||
|
b1ea3b4acf
|
|||
|
2c254c70b8
|
|||
|
ea014d6af2
|
|||
|
1b48484c16
|
|||
|
713bff3eb0
|
|||
|
30f459e690
|
|||
|
8766fddcb3
|
|||
|
2745602be3
|
|||
|
ee22847dde
|
|||
|
c61188649b
|
|||
|
6a87a96838
|
|||
|
2548a681e9
|
|||
|
d514d0679f
|
|||
|
4407892632
|
|||
|
e661260607
|
|||
|
044490e0a5
|
|||
|
af038c89ff
|
|||
|
d2f30173cd
|
|||
|
5319ea994c
|
|||
|
bbe178be3e
|
|||
|
ca28e9936b
|
|||
|
f61c6ade56
|
|||
|
fce3d63823
|
|||
|
722c3cc54f
|
|||
|
372d509e5c
|
|||
|
d62516ed1e
|
|||
|
d2b635eb55
|
|||
|
50403e9d60
|
|||
|
b98c5f2e21
|
|||
|
d972cffe5a
|
|||
|
d8648304bb
|
|||
|
f7bfa9a6c2
|
|||
|
7035b4b598
|
|||
|
094b8400dd
|
|||
|
4652d921d8
|
|||
|
066213c245
|
|||
|
98832c21ee
|
|||
|
6cdb6a652b
|
|||
|
7c932cbceb
|
|||
|
20ebddd9bf
|
|||
|
420c721c7d
|
|||
|
bac583f89e
|
|||
|
722989c682
|
|||
|
b852402f67
|
|||
|
6d015a949e
|
|||
|
e9a72490db
|
|||
|
0a12d456ce
|
|||
|
d1fc1a3db7
|
|||
|
1c2d5f6b57
|
|||
|
faea1f4bd6
|
|||
|
0cb1007daa
|
|||
|
e292031624
|
|||
|
cd5959fe5a
|
|||
|
08c35ca24f
|
|||
|
72bd3fb05e
|
|||
|
59c66747df
|
|||
|
9e6fe8db4b
|
|||
|
5168ee3e13
|
|||
|
c8313c2dc4
|
|||
|
3fcdadb669
|
|||
|
3966bc5152
|
|||
|
b208af8b85
|
|||
|
8d650c0c8f
|
|||
|
a720efc32d
|
|||
|
400540cd41
|
|||
|
1113efa5c2
|
|||
|
8b875f865c
|
|||
|
8905d653ba
|
|||
|
9c2fb6246f
|
|||
|
9c116acec6
|
|||
|
988239a2bc
|
|||
|
bc03118142
|
|||
|
74c213264a
|
|||
|
345cffddc2
|
|||
|
49163758c8
|
|||
|
ad22c15fb1
|
|||
|
9c774f7e0a
|
|||
|
707f0a349f
|
|||
|
7c35be066a
|
|||
|
f91d55fa5e
|
|||
|
5862cc1966
|
|||
|
b3f0360a05
|
|||
|
8938994036
|
|||
|
96d382f805
|
|||
|
5c785c135c
|
|||
|
0130f8ea6d
|
|||
|
faac5c4a83
|
|||
|
620062cca9
|
|||
|
196b200d0f
|
|||
|
04e6bc3c5c
|
|||
|
5c540f90aa
|
|||
|
1e8ac5f68e
|
|||
|
fd515badff
|
|||
|
330a344845
|
31
.gitignore
vendored
31
.gitignore
vendored
@@ -1,27 +1,7 @@
|
|||||||
# Binaries for programs and plugins
|
# produced by tools and text editors
|
||||||
*.exe
|
*.qcow2
|
||||||
*.exe~
|
|
||||||
*.dll
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
*.pkg
|
|
||||||
/hakurei
|
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
|
||||||
# vendor/
|
|
||||||
|
|
||||||
# Go workspace file
|
|
||||||
go.work
|
|
||||||
go.work.sum
|
|
||||||
|
|
||||||
# env file
|
|
||||||
.env
|
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
@@ -30,8 +10,5 @@ go.work.sum
|
|||||||
/internal/pkg/testdata/testtool
|
/internal/pkg/testdata/testtool
|
||||||
/internal/rosa/hakurei_current.tar.gz
|
/internal/rosa/hakurei_current.tar.gz
|
||||||
|
|
||||||
# release
|
# cmd/dist default destination
|
||||||
/dist/hakurei-*
|
/dist
|
||||||
|
|
||||||
# interactive nixos vm
|
|
||||||
nixos.qcow2
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://git.gensokyo.uk/security/hakurei">
|
<a href="https://git.gensokyo.uk/rosa/hakurei">
|
||||||
<picture>
|
<picture>
|
||||||
<img src="https://basement.gensokyo.uk/images/yukari1.png" width="200px" alt="Yukari">
|
<img src="https://basement.gensokyo.uk/images/yukari1.png" width="200px" alt="Yukari">
|
||||||
</picture>
|
</picture>
|
||||||
@@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://pkg.go.dev/hakurei.app"><img src="https://pkg.go.dev/badge/hakurei.app.svg" alt="Go Reference" /></a>
|
<a href="https://pkg.go.dev/hakurei.app"><img src="https://pkg.go.dev/badge/hakurei.app.svg" alt="Go Reference" /></a>
|
||||||
<a href="https://git.gensokyo.uk/security/hakurei/actions"><img src="https://git.gensokyo.uk/security/hakurei/actions/workflows/test.yml/badge.svg?branch=staging&style=flat-square" alt="Gitea Workflow Status" /></a>
|
<a href="https://git.gensokyo.uk/rosa/hakurei/actions"><img src="https://git.gensokyo.uk/rosa/hakurei/actions/workflows/test.yml/badge.svg?branch=staging&style=flat-square" alt="Gitea Workflow Status" /></a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="https://git.gensokyo.uk/security/hakurei/releases"><img src="https://img.shields.io/gitea/v/release/security/hakurei?gitea_url=https%3A%2F%2Fgit.gensokyo.uk&color=purple" alt="Release" /></a>
|
<a href="https://git.gensokyo.uk/rosa/hakurei/releases"><img src="https://img.shields.io/gitea/v/release/rosa/hakurei?gitea_url=https%3A%2F%2Fgit.gensokyo.uk&color=purple" alt="Release" /></a>
|
||||||
<a href="https://goreportcard.com/report/hakurei.app"><img src="https://goreportcard.com/badge/hakurei.app" alt="Go Report Card" /></a>
|
<a href="https://goreportcard.com/report/hakurei.app"><img src="https://goreportcard.com/badge/hakurei.app" alt="Go Report Card" /></a>
|
||||||
<a href="https://hakurei.app"><img src="https://img.shields.io/website?url=https%3A%2F%2Fhakurei.app" alt="Website" /></a>
|
<a href="https://hakurei.app"><img src="https://img.shields.io/website?url=https%3A%2F%2Fhakurei.app" alt="Website" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Hakurei is a tool for running sandboxed desktop applications as dedicated
|
Hakurei is a tool for running sandboxed desktop applications as dedicated
|
||||||
subordinate users on the Linux kernel. It implements the application container
|
subordinate users on the Linux kernel. It implements the application container
|
||||||
of [planterette (WIP)](https://git.gensokyo.uk/security/planterette), a
|
of [planterette (WIP)](https://git.gensokyo.uk/rosa/planterette), a
|
||||||
self-contained Android-like package manager with modern security features.
|
self-contained Android-like package manager with modern security features.
|
||||||
|
|
||||||
Interaction with hakurei happens entirely through structures described by
|
Interaction with hakurei happens entirely through structures described by
|
||||||
|
|||||||
6
all.sh
Executable file
6
all.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
TOOLCHAIN_VERSION="$(go version)"
|
||||||
|
cd "$(dirname -- "$0")/"
|
||||||
|
echo "# Building cmd/dist using ${TOOLCHAIN_VERSION}."
|
||||||
|
go run -v --tags=dist ./cmd/dist
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
package check
|
package check
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@@ -30,6 +30,16 @@ func (e AbsoluteError) Is(target error) bool {
|
|||||||
// Absolute holds a pathname checked to be absolute.
|
// Absolute holds a pathname checked to be absolute.
|
||||||
type Absolute struct{ pathname unique.Handle[string] }
|
type Absolute struct{ pathname unique.Handle[string] }
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ encoding.TextAppender = new(Absolute)
|
||||||
|
_ encoding.TextMarshaler = new(Absolute)
|
||||||
|
_ encoding.TextUnmarshaler = new(Absolute)
|
||||||
|
|
||||||
|
_ encoding.BinaryAppender = new(Absolute)
|
||||||
|
_ encoding.BinaryMarshaler = new(Absolute)
|
||||||
|
_ encoding.BinaryUnmarshaler = new(Absolute)
|
||||||
|
)
|
||||||
|
|
||||||
// ok returns whether [Absolute] is not the zero value.
|
// ok returns whether [Absolute] is not the zero value.
|
||||||
func (a *Absolute) ok() bool { return a != nil && *a != (Absolute{}) }
|
func (a *Absolute) ok() bool { return a != nil && *a != (Absolute{}) }
|
||||||
|
|
||||||
@@ -61,7 +71,7 @@ func (a *Absolute) Is(v *Absolute) bool {
|
|||||||
|
|
||||||
// NewAbs checks pathname and returns a new [Absolute] if pathname is absolute.
|
// NewAbs checks pathname and returns a new [Absolute] if pathname is absolute.
|
||||||
func NewAbs(pathname string) (*Absolute, error) {
|
func NewAbs(pathname string) (*Absolute, error) {
|
||||||
if !path.IsAbs(pathname) {
|
if !filepath.IsAbs(pathname) {
|
||||||
return nil, AbsoluteError(pathname)
|
return nil, AbsoluteError(pathname)
|
||||||
}
|
}
|
||||||
return unsafeAbs(pathname), nil
|
return unsafeAbs(pathname), nil
|
||||||
@@ -76,46 +86,35 @@ func MustAbs(pathname string) *Absolute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append calls [path.Join] with [Absolute] as the first element.
|
// Append calls [filepath.Join] with [Absolute] as the first element.
|
||||||
func (a *Absolute) Append(elem ...string) *Absolute {
|
func (a *Absolute) Append(elem ...string) *Absolute {
|
||||||
return unsafeAbs(path.Join(append([]string{a.String()}, elem...)...))
|
return unsafeAbs(filepath.Join(append([]string{a.String()}, elem...)...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dir calls [path.Dir] with [Absolute] as its argument.
|
// Dir calls [filepath.Dir] with [Absolute] as its argument.
|
||||||
func (a *Absolute) Dir() *Absolute { return unsafeAbs(path.Dir(a.String())) }
|
func (a *Absolute) Dir() *Absolute { return unsafeAbs(filepath.Dir(a.String())) }
|
||||||
|
|
||||||
// GobEncode returns the checked pathname.
|
// AppendText appends the checked pathname.
|
||||||
func (a *Absolute) GobEncode() ([]byte, error) {
|
func (a *Absolute) AppendText(data []byte) ([]byte, error) {
|
||||||
return []byte(a.String()), nil
|
return append(data, a.String()...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GobDecode stores data if it represents an absolute pathname.
|
// MarshalText returns the checked pathname.
|
||||||
func (a *Absolute) GobDecode(data []byte) error {
|
func (a *Absolute) MarshalText() ([]byte, error) { return a.AppendText(nil) }
|
||||||
|
|
||||||
|
// UnmarshalText stores data if it represents an absolute pathname.
|
||||||
|
func (a *Absolute) UnmarshalText(data []byte) error {
|
||||||
pathname := string(data)
|
pathname := string(data)
|
||||||
if !path.IsAbs(pathname) {
|
if !filepath.IsAbs(pathname) {
|
||||||
return AbsoluteError(pathname)
|
return AbsoluteError(pathname)
|
||||||
}
|
}
|
||||||
a.pathname = unique.Make(pathname)
|
a.pathname = unique.Make(pathname)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON returns a JSON representation of the checked pathname.
|
func (a *Absolute) AppendBinary(data []byte) ([]byte, error) { return a.AppendText(data) }
|
||||||
func (a *Absolute) MarshalJSON() ([]byte, error) {
|
func (a *Absolute) MarshalBinary() ([]byte, error) { return a.MarshalText() }
|
||||||
return json.Marshal(a.String())
|
func (a *Absolute) UnmarshalBinary(data []byte) error { return a.UnmarshalText(data) }
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON stores data if it represents an absolute pathname.
|
|
||||||
func (a *Absolute) UnmarshalJSON(data []byte) error {
|
|
||||||
var pathname string
|
|
||||||
if err := json.Unmarshal(data, &pathname); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !path.IsAbs(pathname) {
|
|
||||||
return AbsoluteError(pathname)
|
|
||||||
}
|
|
||||||
a.pathname = unique.Make(pathname)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SortAbs calls [slices.SortFunc] for a slice of [Absolute].
|
// SortAbs calls [slices.SortFunc] for a slice of [Absolute].
|
||||||
func SortAbs(x []*Absolute) {
|
func SortAbs(x []*Absolute) {
|
||||||
@@ -11,12 +11,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
_ "unsafe" // for go:linkname
|
_ "unsafe" // for go:linkname
|
||||||
|
|
||||||
. "hakurei.app/container/check"
|
. "hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
// unsafeAbs returns check.Absolute on any string value.
|
// unsafeAbs returns check.Absolute on any string value.
|
||||||
//
|
//
|
||||||
//go:linkname unsafeAbs hakurei.app/container/check.unsafeAbs
|
//go:linkname unsafeAbs hakurei.app/check.unsafeAbs
|
||||||
func unsafeAbs(pathname string) *Absolute
|
func unsafeAbs(pathname string) *Absolute
|
||||||
|
|
||||||
func TestAbsoluteError(t *testing.T) {
|
func TestAbsoluteError(t *testing.T) {
|
||||||
@@ -170,20 +170,20 @@ func TestCodecAbsolute(t *testing.T) {
|
|||||||
|
|
||||||
{"good", MustAbs("/etc"),
|
{"good", MustAbs("/etc"),
|
||||||
nil,
|
nil,
|
||||||
"\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\b\xff\x80\x00\x04/etc",
|
"\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\b\xff\x80\x00\x04/etc",
|
||||||
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\x0f\xff\x84\x01\x04/etc\x01\xfc\xc0\xed\x00\x00\x00",
|
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\x0f\xff\x84\x01\x04/etc\x01\xfc\xc0\xed\x00\x00\x00",
|
||||||
|
|
||||||
`"/etc"`, `{"val":"/etc","magic":3236757504}`},
|
`"/etc"`, `{"val":"/etc","magic":3236757504}`},
|
||||||
{"not absolute", nil,
|
{"not absolute", nil,
|
||||||
AbsoluteError("etc"),
|
AbsoluteError("etc"),
|
||||||
"\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\a\xff\x80\x00\x03etc",
|
"\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\a\xff\x80\x00\x03etc",
|
||||||
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\x0f\xff\x84\x01\x03etc\x01\xfb\x01\x81\xda\x00\x00\x00",
|
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\x0f\xff\x84\x01\x03etc\x01\xfb\x01\x81\xda\x00\x00\x00",
|
||||||
|
|
||||||
`"etc"`, `{"val":"etc","magic":3236757504}`},
|
`"etc"`, `{"val":"etc","magic":3236757504}`},
|
||||||
{"zero", nil,
|
{"zero", nil,
|
||||||
new(AbsoluteError),
|
new(AbsoluteError),
|
||||||
"\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\x04\xff\x80\x00\x00",
|
"\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\x04\xff\x80\x00\x00",
|
||||||
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x05\x01\x02\xff\x82\x00\x00\x00\f\xff\x84\x01\x00\x01\xfb\x01\x81\xda\x00\x00\x00",
|
",\xff\x83\x03\x01\x01\x06sCheck\x01\xff\x84\x00\x01\x02\x01\bPathname\x01\xff\x80\x00\x01\x05Magic\x01\x06\x00\x00\x00\t\x7f\x06\x01\x02\xff\x82\x00\x00\x00\f\xff\x84\x01\x00\x01\xfb\x01\x81\xda\x00\x00\x00",
|
||||||
`""`, `{"val":"","magic":3236757504}`},
|
`""`, `{"val":"","magic":3236757504}`},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,15 +347,6 @@ func TestCodecAbsolute(t *testing.T) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("json passthrough", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
wantErr := "invalid character ':' looking for beginning of value"
|
|
||||||
if err := new(Absolute).UnmarshalJSON([]byte(":3")); err == nil || err.Error() != wantErr {
|
|
||||||
t.Errorf("UnmarshalJSON: error = %v, want %s", err, wantErr)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAbsoluteWrap(t *testing.T) {
|
func TestAbsoluteWrap(t *testing.T) {
|
||||||
@@ -3,7 +3,7 @@ package check_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEscapeOverlayDataSegment(t *testing.T) {
|
func TestEscapeOverlayDataSegment(t *testing.T) {
|
||||||
10
dist/comp/_hakurei → cmd/dist/comp/_hakurei
vendored
10
dist/comp/_hakurei → cmd/dist/comp/_hakurei
vendored
@@ -1,11 +1,11 @@
|
|||||||
#compdef hakurei
|
#compdef hakurei
|
||||||
|
|
||||||
_hakurei_app() {
|
_hakurei_run() {
|
||||||
__hakurei_files
|
__hakurei_files
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
_hakurei_run() {
|
_hakurei_exec() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'--id[Reverse-DNS style Application identifier, leave empty to inherit instance identifier]:id' \
|
'--id[Reverse-DNS style Application identifier, leave empty to inherit instance identifier]:id' \
|
||||||
'-a[Application identity]: :_numbers' \
|
'-a[Application identity]: :_numbers' \
|
||||||
@@ -57,9 +57,9 @@ __hakurei_instances() {
|
|||||||
{
|
{
|
||||||
local -a _hakurei_cmds
|
local -a _hakurei_cmds
|
||||||
_hakurei_cmds=(
|
_hakurei_cmds=(
|
||||||
"app:Load and start container from configuration file"
|
"run:Load and start container from configuration file"
|
||||||
"run:Configure and start a permissive container"
|
"exec:Configure and start a permissive container"
|
||||||
"show:Show live or local app configuration"
|
"show:Show live or local instance configuration"
|
||||||
"ps:List active instances"
|
"ps:List active instances"
|
||||||
"version:Display version information"
|
"version:Display version information"
|
||||||
"license:Show full license text"
|
"license:Show full license text"
|
||||||
237
cmd/dist/main.go
vendored
Normal file
237
cmd/dist/main.go
vendored
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
//go:build dist
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"compress/gzip"
|
||||||
|
"context"
|
||||||
|
"crypto/sha512"
|
||||||
|
_ "embed"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getenv looks up an environment variable, and returns fallback if it is unset.
|
||||||
|
func getenv(key, fallback string) string {
|
||||||
|
if v, ok := os.LookupEnv(key); ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
// mustRun runs a command with the current process's environment and panics
|
||||||
|
// on error or non-zero exit code.
|
||||||
|
func mustRun(ctx context.Context, name string, arg ...string) {
|
||||||
|
cmd := exec.CommandContext(ctx, name, arg...)
|
||||||
|
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:embed comp/_hakurei
|
||||||
|
var comp []byte
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println()
|
||||||
|
log.SetFlags(0)
|
||||||
|
log.SetPrefix("# ")
|
||||||
|
|
||||||
|
version := getenv("HAKUREI_VERSION", "untagged")
|
||||||
|
prefix := getenv("PREFIX", "/usr")
|
||||||
|
destdir := getenv("DESTDIR", "dist")
|
||||||
|
|
||||||
|
if err := os.MkdirAll(destdir, 0755); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
s, err := os.MkdirTemp(destdir, ".dist.*")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
var code int
|
||||||
|
|
||||||
|
if err = os.RemoveAll(s); err != nil {
|
||||||
|
code = 1
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
code = 1
|
||||||
|
log.Println(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(code)
|
||||||
|
}()
|
||||||
|
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
log.Println("Building hakurei.")
|
||||||
|
mustRun(ctx, "go", "generate", "./...")
|
||||||
|
mustRun(
|
||||||
|
ctx, "go", "build",
|
||||||
|
"-trimpath",
|
||||||
|
"-v", "-o", s,
|
||||||
|
"-ldflags=-s -w "+
|
||||||
|
"-buildid= -linkmode external -extldflags=-static "+
|
||||||
|
"-X hakurei.app/internal/info.buildVersion="+version+" "+
|
||||||
|
"-X hakurei.app/internal/info.hakureiPath="+prefix+"/bin/hakurei "+
|
||||||
|
"-X hakurei.app/internal/info.hsuPath="+prefix+"/bin/hsu "+
|
||||||
|
"-X main.hakureiPath="+prefix+"/bin/hakurei",
|
||||||
|
"./...",
|
||||||
|
)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
log.Println("Testing Hakurei.")
|
||||||
|
mustRun(
|
||||||
|
ctx, "go", "test",
|
||||||
|
"-ldflags=-buildid= -linkmode external -extldflags=-static",
|
||||||
|
"./...",
|
||||||
|
)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
log.Println("Creating distribution.")
|
||||||
|
const suffix = ".tar.gz"
|
||||||
|
distName := "hakurei-" + version + "-" + runtime.GOARCH
|
||||||
|
var f *os.File
|
||||||
|
if f, err = os.OpenFile(
|
||||||
|
filepath.Join(s, distName+suffix),
|
||||||
|
os.O_CREATE|os.O_EXCL|os.O_WRONLY,
|
||||||
|
0644,
|
||||||
|
); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if f == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = f.Close(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
h := sha512.New()
|
||||||
|
gw := gzip.NewWriter(io.MultiWriter(f, h))
|
||||||
|
tw := tar.NewWriter(gw)
|
||||||
|
|
||||||
|
mustWriteHeader := func(name string, size int64, mode os.FileMode) {
|
||||||
|
header := tar.Header{
|
||||||
|
Name: filepath.Join(distName, name),
|
||||||
|
Size: size,
|
||||||
|
Mode: int64(mode),
|
||||||
|
Uname: "root",
|
||||||
|
Gname: "root",
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode&os.ModeDir != 0 {
|
||||||
|
header.Typeflag = tar.TypeDir
|
||||||
|
fmt.Printf("%s %s\n", mode, name)
|
||||||
|
} else {
|
||||||
|
header.Typeflag = tar.TypeReg
|
||||||
|
fmt.Printf("%s %s (%d bytes)\n", mode, name, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = tw.WriteHeader(&header); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mustWriteFile := func(name string, data []byte, mode os.FileMode) {
|
||||||
|
mustWriteHeader(name, int64(len(data)), mode)
|
||||||
|
if mode&os.ModeDir != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err = tw.Write(data); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mustWriteFromPath := func(dst, src string, mode os.FileMode) {
|
||||||
|
var r *os.File
|
||||||
|
if r, err = os.Open(src); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fi os.FileInfo
|
||||||
|
if fi, err = r.Stat(); err != nil {
|
||||||
|
_ = r.Close()
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode == 0 {
|
||||||
|
mode = fi.Mode()
|
||||||
|
}
|
||||||
|
|
||||||
|
mustWriteHeader(dst, fi.Size(), mode)
|
||||||
|
if _, err = io.Copy(tw, r); err != nil {
|
||||||
|
_ = r.Close()
|
||||||
|
panic(err)
|
||||||
|
} else if err = r.Close(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mustWriteFile(".", nil, fs.ModeDir|0755)
|
||||||
|
mustWriteFile("comp/", nil, os.ModeDir|0755)
|
||||||
|
mustWriteFile("comp/_hakurei", comp, 0644)
|
||||||
|
mustWriteFile("install.sh", []byte(`#!/bin/sh -e
|
||||||
|
cd "$(dirname -- "$0")" || exit 1
|
||||||
|
|
||||||
|
install -vDm0755 "bin/hakurei" "${DESTDIR}`+prefix+`/bin/hakurei"
|
||||||
|
install -vDm0755 "bin/sharefs" "${DESTDIR}`+prefix+`/bin/sharefs"
|
||||||
|
|
||||||
|
install -vDm4511 "bin/hsu" "${DESTDIR}`+prefix+`/bin/hsu"
|
||||||
|
if [ ! -f "${DESTDIR}/etc/hsurc" ]; then
|
||||||
|
install -vDm0400 "hsurc.default" "${DESTDIR}/etc/hsurc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -vDm0644 "comp/_hakurei" "${DESTDIR}`+prefix+`/share/zsh/site-functions/_hakurei"
|
||||||
|
`), 0755)
|
||||||
|
|
||||||
|
mustWriteFromPath("README.md", "README.md", 0)
|
||||||
|
mustWriteFile("hsurc.default", []byte("1000 0"), 0400)
|
||||||
|
mustWriteFromPath("bin/hsu", filepath.Join(s, "hsu"), 04511)
|
||||||
|
for _, name := range []string{
|
||||||
|
"hakurei",
|
||||||
|
"sharefs",
|
||||||
|
} {
|
||||||
|
mustWriteFromPath(
|
||||||
|
filepath.Join("bin", name),
|
||||||
|
filepath.Join(s, name),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = tw.Close(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
} else if err = gw.Close(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
} else if err = f.Close(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
f = nil
|
||||||
|
|
||||||
|
if err = os.WriteFile(
|
||||||
|
filepath.Join(destdir, distName+suffix+".sha512"),
|
||||||
|
append(hex.AppendEncode(nil, h.Sum(nil)), " "+distName+suffix+"\n"...),
|
||||||
|
0644,
|
||||||
|
); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if err = os.Rename(
|
||||||
|
filepath.Join(s, distName+suffix),
|
||||||
|
filepath.Join(destdir, distName+suffix),
|
||||||
|
); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
|
// The earlyinit is part of the Rosa OS initramfs and serves as the system init.
|
||||||
|
//
|
||||||
|
// This program is an internal detail of Rosa OS and is not usable on its own.
|
||||||
|
// It is not covered by the compatibility promise.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,6 +17,22 @@ func main() {
|
|||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
log.SetPrefix("earlyinit: ")
|
log.SetPrefix("earlyinit: ")
|
||||||
|
|
||||||
|
var (
|
||||||
|
option map[string]string
|
||||||
|
flags []string
|
||||||
|
)
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
option = make(map[string]string)
|
||||||
|
for _, s := range os.Args[1:] {
|
||||||
|
key, value, ok := strings.Cut(s, "=")
|
||||||
|
if !ok {
|
||||||
|
flags = append(flags, s)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
option[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := Mount(
|
if err := Mount(
|
||||||
"devtmpfs",
|
"devtmpfs",
|
||||||
"/dev/",
|
"/dev/",
|
||||||
@@ -55,4 +76,56 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// staying in rootfs, these are no longer used
|
||||||
|
must(os.Remove("/root"))
|
||||||
|
must(os.Remove("/init"))
|
||||||
|
|
||||||
|
must(os.Mkdir("/proc", 0))
|
||||||
|
mustSyscall("mount proc", Mount(
|
||||||
|
"proc",
|
||||||
|
"/proc",
|
||||||
|
"proc",
|
||||||
|
MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||||
|
"hidepid=1",
|
||||||
|
))
|
||||||
|
|
||||||
|
must(os.Mkdir("/sys", 0))
|
||||||
|
mustSyscall("mount sysfs", Mount(
|
||||||
|
"sysfs",
|
||||||
|
"/sys",
|
||||||
|
"sysfs",
|
||||||
|
0,
|
||||||
|
"",
|
||||||
|
))
|
||||||
|
|
||||||
|
// after top level has been set up
|
||||||
|
mustSyscall("remount root", Mount(
|
||||||
|
"",
|
||||||
|
"/",
|
||||||
|
"",
|
||||||
|
MS_REMOUNT|MS_BIND|
|
||||||
|
MS_RDONLY|MS_NODEV|MS_NOSUID|MS_NOEXEC,
|
||||||
|
"",
|
||||||
|
))
|
||||||
|
|
||||||
|
must(os.WriteFile(
|
||||||
|
"/sys/module/firmware_class/parameters/path",
|
||||||
|
[]byte("/system/lib/firmware"),
|
||||||
|
0,
|
||||||
|
))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// mustSyscall calls [log.Fatalln] if err is non-nil.
|
||||||
|
func mustSyscall(action string, err error) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("cannot "+action+":", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// must calls [log.Fatal] with err if it is non-nil.
|
||||||
|
func must(err error) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@@ -11,11 +12,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
_ "unsafe" // for go:linkname
|
|
||||||
|
|
||||||
|
"hakurei.app/check"
|
||||||
"hakurei.app/command"
|
"hakurei.app/command"
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/ext"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/hst"
|
"hakurei.app/hst"
|
||||||
"hakurei.app/internal/dbus"
|
"hakurei.app/internal/dbus"
|
||||||
"hakurei.app/internal/env"
|
"hakurei.app/internal/env"
|
||||||
@@ -26,14 +27,20 @@ import (
|
|||||||
|
|
||||||
// optionalErrorUnwrap calls [errors.Unwrap] and returns the resulting value
|
// optionalErrorUnwrap calls [errors.Unwrap] and returns the resulting value
|
||||||
// if it is not nil, or the original value if it is.
|
// if it is not nil, or the original value if it is.
|
||||||
//
|
func optionalErrorUnwrap(err error) error {
|
||||||
//go:linkname optionalErrorUnwrap hakurei.app/container.optionalErrorUnwrap
|
if underlyingErr := errors.Unwrap(err); underlyingErr != nil {
|
||||||
func optionalErrorUnwrap(err error) error
|
return underlyingErr
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var errSuccess = errors.New("success")
|
||||||
|
|
||||||
func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErrs, out io.Writer) command.Command {
|
func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErrs, out io.Writer) command.Command {
|
||||||
var (
|
var (
|
||||||
flagVerbose bool
|
flagVerbose bool
|
||||||
flagJSON bool
|
flagInsecure bool
|
||||||
|
flagJSON bool
|
||||||
)
|
)
|
||||||
c := command.New(out, log.Printf, "hakurei", func([]string) error {
|
c := command.New(out, log.Printf, "hakurei", func([]string) error {
|
||||||
msg.SwapVerbose(flagVerbose)
|
msg.SwapVerbose(flagVerbose)
|
||||||
@@ -51,6 +58,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
return nil
|
return nil
|
||||||
}).
|
}).
|
||||||
Flag(&flagVerbose, "v", command.BoolFlag(false), "Increase log verbosity").
|
Flag(&flagVerbose, "v", command.BoolFlag(false), "Increase log verbosity").
|
||||||
|
Flag(&flagInsecure, "insecure", command.BoolFlag(false), "Allow use of insecure compatibility options").
|
||||||
Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output in JSON when applicable")
|
Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output in JSON when applicable")
|
||||||
|
|
||||||
c.Command("shim", command.UsageInternal, func([]string) error { outcome.Shim(msg); return errSuccess })
|
c.Command("shim", command.UsageInternal, func([]string) error { outcome.Shim(msg); return errSuccess })
|
||||||
@@ -59,9 +67,9 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
var (
|
var (
|
||||||
flagIdentifierFile int
|
flagIdentifierFile int
|
||||||
)
|
)
|
||||||
c.NewCommand("app", "Load and start container from configuration file", func(args []string) error {
|
c.NewCommand("run", "Load and start container from configuration file", func(args []string) error {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
log.Fatal("app requires at least 1 argument")
|
log.Fatal("run requires at least 1 argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := tryPath(msg, args[0])
|
config := tryPath(msg, args[0])
|
||||||
@@ -69,7 +77,12 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
config.Container.Args = append(config.Container.Args, args[1:]...)
|
config.Container.Args = append(config.Container.Args, args[1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
outcome.Main(ctx, msg, config, flagIdentifierFile)
|
var flags int
|
||||||
|
if flagInsecure {
|
||||||
|
flags |= hst.VAllowInsecure
|
||||||
|
}
|
||||||
|
|
||||||
|
outcome.Main(ctx, msg, config, flags, flagIdentifierFile)
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}).
|
}).
|
||||||
Flag(&flagIdentifierFile, "identifier-fd", command.IntFlag(-1),
|
Flag(&flagIdentifierFile, "identifier-fd", command.IntFlag(-1),
|
||||||
@@ -89,12 +102,15 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
flagHomeDir string
|
flagHomeDir string
|
||||||
flagUserName string
|
flagUserName string
|
||||||
|
|
||||||
|
flagSchedPolicy string
|
||||||
|
flagSchedPriority int
|
||||||
|
|
||||||
flagPrivateRuntime, flagPrivateTmpdir bool
|
flagPrivateRuntime, flagPrivateTmpdir bool
|
||||||
|
|
||||||
flagWayland, flagX11, flagDBus, flagPipeWire, flagPulse bool
|
flagWayland, flagX11, flagDBus, flagPipeWire, flagPulse bool
|
||||||
)
|
)
|
||||||
|
|
||||||
c.NewCommand("run", "Configure and start a permissive container", func(args []string) error {
|
c.NewCommand("exec", "Configure and start a permissive container", func(args []string) error {
|
||||||
if flagIdentity < hst.IdentityStart || flagIdentity > hst.IdentityEnd {
|
if flagIdentity < hst.IdentityStart || flagIdentity > hst.IdentityEnd {
|
||||||
log.Fatalf("identity %d out of range", flagIdentity)
|
log.Fatalf("identity %d out of range", flagIdentity)
|
||||||
}
|
}
|
||||||
@@ -131,12 +147,12 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
log.Fatal(optionalErrorUnwrap(err))
|
log.Fatal(optionalErrorUnwrap(err))
|
||||||
return err
|
return err
|
||||||
} else if progPath, err = check.NewAbs(p); err != nil {
|
} else if progPath, err = check.NewAbs(p); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var et hst.Enablement
|
var et hst.Enablements
|
||||||
if flagWayland {
|
if flagWayland {
|
||||||
et |= hst.EWayland
|
et |= hst.EWayland
|
||||||
}
|
}
|
||||||
@@ -150,11 +166,11 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
et |= hst.EPipeWire
|
et |= hst.EPipeWire
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &hst.Config{
|
config := hst.Config{
|
||||||
ID: flagID,
|
ID: flagID,
|
||||||
Identity: flagIdentity,
|
Identity: flagIdentity,
|
||||||
Groups: flagGroups,
|
Groups: flagGroups,
|
||||||
Enablements: hst.NewEnablements(et),
|
Enablements: &et,
|
||||||
|
|
||||||
Container: &hst.ContainerConfig{
|
Container: &hst.ContainerConfig{
|
||||||
Filesystem: []hst.FilesystemConfigJSON{
|
Filesystem: []hst.FilesystemConfigJSON{
|
||||||
@@ -177,6 +193,13 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := config.SchedPolicy.UnmarshalText(
|
||||||
|
[]byte(flagSchedPolicy),
|
||||||
|
); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
config.SchedPriority = ext.Int(flagSchedPriority)
|
||||||
|
|
||||||
// bind GPU stuff
|
// bind GPU stuff
|
||||||
if et&(hst.EX11|hst.EWayland) != 0 {
|
if et&(hst.EX11|hst.EWayland) != 0 {
|
||||||
config.Container.Filesystem = append(config.Container.Filesystem, hst.FilesystemConfigJSON{FilesystemConfig: &hst.FSBind{
|
config.Container.Filesystem = append(config.Container.Filesystem, hst.FilesystemConfigJSON{FilesystemConfig: &hst.FSBind{
|
||||||
@@ -214,7 +237,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
homeDir = passwd.HomeDir
|
homeDir = passwd.HomeDir
|
||||||
}
|
}
|
||||||
if a, err := check.NewAbs(homeDir); err != nil {
|
if a, err := check.NewAbs(homeDir); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
config.Container.Home = a
|
config.Container.Home = a
|
||||||
@@ -234,11 +257,11 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
config.SessionBus = dbus.NewConfig(flagID, true, flagDBusMpris)
|
config.SessionBus = dbus.NewConfig(flagID, true, flagDBusMpris)
|
||||||
} else {
|
} else {
|
||||||
if f, err := os.Open(flagDBusConfigSession); err != nil {
|
if f, err := os.Open(flagDBusConfigSession); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
decodeJSON(log.Fatal, "load session bus proxy config", f, &config.SessionBus)
|
decodeJSON(log.Fatal, "load session bus proxy config", f, &config.SessionBus)
|
||||||
if err = f.Close(); err != nil {
|
if err = f.Close(); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,11 +269,11 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
// system bus proxy is optional
|
// system bus proxy is optional
|
||||||
if flagDBusConfigSystem != "nil" {
|
if flagDBusConfigSystem != "nil" {
|
||||||
if f, err := os.Open(flagDBusConfigSystem); err != nil {
|
if f, err := os.Open(flagDBusConfigSystem); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
decodeJSON(log.Fatal, "load system bus proxy config", f, &config.SystemBus)
|
decodeJSON(log.Fatal, "load system bus proxy config", f, &config.SystemBus)
|
||||||
if err = f.Close(); err != nil {
|
if err = f.Close(); err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,7 +289,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outcome.Main(ctx, msg, config, -1)
|
outcome.Main(ctx, msg, &config, 0, -1)
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}).
|
}).
|
||||||
Flag(&flagDBusConfigSession, "dbus-config", command.StringFlag("builtin"),
|
Flag(&flagDBusConfigSession, "dbus-config", command.StringFlag("builtin"),
|
||||||
@@ -287,6 +310,10 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
"Container home directory").
|
"Container home directory").
|
||||||
Flag(&flagUserName, "u", command.StringFlag("chronos"),
|
Flag(&flagUserName, "u", command.StringFlag("chronos"),
|
||||||
"Passwd user name within sandbox").
|
"Passwd user name within sandbox").
|
||||||
|
Flag(&flagSchedPolicy, "policy", command.StringFlag(""),
|
||||||
|
"Scheduling policy to set for the container").
|
||||||
|
Flag(&flagSchedPriority, "priority", command.IntFlag(0),
|
||||||
|
"Scheduling priority to set for the container").
|
||||||
Flag(&flagPrivateRuntime, "private-runtime", command.BoolFlag(false),
|
Flag(&flagPrivateRuntime, "private-runtime", command.BoolFlag(false),
|
||||||
"Do not share XDG_RUNTIME_DIR between containers under the same identity").
|
"Do not share XDG_RUNTIME_DIR between containers under the same identity").
|
||||||
Flag(&flagPrivateTmpdir, "private-tmpdir", command.BoolFlag(false),
|
Flag(&flagPrivateTmpdir, "private-tmpdir", command.BoolFlag(false),
|
||||||
@@ -308,7 +335,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
flagShort bool
|
flagShort bool
|
||||||
flagNoStore bool
|
flagNoStore bool
|
||||||
)
|
)
|
||||||
c.NewCommand("show", "Show live or local app configuration", func(args []string) error {
|
c.NewCommand("show", "Show live or local instance configuration", func(args []string) error {
|
||||||
switch len(args) {
|
switch len(args) {
|
||||||
case 0: // system
|
case 0: // system
|
||||||
printShowSystem(os.Stdout, flagShort, flagJSON)
|
printShowSystem(os.Stdout, flagShort, flagJSON)
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ func TestHelp(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"main", []string{}, `
|
"main", []string{}, `
|
||||||
Usage: hakurei [-h | --help] [-v] [--json] COMMAND [OPTIONS]
|
Usage: hakurei [-h | --help] [-v] [--insecure] [--json] COMMAND [OPTIONS]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
app Load and start container from configuration file
|
run Load and start container from configuration file
|
||||||
run Configure and start a permissive container
|
exec Configure and start a permissive container
|
||||||
show Show live or local app configuration
|
show Show live or local instance configuration
|
||||||
ps List active instances
|
ps List active instances
|
||||||
version Display version information
|
version Display version information
|
||||||
license Show full license text
|
license Show full license text
|
||||||
@@ -35,8 +35,8 @@ Commands:
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"run", []string{"run", "-h"}, `
|
"exec", []string{"exec", "-h"}, `
|
||||||
Usage: hakurei run [-h | --help] [--dbus-config <value>] [--dbus-system <value>] [--mpris] [--dbus-log] [--id <value>] [-a <int>] [-g <value>] [-d <value>] [-u <value>] [--private-runtime] [--private-tmpdir] [--wayland] [-X] [--dbus] [--pipewire] [--pulse] COMMAND [OPTIONS]
|
Usage: hakurei exec [-h | --help] [--dbus-config <value>] [--dbus-system <value>] [--mpris] [--dbus-log] [--id <value>] [-a <int>] [-g <value>] [-d <value>] [-u <value>] [--policy <value>] [--priority <int>] [--private-runtime] [--private-tmpdir] [--wayland] [-X] [--dbus] [--pipewire] [--pulse] COMMAND [OPTIONS]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-X Enable direct connection to X11
|
-X Enable direct connection to X11
|
||||||
@@ -60,6 +60,10 @@ Flags:
|
|||||||
Allow owning MPRIS D-Bus path, has no effect if custom config is available
|
Allow owning MPRIS D-Bus path, has no effect if custom config is available
|
||||||
-pipewire
|
-pipewire
|
||||||
Enable connection to PipeWire via SecurityContext
|
Enable connection to PipeWire via SecurityContext
|
||||||
|
-policy string
|
||||||
|
Scheduling policy to set for the container
|
||||||
|
-priority int
|
||||||
|
Scheduling priority to set for the container
|
||||||
-private-runtime
|
-private-runtime
|
||||||
Do not share XDG_RUNTIME_DIR between containers under the same identity
|
Do not share XDG_RUNTIME_DIR between containers under the same identity
|
||||||
-private-tmpdir
|
-private-tmpdir
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecodeJSON(t *testing.T) {
|
func TestDecodeJSON(t *testing.T) {
|
||||||
|
|||||||
@@ -1,8 +1,42 @@
|
|||||||
|
// Hakurei runs user-specified containers as subordinate users.
|
||||||
|
//
|
||||||
|
// This program is generally invoked by another, higher level program, which
|
||||||
|
// creates container configuration via package [hst] or an implementation of it.
|
||||||
|
//
|
||||||
|
// The parent may leave files open and specify their file descriptor for various
|
||||||
|
// uses. In these cases, standard streams and netpoll files are treated as
|
||||||
|
// invalid file descriptors and rejected. All string representations must be in
|
||||||
|
// decimal.
|
||||||
|
//
|
||||||
|
// When specifying a [hst.Config] JSON stream or file to the run subcommand, the
|
||||||
|
// argument "-" is equivalent to stdin. Otherwise, file descriptor rules
|
||||||
|
// described above applies. Invalid file descriptors are treated as file names
|
||||||
|
// in their string representation, with the exception that if a netpoll file
|
||||||
|
// descriptor is attempted, the program fails.
|
||||||
|
//
|
||||||
|
// The flag --identifier-fd can be optionally specified to the run subcommand to
|
||||||
|
// receive the identifier of the newly started instance. File descriptor rules
|
||||||
|
// described above applies, and the file must be writable. This is sent after
|
||||||
|
// its state is made available, so the client must not attempt to poll for it.
|
||||||
|
// This uses the internal binary format of [hst.ID].
|
||||||
|
//
|
||||||
|
// For the show and ps subcommands, the flag --json can be applied to the main
|
||||||
|
// hakurei command to serialise output in JSON when applicable. Additionally,
|
||||||
|
// the flag --short targeting each subcommand is used to omit some information
|
||||||
|
// in both JSON and user-facing output. Only JSON-encoded output is covered
|
||||||
|
// under the compatibility promise.
|
||||||
|
//
|
||||||
|
// A template for [hst.Config] demonstrating all available configuration fields
|
||||||
|
// is returned by [hst.Template]. The JSON-encoded equivalent of this can be
|
||||||
|
// obtained via the template subcommand. Fields left unpopulated in the template
|
||||||
|
// (the direct_* family of fields, which are insecure under any configuration if
|
||||||
|
// enabled) are unsupported.
|
||||||
|
//
|
||||||
|
// For simple (but insecure) testing scenarios, the exec subcommand can be used
|
||||||
|
// to generate a simple, permissive configuration in-memory. See its help
|
||||||
|
// message for all available options.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// this works around go:embed '..' limitation
|
|
||||||
//go:generate cp ../../LICENSE .
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
@@ -13,15 +47,13 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
|
"hakurei.app/ext"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
//go:generate cp ../../LICENSE .
|
||||||
errSuccess = errors.New("success")
|
//go:embed LICENSE
|
||||||
|
var license string
|
||||||
//go:embed LICENSE
|
|
||||||
license string
|
|
||||||
)
|
|
||||||
|
|
||||||
// earlyHardeningErrs are errors collected while setting up early hardening feature.
|
// earlyHardeningErrs are errors collected while setting up early hardening feature.
|
||||||
type earlyHardeningErrs struct{ yamaLSM, dumpable error }
|
type earlyHardeningErrs struct{ yamaLSM, dumpable error }
|
||||||
@@ -30,13 +62,13 @@ func main() {
|
|||||||
// early init path, skips root check and duplicate PR_SET_DUMPABLE
|
// early init path, skips root check and duplicate PR_SET_DUMPABLE
|
||||||
container.TryArgv0(nil)
|
container.TryArgv0(nil)
|
||||||
|
|
||||||
log.SetPrefix("hakurei: ")
|
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
log.SetPrefix("hakurei: ")
|
||||||
msg := message.New(log.Default())
|
msg := message.New(log.Default())
|
||||||
|
|
||||||
early := earlyHardeningErrs{
|
early := earlyHardeningErrs{
|
||||||
yamaLSM: container.SetPtracer(0),
|
yamaLSM: ext.SetPtracer(0),
|
||||||
dumpable: container.SetDumpable(container.SUID_DUMP_DISABLE),
|
dumpable: ext.SetDumpable(ext.SUID_DUMP_DISABLE),
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Geteuid() == 0 {
|
if os.Geteuid() == 0 {
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// tryPath attempts to read [hst.Config] from multiple sources.
|
// tryPath attempts to read [hst.Config] from multiple sources.
|
||||||
// tryPath reads from [os.Stdin] if name has value "-".
|
//
|
||||||
// Otherwise, name is passed to tryFd, and if that returns nil, name is passed to [os.Open].
|
// tryPath reads from [os.Stdin] if name has value "-". Otherwise, name is
|
||||||
|
// passed to tryFd, and if that returns nil, name is passed to [os.Open].
|
||||||
func tryPath(msg message.Msg, name string) (config *hst.Config) {
|
func tryPath(msg message.Msg, name string) (config *hst.Config) {
|
||||||
var r io.ReadCloser
|
var r io.ReadCloser
|
||||||
config = new(hst.Config)
|
config = new(hst.Config)
|
||||||
@@ -46,7 +47,8 @@ func tryPath(msg message.Msg, name string) (config *hst.Config) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryFd returns a [io.ReadCloser] if name represents an integer corresponding to a valid file descriptor.
|
// tryFd returns a [io.ReadCloser] if name represents an integer corresponding
|
||||||
|
// to a valid file descriptor.
|
||||||
func tryFd(msg message.Msg, name string) io.ReadCloser {
|
func tryFd(msg message.Msg, name string) io.ReadCloser {
|
||||||
if v, err := strconv.Atoi(name); err != nil {
|
if v, err := strconv.Atoi(name); err != nil {
|
||||||
if !errors.Is(err, strconv.ErrSyntax) {
|
if !errors.Is(err, strconv.ErrSyntax) {
|
||||||
@@ -60,7 +62,12 @@ func tryFd(msg message.Msg, name string) io.ReadCloser {
|
|||||||
|
|
||||||
msg.Verbosef("trying config stream from %d", v)
|
msg.Verbosef("trying config stream from %d", v)
|
||||||
fd := uintptr(v)
|
fd := uintptr(v)
|
||||||
if _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, fd, syscall.F_GETFD, 0); errno != 0 {
|
if _, _, errno := syscall.Syscall(
|
||||||
|
syscall.SYS_FCNTL,
|
||||||
|
fd,
|
||||||
|
syscall.F_GETFD,
|
||||||
|
0,
|
||||||
|
); errno != 0 {
|
||||||
if errors.Is(errno, syscall.EBADF) { // reject bad fd
|
if errors.Is(errno, syscall.EBADF) { // reject bad fd
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -75,10 +82,12 @@ func tryFd(msg message.Msg, name string) io.ReadCloser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// shortLengthMin is the minimum length a short form identifier can have and still be interpreted as an identifier.
|
// shortLengthMin is the minimum length a short form identifier can have and
|
||||||
|
// still be interpreted as an identifier.
|
||||||
const shortLengthMin = 1 << 3
|
const shortLengthMin = 1 << 3
|
||||||
|
|
||||||
// shortIdentifier returns an eight character short representation of [hst.ID] from its random bytes.
|
// shortIdentifier returns an eight character short representation of [hst.ID]
|
||||||
|
// from its random bytes.
|
||||||
func shortIdentifier(id *hst.ID) string {
|
func shortIdentifier(id *hst.ID) string {
|
||||||
return shortIdentifierString(id.String())
|
return shortIdentifierString(id.String())
|
||||||
}
|
}
|
||||||
@@ -88,7 +97,8 @@ func shortIdentifierString(s string) string {
|
|||||||
return s[len(hst.ID{}) : len(hst.ID{})+shortLengthMin]
|
return s[len(hst.ID{}) : len(hst.ID{})+shortLengthMin]
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryIdentifier attempts to match [hst.State] from a [hex] representation of [hst.ID] or a prefix of its lower half.
|
// tryIdentifier attempts to match [hst.State] from a [hex] representation of
|
||||||
|
// [hst.ID] or a prefix of its lower half.
|
||||||
func tryIdentifier(msg message.Msg, name string, s *store.Store) *hst.State {
|
func tryIdentifier(msg message.Msg, name string, s *store.Store) *hst.State {
|
||||||
const (
|
const (
|
||||||
likeShort = 1 << iota
|
likeShort = 1 << iota
|
||||||
@@ -96,7 +106,8 @@ func tryIdentifier(msg message.Msg, name string, s *store.Store) *hst.State {
|
|||||||
)
|
)
|
||||||
|
|
||||||
var likely uintptr
|
var likely uintptr
|
||||||
if len(name) >= shortLengthMin && len(name) <= len(hst.ID{}) { // half the hex representation
|
// half the hex representation
|
||||||
|
if len(name) >= shortLengthMin && len(name) <= len(hst.ID{}) {
|
||||||
// cannot safely decode here due to unknown alignment
|
// cannot safely decode here due to unknown alignment
|
||||||
for _, c := range name {
|
for _, c := range name {
|
||||||
if c >= '0' && c <= '9' {
|
if c >= '0' && c <= '9' {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/hst"
|
"hakurei.app/hst"
|
||||||
"hakurei.app/internal/store"
|
"hakurei.app/internal/store"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func printShowInstance(
|
|||||||
t := newPrinter(output)
|
t := newPrinter(output)
|
||||||
defer t.MustFlush()
|
defer t.MustFlush()
|
||||||
|
|
||||||
if err := config.Validate(); err != nil {
|
if err := config.Validate(hst.VAllowInsecure); err != nil {
|
||||||
valid = false
|
valid = false
|
||||||
if m, ok := message.GetMessage(err); ok {
|
if m, ok := message.GetMessage(err); ok {
|
||||||
mustPrint(output, "Error: "+m+"!\n\n")
|
mustPrint(output, "Error: "+m+"!\n\n")
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/hst"
|
"hakurei.app/hst"
|
||||||
"hakurei.app/internal/store"
|
"hakurei.app/internal/store"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
@@ -32,7 +32,7 @@ var (
|
|||||||
PID: 0xbeef,
|
PID: 0xbeef,
|
||||||
ShimPID: 0xcafe,
|
ShimPID: 0xcafe,
|
||||||
Config: &hst.Config{
|
Config: &hst.Config{
|
||||||
Enablements: hst.NewEnablements(hst.EWayland | hst.EPipeWire),
|
Enablements: new(hst.EWayland | hst.EPipeWire),
|
||||||
Identity: 1,
|
Identity: 1,
|
||||||
Container: &hst.ContainerConfig{
|
Container: &hst.ContainerConfig{
|
||||||
Shell: check.MustAbs("/bin/sh"),
|
Shell: check.MustAbs("/bin/sh"),
|
||||||
|
|||||||
7
cmd/hsu/conf.go
Normal file
7
cmd/hsu/conf.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build !rosa
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
// hsuConfPath is an absolute pathname to the hsu configuration file. Its
|
||||||
|
// contents are interpreted by parseConfig.
|
||||||
|
const hsuConfPath = "/etc/hsurc"
|
||||||
7
cmd/hsu/config_rosa.go
Normal file
7
cmd/hsu/config_rosa.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build rosa
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
// hsuConfPath is the pathname to the hsu configuration file, specific to
|
||||||
|
// Rosa OS. Its contents are interpreted by parseConfig.
|
||||||
|
const hsuConfPath = "/system/etc/hsurc"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
/* copied from hst and must never be changed */
|
/* keep in sync with hst */
|
||||||
|
|
||||||
const (
|
const (
|
||||||
userOffset = 100000
|
userOffset = 100000
|
||||||
|
|||||||
@@ -1,13 +1,64 @@
|
|||||||
|
// hsu starts the hakurei shim as the target subordinate user.
|
||||||
|
//
|
||||||
|
// The hsu program must be installed with the setuid and setgid bit set, and
|
||||||
|
// owned by root. A configuration file must be installed at /etc/hsurc with
|
||||||
|
// permission bits 0400, and owned by root. Each line of the file specifies a
|
||||||
|
// hakurei userid to kernel uid mapping. A line consists of the decimal string
|
||||||
|
// representation of the uid of the user wishing to start hakurei containers,
|
||||||
|
// followed by a space, followed by the decimal string representation of its
|
||||||
|
// userid. Duplicate uid entries are ignored, with the first occurrence taking
|
||||||
|
// effect.
|
||||||
|
//
|
||||||
|
// For example, to map the kernel uid 1000 to the hakurei user id 0:
|
||||||
|
//
|
||||||
|
// 1000 0
|
||||||
|
//
|
||||||
|
// # Internals
|
||||||
|
//
|
||||||
|
// Hakurei and hsu holds pathnames pointing to each other set at link time. For
|
||||||
|
// this reason, a distribution of hakurei has fixed installation prefix. Since
|
||||||
|
// this program is never invoked by the user, behaviour described in the
|
||||||
|
// following paragraphs are considered an internal detail and not covered by the
|
||||||
|
// compatibility promise.
|
||||||
|
//
|
||||||
|
// After checking credentials, hsu checks via /proc/ the absolute pathname of
|
||||||
|
// its parent process, and fails if it does not match the hakurei pathname set
|
||||||
|
// at link time. This is not a security feature: the priv-side is considered
|
||||||
|
// trusted, and this feature makes no attempt to address the racy nature of
|
||||||
|
// querying /proc/, or debuggers attached to the parent process. Instead, this
|
||||||
|
// aims to discourage misuse and reduce confusion if the user accidentally
|
||||||
|
// stumbles upon this program. It also prevents accidental use of the incorrect
|
||||||
|
// installation of hsu in some environments.
|
||||||
|
//
|
||||||
|
// Since target container environment variables are set up in shim via the
|
||||||
|
// [container] infrastructure, the environment is used for parameters from the
|
||||||
|
// parent process.
|
||||||
|
//
|
||||||
|
// HAKUREI_SHIM specifies a single byte between '3' and '9' representing the
|
||||||
|
// setup pipe file descriptor. It is passed as is to the shim process and is the
|
||||||
|
// only value in the environment of the shim process. Since hsurc is not
|
||||||
|
// accessible to the parent process, leaving this unset causes hsu to print the
|
||||||
|
// corresponding hakurei user id of the parent and terminate.
|
||||||
|
//
|
||||||
|
// HAKUREI_IDENTITY specifies the identity of the instance being started and is
|
||||||
|
// used to produce the kernel uid alongside hakurei user id looked up from hsurc.
|
||||||
|
//
|
||||||
|
// HAKUREI_GROUPS specifies supplementary groups to inherit from the credentials
|
||||||
|
// of the parent process in a ' ' separated list of decimal string
|
||||||
|
// representations of gid. This has the unfortunate consequence of allowing
|
||||||
|
// users mapped via hsurc to effectively drop group membership, so special care
|
||||||
|
// must be taken to ensure this does not lead to an increase in access. This is
|
||||||
|
// not applicable to Rosa OS since unsigned code execution is not permitted
|
||||||
|
// outside hakurei containers, and is generally nonapplicable to the security
|
||||||
|
// model of hakurei, where all untrusted code runs within containers.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// minimise imports to avoid inadvertently calling init or global variable functions
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -16,10 +67,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// envIdentity is the name of the environment variable holding a
|
// envShim is the name of the environment variable holding a single byte
|
||||||
// single byte representing the shim setup pipe file descriptor.
|
// representing the shim setup pipe file descriptor.
|
||||||
envShim = "HAKUREI_SHIM"
|
envShim = "HAKUREI_SHIM"
|
||||||
// envGroups holds a ' ' separated list of string representations of
|
// envIdentity is the name of the environment variable holding a decimal
|
||||||
|
// string representation of the current application identity.
|
||||||
|
envIdentity = "HAKUREI_IDENTITY"
|
||||||
|
// envGroups holds a ' ' separated list of decimal string representations of
|
||||||
// supplementary group gid. Membership requirements are enforced.
|
// supplementary group gid. Membership requirements are enforced.
|
||||||
envGroups = "HAKUREI_GROUPS"
|
envGroups = "HAKUREI_GROUPS"
|
||||||
)
|
)
|
||||||
@@ -35,7 +89,6 @@ func main() {
|
|||||||
|
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
log.SetPrefix("hsu: ")
|
log.SetPrefix("hsu: ")
|
||||||
log.SetOutput(os.Stderr)
|
|
||||||
|
|
||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
log.Fatal("this program must be owned by uid 0 and have the setuid bit set")
|
log.Fatal("this program must be owned by uid 0 and have the setuid bit set")
|
||||||
@@ -49,13 +102,13 @@ func main() {
|
|||||||
log.Fatal("this program must not be started by root")
|
log.Fatal("this program must not be started by root")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !path.IsAbs(hakureiPath) {
|
if !filepath.IsAbs(hakureiPath) {
|
||||||
log.Fatal("this program is compiled incorrectly")
|
log.Fatal("this program is compiled incorrectly")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var toolPath string
|
var toolPath string
|
||||||
pexe := path.Join("/proc", strconv.Itoa(os.Getppid()), "exe")
|
pexe := filepath.Join("/proc", strconv.Itoa(os.Getppid()), "exe")
|
||||||
if p, err := os.Readlink(pexe); err != nil {
|
if p, err := os.Readlink(pexe); err != nil {
|
||||||
log.Fatalf("cannot read parent executable path: %v", err)
|
log.Fatalf("cannot read parent executable path: %v", err)
|
||||||
} else if strings.HasSuffix(p, " (deleted)") {
|
} else if strings.HasSuffix(p, " (deleted)") {
|
||||||
@@ -99,8 +152,6 @@ func main() {
|
|||||||
// last possible uid outcome
|
// last possible uid outcome
|
||||||
uidEnd = 999919999
|
uidEnd = 999919999
|
||||||
)
|
)
|
||||||
|
|
||||||
// cast to int for use with library functions
|
|
||||||
uid := int(toUser(userid, identity))
|
uid := int(toUser(userid, identity))
|
||||||
|
|
||||||
// final bounds check to catch any bugs
|
// final bounds check to catch any bugs
|
||||||
@@ -136,7 +187,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// careful! users in the allowlist is effectively allowed to drop groups via hsu
|
// careful! users in the allowlist is effectively allowed to drop groups via hsu
|
||||||
|
|
||||||
if err := syscall.Setresgid(uid, uid, uid); err != nil {
|
if err := syscall.Setresgid(uid, uid, uid); err != nil {
|
||||||
log.Fatalf("cannot set gid: %v", err)
|
log.Fatalf("cannot set gid: %v", err)
|
||||||
}
|
}
|
||||||
@@ -146,10 +196,21 @@ func main() {
|
|||||||
if err := syscall.Setresuid(uid, uid, uid); err != nil {
|
if err := syscall.Setresuid(uid, uid, uid); err != nil {
|
||||||
log.Fatalf("cannot set uid: %v", err)
|
log.Fatalf("cannot set uid: %v", err)
|
||||||
}
|
}
|
||||||
if _, _, errno := syscall.AllThreadsSyscall(syscall.SYS_PRCTL, PR_SET_NO_NEW_PRIVS, 1, 0); errno != 0 {
|
|
||||||
|
if _, _, errno := syscall.AllThreadsSyscall(
|
||||||
|
syscall.SYS_PRCTL,
|
||||||
|
PR_SET_NO_NEW_PRIVS, 1,
|
||||||
|
0,
|
||||||
|
); errno != 0 {
|
||||||
log.Fatalf("cannot set no_new_privs flag: %s", errno.Error())
|
log.Fatalf("cannot set no_new_privs flag: %s", errno.Error())
|
||||||
}
|
}
|
||||||
if err := syscall.Exec(toolPath, []string{"hakurei", "shim"}, []string{envShim + "=" + shimSetupFd}); err != nil {
|
|
||||||
|
if err := syscall.Exec(toolPath, []string{
|
||||||
|
"hakurei",
|
||||||
|
"shim",
|
||||||
|
}, []string{
|
||||||
|
envShim + "=" + shimSetupFd,
|
||||||
|
}); err != nil {
|
||||||
log.Fatalf("cannot start shim: %v", err)
|
log.Fatalf("cannot start shim: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ const (
|
|||||||
useridEnd = useridStart + rangeSize - 1
|
useridEnd = useridStart + rangeSize - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// parseUint32Fast parses a string representation of an unsigned 32-bit integer value
|
// parseUint32Fast parses a string representation of an unsigned 32-bit integer
|
||||||
// using the fast path only. This limits the range of values it is defined in.
|
// value using the fast path only. This limits the range of values it is defined
|
||||||
|
// in but is perfectly adequate for this use case.
|
||||||
func parseUint32Fast(s string) (uint32, error) {
|
func parseUint32Fast(s string) (uint32, error) {
|
||||||
sLen := len(s)
|
sLen := len(s)
|
||||||
if sLen < 1 {
|
if sLen < 1 {
|
||||||
@@ -40,12 +41,14 @@ func parseUint32Fast(s string) (uint32, error) {
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseConfig reads a list of allowed users from r until it encounters puid or [io.EOF].
|
// parseConfig reads a list of allowed users from r until it encounters puid or
|
||||||
|
// [io.EOF].
|
||||||
//
|
//
|
||||||
// Each line of the file specifies a hakurei userid to kernel uid mapping. A line consists
|
// Each line of the file specifies a hakurei userid to kernel uid mapping. A
|
||||||
// of the string representation of the uid of the user wishing to start hakurei containers,
|
// line consists of the string representation of the uid of the user wishing to
|
||||||
// followed by a space, followed by the string representation of its userid. Duplicate uid
|
// start hakurei containers, followed by a space, followed by the string
|
||||||
// entries are ignored, with the first occurrence taking effect.
|
// representation of its userid. Duplicate uid entries are ignored, with the
|
||||||
|
// first occurrence taking effect.
|
||||||
//
|
//
|
||||||
// All string representations are parsed by calling parseUint32Fast.
|
// All string representations are parsed by calling parseUint32Fast.
|
||||||
func parseConfig(r io.Reader, puid uint32) (userid uint32, ok bool, err error) {
|
func parseConfig(r io.Reader, puid uint32) (userid uint32, ok bool, err error) {
|
||||||
@@ -81,10 +84,6 @@ func parseConfig(r io.Reader, puid uint32) (userid uint32, ok bool, err error) {
|
|||||||
return useridEnd + 1, false, s.Err()
|
return useridEnd + 1, false, s.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// hsuConfPath is an absolute pathname to the hsu configuration file.
|
|
||||||
// Its contents are interpreted by parseConfig.
|
|
||||||
const hsuConfPath = "/etc/hsurc"
|
|
||||||
|
|
||||||
// mustParseConfig calls parseConfig to interpret the contents of hsuConfPath,
|
// mustParseConfig calls parseConfig to interpret the contents of hsuConfPath,
|
||||||
// terminating the program if an error is encountered, the syntax is incorrect,
|
// terminating the program if an error is encountered, the syntax is incorrect,
|
||||||
// or the current user is not authorised to use hsu because its uid is missing.
|
// or the current user is not authorised to use hsu because its uid is missing.
|
||||||
@@ -112,10 +111,6 @@ func mustParseConfig(puid int) (userid uint32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// envIdentity is the name of the environment variable holding a
|
|
||||||
// string representation of the current application identity.
|
|
||||||
var envIdentity = "HAKUREI_IDENTITY"
|
|
||||||
|
|
||||||
// mustReadIdentity calls parseUint32Fast to interpret the value stored in envIdentity,
|
// mustReadIdentity calls parseUint32Fast to interpret the value stored in envIdentity,
|
||||||
// terminating the program if the value is not set, malformed, or out of bounds.
|
// terminating the program if the value is not set, malformed, or out of bounds.
|
||||||
func mustReadIdentity() uint32 {
|
func mustReadIdentity() uint32 {
|
||||||
|
|||||||
155
cmd/mbf/main.go
155
cmd/mbf/main.go
@@ -1,3 +1,15 @@
|
|||||||
|
// The mbf program is a frontend for [hakurei.app/internal/rosa].
|
||||||
|
//
|
||||||
|
// This program is not covered by the compatibility promise. The command line
|
||||||
|
// interface, available packages and their behaviour, and even the on-disk
|
||||||
|
// format, may change at any time.
|
||||||
|
//
|
||||||
|
// # Name
|
||||||
|
//
|
||||||
|
// The name mbf stands for maiden's best friend, as a tribute to the DOOM source
|
||||||
|
// port of [the same name]. This name is a placeholder and is subject to change.
|
||||||
|
//
|
||||||
|
// [the same name]: https://www.doomwiki.org/wiki/MBF
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -18,12 +30,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unique"
|
"unique"
|
||||||
|
|
||||||
|
"hakurei.app/check"
|
||||||
"hakurei.app/command"
|
"hakurei.app/command"
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
"hakurei.app/container/check"
|
|
||||||
"hakurei.app/container/fhs"
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/ext"
|
||||||
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
"hakurei.app/internal/rosa"
|
"hakurei.app/internal/rosa"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
@@ -56,11 +69,12 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
flagQuiet bool
|
flagQuiet bool
|
||||||
flagCures int
|
flagCures int
|
||||||
flagBase string
|
flagBase string
|
||||||
flagTShift int
|
flagIdle bool
|
||||||
flagIdle bool
|
|
||||||
|
flagHostAbstract bool
|
||||||
)
|
)
|
||||||
c := command.New(os.Stderr, log.Printf, "mbf", func([]string) (err error) {
|
c := command.New(os.Stderr, log.Printf, "mbf", func([]string) (err error) {
|
||||||
msg.SwapVerbose(!flagQuiet)
|
msg.SwapVerbose(!flagQuiet)
|
||||||
@@ -76,19 +90,15 @@ func main() {
|
|||||||
} else if base, err = check.NewAbs(flagBase); err != nil {
|
} else if base, err = check.NewAbs(flagBase); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if cache, err = pkg.Open(ctx, msg, flagCures, base); err == nil {
|
|
||||||
if flagTShift < 0 {
|
|
||||||
cache.SetThreshold(0)
|
|
||||||
} else if flagTShift > 31 {
|
|
||||||
cache.SetThreshold(1 << 31)
|
|
||||||
} else {
|
|
||||||
cache.SetThreshold(1 << flagTShift)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var flags int
|
||||||
if flagIdle {
|
if flagIdle {
|
||||||
pkg.SchedPolicy = container.SCHED_IDLE
|
flags |= pkg.CSchedIdle
|
||||||
}
|
}
|
||||||
|
if flagHostAbstract {
|
||||||
|
flags |= pkg.CHostAbstract
|
||||||
|
}
|
||||||
|
cache, err = pkg.Open(ctx, msg, flags, flagCures, base)
|
||||||
|
|
||||||
return
|
return
|
||||||
}).Flag(
|
}).Flag(
|
||||||
@@ -103,14 +113,17 @@ func main() {
|
|||||||
&flagBase,
|
&flagBase,
|
||||||
"d", command.StringFlag("$MBF_CACHE_DIR"),
|
"d", command.StringFlag("$MBF_CACHE_DIR"),
|
||||||
"Directory to store cured artifacts",
|
"Directory to store cured artifacts",
|
||||||
).Flag(
|
|
||||||
&flagTShift,
|
|
||||||
"tshift", command.IntFlag(-1),
|
|
||||||
"Dependency graph size exponent, to the power of 2",
|
|
||||||
).Flag(
|
).Flag(
|
||||||
&flagIdle,
|
&flagIdle,
|
||||||
"sched-idle", command.BoolFlag(false),
|
"sched-idle", command.BoolFlag(false),
|
||||||
"Set SCHED_IDLE scheduling policy",
|
"Set SCHED_IDLE scheduling policy",
|
||||||
|
).Flag(
|
||||||
|
&flagHostAbstract,
|
||||||
|
"host-abstract", command.BoolFlag(
|
||||||
|
os.Getenv("MBF_HOST_ABSTRACT") != "",
|
||||||
|
),
|
||||||
|
"Do not restrict networked cure containers from connecting to host "+
|
||||||
|
"abstract UNIX sockets",
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -175,6 +188,17 @@ func main() {
|
|||||||
fmt.Println("website : " +
|
fmt.Println("website : " +
|
||||||
strings.TrimSuffix(meta.Website, "/"))
|
strings.TrimSuffix(meta.Website, "/"))
|
||||||
}
|
}
|
||||||
|
if len(meta.Dependencies) > 0 {
|
||||||
|
fmt.Print("depends on :")
|
||||||
|
for _, d := range meta.Dependencies {
|
||||||
|
s := rosa.GetMetadata(d).Name
|
||||||
|
if version := rosa.Std.Version(d); version != rosa.Unversioned {
|
||||||
|
s += "-" + version
|
||||||
|
}
|
||||||
|
fmt.Print(" " + s)
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
const statusPrefix = "status : "
|
const statusPrefix = "status : "
|
||||||
if flagStatus {
|
if flagStatus {
|
||||||
@@ -260,7 +284,7 @@ func main() {
|
|||||||
return errors.New("report requires 1 argument")
|
return errors.New("report requires 1 argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
if container.Isatty(int(w.Fd())) {
|
if ext.Isatty(int(w.Fd())) {
|
||||||
return errors.New("output appears to be a terminal")
|
return errors.New("output appears to be a terminal")
|
||||||
}
|
}
|
||||||
return rosa.WriteReport(msg, w, cache)
|
return rosa.WriteReport(msg, w, cache)
|
||||||
@@ -423,7 +447,9 @@ func main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
var (
|
var (
|
||||||
flagDump string
|
flagDump string
|
||||||
|
flagEnter bool
|
||||||
|
flagExport string
|
||||||
)
|
)
|
||||||
c.NewCommand(
|
c.NewCommand(
|
||||||
"cure",
|
"cure",
|
||||||
@@ -432,15 +458,44 @@ func main() {
|
|||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return errors.New("cure requires 1 argument")
|
return errors.New("cure requires 1 argument")
|
||||||
}
|
}
|
||||||
if p, ok := rosa.ResolveName(args[0]); !ok {
|
p, ok := rosa.ResolveName(args[0])
|
||||||
|
if !ok {
|
||||||
return fmt.Errorf("unknown artifact %q", args[0])
|
return fmt.Errorf("unknown artifact %q", args[0])
|
||||||
} else if flagDump == "" {
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
default:
|
||||||
pathname, _, err := cache.Cure(rosa.Std.Load(p))
|
pathname, _, err := cache.Cure(rosa.Std.Load(p))
|
||||||
if err == nil {
|
if err != nil {
|
||||||
log.Println(pathname)
|
return err
|
||||||
}
|
}
|
||||||
return err
|
log.Println(pathname)
|
||||||
} else {
|
|
||||||
|
if flagExport != "" {
|
||||||
|
msg.Verbosef("exporting %s to %s...", args[0], flagExport)
|
||||||
|
|
||||||
|
var f *os.File
|
||||||
|
if f, err = os.OpenFile(
|
||||||
|
flagExport,
|
||||||
|
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
|
||||||
|
0400,
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
} else if _, err = pkg.Flatten(
|
||||||
|
os.DirFS(pathname.String()),
|
||||||
|
".",
|
||||||
|
f,
|
||||||
|
); err != nil {
|
||||||
|
_ = f.Close()
|
||||||
|
return err
|
||||||
|
} else if err = f.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
case flagDump != "":
|
||||||
f, err := os.OpenFile(
|
f, err := os.OpenFile(
|
||||||
flagDump,
|
flagDump,
|
||||||
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
|
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
|
||||||
@@ -456,6 +511,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return f.Close()
|
return f.Close()
|
||||||
|
|
||||||
|
case flagEnter:
|
||||||
|
return cache.EnterExec(
|
||||||
|
ctx,
|
||||||
|
rosa.Std.Load(p),
|
||||||
|
true, os.Stdin, os.Stdout, os.Stderr,
|
||||||
|
rosa.AbsSystem.Append("bin", "mksh"),
|
||||||
|
"sh",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
).
|
).
|
||||||
@@ -463,6 +527,16 @@ func main() {
|
|||||||
&flagDump,
|
&flagDump,
|
||||||
"dump", command.StringFlag(""),
|
"dump", command.StringFlag(""),
|
||||||
"Write IR to specified pathname and terminate",
|
"Write IR to specified pathname and terminate",
|
||||||
|
).
|
||||||
|
Flag(
|
||||||
|
&flagExport,
|
||||||
|
"export", command.StringFlag(""),
|
||||||
|
"Export cured artifact to specified pathname",
|
||||||
|
).
|
||||||
|
Flag(
|
||||||
|
&flagEnter,
|
||||||
|
"enter", command.BoolFlag(false),
|
||||||
|
"Enter cure container with an interactive shell",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,17 +551,19 @@ func main() {
|
|||||||
"shell",
|
"shell",
|
||||||
"Interactive shell in the specified Rosa OS environment",
|
"Interactive shell in the specified Rosa OS environment",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
root := make([]pkg.Artifact, 0, 6+len(args))
|
presets := make([]rosa.PArtifact, len(args))
|
||||||
for _, arg := range args {
|
for i, arg := range args {
|
||||||
p, ok := rosa.ResolveName(arg)
|
p, ok := rosa.ResolveName(arg)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unknown artifact %q", arg)
|
return fmt.Errorf("unknown artifact %q", arg)
|
||||||
}
|
}
|
||||||
root = append(root, rosa.Std.Load(p))
|
presets[i] = p
|
||||||
}
|
}
|
||||||
|
root := make(pkg.Collect, 0, 6+len(args))
|
||||||
|
root = rosa.Std.AppendPresets(root, presets...)
|
||||||
|
|
||||||
if flagWithToolchain {
|
if flagWithToolchain {
|
||||||
musl, compilerRT, runtimes, clang := rosa.Std.NewLLVM()
|
musl, compilerRT, runtimes, clang := (rosa.Std - 1).NewLLVM()
|
||||||
root = append(root, musl, compilerRT, runtimes, clang)
|
root = append(root, musl, compilerRT, runtimes, clang)
|
||||||
} else {
|
} else {
|
||||||
root = append(root, rosa.Std.Load(rosa.Musl))
|
root = append(root, rosa.Std.Load(rosa.Musl))
|
||||||
@@ -497,6 +573,12 @@ func main() {
|
|||||||
rosa.Std.Load(rosa.Toybox),
|
rosa.Std.Load(rosa.Toybox),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if _, _, err := cache.Cure(&root); err == nil {
|
||||||
|
return errors.New("unreachable")
|
||||||
|
} else if !pkg.IsCollected(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
type cureRes struct {
|
type cureRes struct {
|
||||||
pathname *check.Absolute
|
pathname *check.Absolute
|
||||||
checksum unique.Handle[pkg.Checksum]
|
checksum unique.Handle[pkg.Checksum]
|
||||||
@@ -536,6 +618,9 @@ func main() {
|
|||||||
z.Hostname = "localhost"
|
z.Hostname = "localhost"
|
||||||
z.Uid, z.Gid = (1<<10)-1, (1<<10)-1
|
z.Uid, z.Gid = (1<<10)-1, (1<<10)-1
|
||||||
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
|
if s, ok := os.LookupEnv("TERM"); ok {
|
||||||
|
z.Env = append(z.Env, "TERM="+s)
|
||||||
|
}
|
||||||
|
|
||||||
var tempdir *check.Absolute
|
var tempdir *check.Absolute
|
||||||
if s, err := filepath.Abs(os.TempDir()); err != nil {
|
if s, err := filepath.Abs(os.TempDir()); err != nil {
|
||||||
@@ -586,13 +671,13 @@ func main() {
|
|||||||
).
|
).
|
||||||
Flag(
|
Flag(
|
||||||
&flagSession,
|
&flagSession,
|
||||||
"session", command.BoolFlag(false),
|
"session", command.BoolFlag(true),
|
||||||
"Retain session",
|
"Retain session",
|
||||||
).
|
).
|
||||||
Flag(
|
Flag(
|
||||||
&flagWithToolchain,
|
&flagWithToolchain,
|
||||||
"with-toolchain", command.BoolFlag(false),
|
"with-toolchain", command.BoolFlag(false),
|
||||||
"Include the stage3 LLVM toolchain",
|
"Include the stage2 LLVM toolchain",
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SHAREFS_MEDIA_RW_ID (1 << 10) - 1 /* owning gid presented to userspace */
|
#define SHAREFS_MEDIA_RW_ID (1 << 10) - 1 /* owning gid presented to userspace */
|
||||||
#define SHAREFS_PERM_DIR 0700 /* permission bits for directories presented to userspace */
|
#define SHAREFS_PERM_DIR 0770 /* permission bits for directories presented to userspace */
|
||||||
#define SHAREFS_PERM_REG 0600 /* permission bits for regular files presented to userspace */
|
#define SHAREFS_PERM_REG 0660 /* permission bits for regular files presented to userspace */
|
||||||
#define SHAREFS_FORBIDDEN_FLAGS O_DIRECT /* these open flags are cleared unconditionally */
|
#define SHAREFS_FORBIDDEN_FLAGS O_DIRECT /* these open flags are cleared unconditionally */
|
||||||
|
|
||||||
/* sharefs_private is populated by sharefs_init and contains process-wide context */
|
/* sharefs_private is populated by sharefs_init and contains process-wide context */
|
||||||
|
|||||||
@@ -19,22 +19,21 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/cgo"
|
"runtime/cgo"
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"hakurei.app/check"
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
"hakurei.app/container/check"
|
|
||||||
"hakurei.app/container/fhs"
|
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/hst"
|
"hakurei.app/hst"
|
||||||
"hakurei.app/internal/helper/proc"
|
"hakurei.app/internal/helper/proc"
|
||||||
"hakurei.app/internal/info"
|
"hakurei.app/internal/info"
|
||||||
@@ -85,7 +84,10 @@ func destroySetup(private_data unsafe.Pointer) (ok bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export sharefs_init
|
//export sharefs_init
|
||||||
func sharefs_init(_ *C.struct_fuse_conn_info, cfg *C.struct_fuse_config) unsafe.Pointer {
|
func sharefs_init(
|
||||||
|
_ *C.struct_fuse_conn_info,
|
||||||
|
cfg *C.struct_fuse_config,
|
||||||
|
) unsafe.Pointer {
|
||||||
ctx := C.fuse_get_context()
|
ctx := C.fuse_get_context()
|
||||||
priv := (*C.struct_sharefs_private)(ctx.private_data)
|
priv := (*C.struct_sharefs_private)(ctx.private_data)
|
||||||
setup := cgo.Handle(priv.setup).Value().(*setupState)
|
setup := cgo.Handle(priv.setup).Value().(*setupState)
|
||||||
@@ -103,7 +105,11 @@ func sharefs_init(_ *C.struct_fuse_conn_info, cfg *C.struct_fuse_config) unsafe.
|
|||||||
cfg.negative_timeout = 0
|
cfg.negative_timeout = 0
|
||||||
|
|
||||||
// all future filesystem operations happen through this dirfd
|
// all future filesystem operations happen through this dirfd
|
||||||
if fd, err := syscall.Open(setup.Source.String(), syscall.O_DIRECTORY|syscall.O_RDONLY|syscall.O_CLOEXEC, 0); err != nil {
|
if fd, err := syscall.Open(
|
||||||
|
setup.Source.String(),
|
||||||
|
syscall.O_DIRECTORY|syscall.O_RDONLY|syscall.O_CLOEXEC,
|
||||||
|
0,
|
||||||
|
); err != nil {
|
||||||
log.Printf("cannot open %q: %v", setup.Source, err)
|
log.Printf("cannot open %q: %v", setup.Source, err)
|
||||||
goto fail
|
goto fail
|
||||||
} else if err = syscall.Fchdir(fd); err != nil {
|
} else if err = syscall.Fchdir(fd); err != nil {
|
||||||
@@ -138,9 +144,9 @@ func sharefs_destroy(private_data unsafe.Pointer) {
|
|||||||
func showHelp(args *fuseArgs) {
|
func showHelp(args *fuseArgs) {
|
||||||
executableName := sharefsName
|
executableName := sharefsName
|
||||||
if args.argc > 0 {
|
if args.argc > 0 {
|
||||||
executableName = path.Base(C.GoString(*args.argv))
|
executableName = filepath.Base(C.GoString(*args.argv))
|
||||||
} else if name, err := os.Executable(); err == nil {
|
} else if name, err := os.Executable(); err == nil {
|
||||||
executableName = path.Base(name)
|
executableName = filepath.Base(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("usage: %s [options] <mountpoint>\n\n", executableName)
|
fmt.Printf("usage: %s [options] <mountpoint>\n\n", executableName)
|
||||||
@@ -169,8 +175,11 @@ func parseOpts(args *fuseArgs, setup *setupState, log *log.Logger) (ok bool) {
|
|||||||
// Decimal string representation of gid to set when running as root.
|
// Decimal string representation of gid to set when running as root.
|
||||||
setgid *C.char
|
setgid *C.char
|
||||||
|
|
||||||
// Decimal string representation of open file descriptor to read setupState from.
|
// Decimal string representation of open file descriptor to read
|
||||||
// This is an internal detail for containerisation and must not be specified directly.
|
// setupState from.
|
||||||
|
//
|
||||||
|
// This is an internal detail for containerisation and must not be
|
||||||
|
// specified directly.
|
||||||
setup *C.char
|
setup *C.char
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +262,8 @@ func parseOpts(args *fuseArgs, setup *setupState, log *log.Logger) (ok bool) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyArgs returns a heap allocated copy of an argument slice in fuse_args representation.
|
// copyArgs returns a heap allocated copy of an argument slice in fuse_args
|
||||||
|
// representation.
|
||||||
func copyArgs(s ...string) fuseArgs {
|
func copyArgs(s ...string) fuseArgs {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return fuseArgs{argc: 0, argv: nil, allocated: 0}
|
return fuseArgs{argc: 0, argv: nil, allocated: 0}
|
||||||
@@ -269,6 +279,7 @@ func copyArgs(s ...string) fuseArgs {
|
|||||||
func freeArgs(args *fuseArgs) { C.fuse_opt_free_args(args) }
|
func freeArgs(args *fuseArgs) { C.fuse_opt_free_args(args) }
|
||||||
|
|
||||||
// unsafeAddArgument adds an argument to fuseArgs via fuse_opt_add_arg.
|
// unsafeAddArgument adds an argument to fuseArgs via fuse_opt_add_arg.
|
||||||
|
//
|
||||||
// The last byte of arg must be 0.
|
// The last byte of arg must be 0.
|
||||||
func unsafeAddArgument(args *fuseArgs, arg string) {
|
func unsafeAddArgument(args *fuseArgs, arg string) {
|
||||||
C.fuse_opt_add_arg(args, (*C.char)(unsafe.Pointer(unsafe.StringData(arg))))
|
C.fuse_opt_add_arg(args, (*C.char)(unsafe.Pointer(unsafe.StringData(arg))))
|
||||||
@@ -288,8 +299,8 @@ func _main(s ...string) (exitCode int) {
|
|||||||
args := copyArgs(s...)
|
args := copyArgs(s...)
|
||||||
defer freeArgs(&args)
|
defer freeArgs(&args)
|
||||||
|
|
||||||
// this causes the kernel to enforce access control based on
|
// this causes the kernel to enforce access control based on struct stat
|
||||||
// struct stat populated by sharefs_getattr
|
// populated by sharefs_getattr
|
||||||
unsafeAddArgument(&args, "-odefault_permissions\x00")
|
unsafeAddArgument(&args, "-odefault_permissions\x00")
|
||||||
|
|
||||||
var priv C.struct_sharefs_private
|
var priv C.struct_sharefs_private
|
||||||
@@ -453,15 +464,19 @@ func _main(s ...string) (exitCode int) {
|
|||||||
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
z.Stdin, z.Stdout, z.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
}
|
}
|
||||||
z.Bind(z.Path, z.Path, 0)
|
z.Bind(z.Path, z.Path, 0)
|
||||||
setup.Fuse = int(proc.ExtraFileSlice(&z.ExtraFiles, os.NewFile(uintptr(C.fuse_session_fd(se)), "fuse")))
|
setup.Fuse = int(proc.ExtraFileSlice(
|
||||||
|
&z.ExtraFiles,
|
||||||
|
os.NewFile(uintptr(C.fuse_session_fd(se)), "fuse"),
|
||||||
|
))
|
||||||
|
|
||||||
var setupWriter io.WriteCloser
|
var setupPipe [2]*os.File
|
||||||
if fd, w, err := container.Setup(&z.ExtraFiles); err != nil {
|
if r, w, err := os.Pipe(); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return 5
|
return 5
|
||||||
} else {
|
} else {
|
||||||
z.Args = append(z.Args, "-osetup="+strconv.Itoa(fd))
|
z.Args = append(z.Args, "-osetup="+strconv.Itoa(3+len(z.ExtraFiles)))
|
||||||
setupWriter = w
|
z.ExtraFiles = append(z.ExtraFiles, r)
|
||||||
|
setupPipe[0], setupPipe[1] = r, w
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := z.Start(); err != nil {
|
if err := z.Start(); err != nil {
|
||||||
@@ -472,6 +487,9 @@ func _main(s ...string) (exitCode int) {
|
|||||||
}
|
}
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
if err := setupPipe[0].Close(); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
if err := z.Serve(); err != nil {
|
if err := z.Serve(); err != nil {
|
||||||
if m, ok := message.GetMessage(err); ok {
|
if m, ok := message.GetMessage(err); ok {
|
||||||
log.Println(m)
|
log.Println(m)
|
||||||
@@ -481,10 +499,10 @@ func _main(s ...string) (exitCode int) {
|
|||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gob.NewEncoder(setupWriter).Encode(&setup); err != nil {
|
if err := gob.NewEncoder(setupPipe[1]).Encode(&setup); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return 5
|
return 5
|
||||||
} else if err = setupWriter.Close(); err != nil {
|
} else if err = setupPipe[1].Close(); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseOpts(t *testing.T) {
|
func TestParseOpts(t *testing.T) {
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
// The sharefs FUSE filesystem is a permissionless shared filesystem.
|
||||||
|
//
|
||||||
|
// This filesystem is the primary means of file sharing between hakurei
|
||||||
|
// application containers. It serves the same purpose in Rosa OS as /sdcard
|
||||||
|
// does in AOSP.
|
||||||
|
//
|
||||||
|
// See help message for all available options.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
122
cmd/sharefs/test/raceattr.go
Normal file
122
cmd/sharefs/test/raceattr.go
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
//go:build raceattr
|
||||||
|
|
||||||
|
// The raceattr program reproduces vfs inode file attribute race.
|
||||||
|
//
|
||||||
|
// Even though libfuse high-level API presents the address of a struct stat
|
||||||
|
// alongside struct fuse_context, file attributes are actually inherent to the
|
||||||
|
// inode, instead of the specific call from userspace. The kernel implementation
|
||||||
|
// in fs/fuse/xattr.c appears to make stale data in the inode (set by a previous
|
||||||
|
// call) impossible or very unlikely to reach userspace via the stat family of
|
||||||
|
// syscalls. However, when using default_permissions to have the VFS check
|
||||||
|
// permissions, this race still happens, despite the resulting struct stat being
|
||||||
|
// correct when overriding the check via capabilities otherwise.
|
||||||
|
//
|
||||||
|
// This program reproduces the failure, but because of its continuous nature, it
|
||||||
|
// is provided independent of the vm integration test suite.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newStatAs(
|
||||||
|
ctx context.Context, cancel context.CancelFunc,
|
||||||
|
n *atomic.Uint64, ok *atomic.Bool,
|
||||||
|
uid uint32, pathname string,
|
||||||
|
continuous bool,
|
||||||
|
) func() {
|
||||||
|
return func() {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if _, _, errno := syscall.Syscall(
|
||||||
|
syscall.SYS_SETUID, uintptr(uid),
|
||||||
|
0, 0,
|
||||||
|
); errno != 0 {
|
||||||
|
cancel()
|
||||||
|
log.Printf("cannot set uid to %d: %s", uid, errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
var stat syscall.Stat_t
|
||||||
|
for {
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := syscall.Lstat(pathname, &stat); err != nil {
|
||||||
|
// SHAREFS_PERM_DIR not world executable, or
|
||||||
|
// SHAREFS_PERM_REG not world readable
|
||||||
|
if !continuous {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
ok.Store(true)
|
||||||
|
log.Printf("uid %d: %v", uid, err)
|
||||||
|
} else if stat.Uid != uid {
|
||||||
|
// appears to be unreachable
|
||||||
|
if !continuous {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
ok.Store(true)
|
||||||
|
log.Printf("got uid %d instead of %d", stat.Uid, uid)
|
||||||
|
}
|
||||||
|
n.Add(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.SetFlags(0)
|
||||||
|
log.SetPrefix("raceattr: ")
|
||||||
|
|
||||||
|
p := flag.String("target", "/sdcard/raceattr", "pathname of test file")
|
||||||
|
u0 := flag.Int("uid0", 1<<10-1, "first uid")
|
||||||
|
u1 := flag.Int("uid1", 1<<10-2, "second uid")
|
||||||
|
count := flag.Int("count", 1, "threads per uid")
|
||||||
|
continuous := flag.Bool("continuous", false, "keep running even after reproduce")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
log.Fatal("this program must run as root")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := signal.NotifyContext(
|
||||||
|
context.Background(),
|
||||||
|
syscall.SIGINT,
|
||||||
|
syscall.SIGTERM,
|
||||||
|
syscall.SIGHUP,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := os.WriteFile(*p, nil, 0); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
n atomic.Uint64
|
||||||
|
ok atomic.Bool
|
||||||
|
)
|
||||||
|
|
||||||
|
if *count < 1 {
|
||||||
|
*count = 1
|
||||||
|
}
|
||||||
|
for range *count {
|
||||||
|
wg.Go(newStatAs(ctx, cancel, &n, &ok, uint32(*u0), *p, *continuous))
|
||||||
|
if *u1 >= 0 {
|
||||||
|
wg.Go(newStatAs(ctx, cancel, &n, &ok, uint32(*u1), *p, *continuous))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
if !*continuous && ok.Load() {
|
||||||
|
log.Printf("reproduced after %d calls", n.Load())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(AutoEtcOp)) }
|
func init() { gob.Register(new(AutoEtcOp)) }
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAutoEtcOp(t *testing.T) {
|
func TestAutoEtcOp(t *testing.T) {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package container
|
|||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -51,15 +53,15 @@ func capset(hdrp *capHeader, datap *[2]capData) error {
|
|||||||
|
|
||||||
// capBoundingSetDrop drops a capability from the calling thread's capability bounding set.
|
// capBoundingSetDrop drops a capability from the calling thread's capability bounding set.
|
||||||
func capBoundingSetDrop(cap uintptr) error {
|
func capBoundingSetDrop(cap uintptr) error {
|
||||||
return Prctl(syscall.PR_CAPBSET_DROP, cap, 0)
|
return ext.Prctl(syscall.PR_CAPBSET_DROP, cap, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// capAmbientClearAll clears the ambient capability set of the calling thread.
|
// capAmbientClearAll clears the ambient capability set of the calling thread.
|
||||||
func capAmbientClearAll() error {
|
func capAmbientClearAll() error {
|
||||||
return Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0)
|
return ext.Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// capAmbientRaise adds to the ambient capability set of the calling thread.
|
// capAmbientRaise adds to the ambient capability set of the calling thread.
|
||||||
func capAmbientRaise(cap uintptr) error {
|
func capAmbientRaise(cap uintptr) error {
|
||||||
return Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap)
|
return ext.Prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ import (
|
|||||||
. "syscall"
|
. "syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/ext"
|
||||||
|
"hakurei.app/fhs"
|
||||||
|
"hakurei.app/internal/landlock"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,9 +29,6 @@ const (
|
|||||||
// CancelSignal is the signal expected by container init on context cancel.
|
// CancelSignal is the signal expected by container init on context cancel.
|
||||||
// A custom [Container.Cancel] function must eventually deliver this signal.
|
// A custom [Container.Cancel] function must eventually deliver this signal.
|
||||||
CancelSignal = SIGUSR2
|
CancelSignal = SIGUSR2
|
||||||
|
|
||||||
// Timeout for writing initParams to Container.setup.
|
|
||||||
initSetupTimeout = 5 * time.Second
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -38,9 +37,13 @@ type (
|
|||||||
Container struct {
|
Container struct {
|
||||||
// Whether the container init should stay alive after its parent terminates.
|
// Whether the container init should stay alive after its parent terminates.
|
||||||
AllowOrphan bool
|
AllowOrphan bool
|
||||||
// Scheduling policy to set via sched_setscheduler(2). The zero value
|
// Whether to set SchedPolicy and SchedPriority via sched_setscheduler(2).
|
||||||
// skips this call. Supported policies are [SCHED_BATCH], [SCHED_IDLE].
|
SetScheduler bool
|
||||||
SchedPolicy SchedPolicy
|
// Scheduling policy to set via sched_setscheduler(2).
|
||||||
|
SchedPolicy ext.SchedPolicy
|
||||||
|
// Scheduling priority to set via sched_setscheduler(2). The zero value
|
||||||
|
// implies the minimum value supported by the current SchedPolicy.
|
||||||
|
SchedPriority ext.Int
|
||||||
// Cgroup fd, nil to disable.
|
// Cgroup fd, nil to disable.
|
||||||
Cgroup *int
|
Cgroup *int
|
||||||
// ExtraFiles passed through to initial process in the container, with
|
// ExtraFiles passed through to initial process in the container, with
|
||||||
@@ -48,7 +51,7 @@ type (
|
|||||||
ExtraFiles []*os.File
|
ExtraFiles []*os.File
|
||||||
|
|
||||||
// Write end of a pipe connected to the init to deliver [Params].
|
// Write end of a pipe connected to the init to deliver [Params].
|
||||||
setup *os.File
|
setup [2]*os.File
|
||||||
// Cancels the context passed to the underlying cmd.
|
// Cancels the context passed to the underlying cmd.
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
// Closed after Wait returns. Keeps the spawning thread alive.
|
// Closed after Wait returns. Keeps the spawning thread alive.
|
||||||
@@ -181,31 +184,24 @@ var (
|
|||||||
closeOnExecErr error
|
closeOnExecErr error
|
||||||
)
|
)
|
||||||
|
|
||||||
// ensureCloseOnExec ensures all currently open file descriptors have the syscall.FD_CLOEXEC flag set.
|
// ensureCloseOnExec ensures all currently open file descriptors have the
|
||||||
// This is only ran once as it is intended to handle files left open by the parent, and any file opened
|
// syscall.FD_CLOEXEC flag set.
|
||||||
// on this side should already have syscall.FD_CLOEXEC set.
|
//
|
||||||
|
// This is only ran once as it is intended to handle files left open by the
|
||||||
|
// parent, and any file opened on this side should already have
|
||||||
|
// syscall.FD_CLOEXEC set.
|
||||||
func ensureCloseOnExec() error {
|
func ensureCloseOnExec() error {
|
||||||
closeOnExecOnce.Do(func() {
|
closeOnExecOnce.Do(func() { closeOnExecErr = doCloseOnExec() })
|
||||||
const fdPrefixPath = "/proc/self/fd/"
|
|
||||||
|
|
||||||
var entries []os.DirEntry
|
|
||||||
if entries, closeOnExecErr = os.ReadDir(fdPrefixPath); closeOnExecErr != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var fd int
|
|
||||||
for _, ent := range entries {
|
|
||||||
if fd, closeOnExecErr = strconv.Atoi(ent.Name()); closeOnExecErr != nil {
|
|
||||||
break // not reached
|
|
||||||
}
|
|
||||||
CloseOnExec(fd)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if closeOnExecErr == nil {
|
if closeOnExecErr == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &StartError{Fatal: true, Step: "set FD_CLOEXEC on all open files", Err: closeOnExecErr, Passthrough: true}
|
return &StartError{
|
||||||
|
Fatal: true,
|
||||||
|
Step: "set FD_CLOEXEC on all open files",
|
||||||
|
Err: closeOnExecErr,
|
||||||
|
Passthrough: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start starts the container init. The init process blocks until Serve is called.
|
// Start starts the container init. The init process blocks until Serve is called.
|
||||||
@@ -289,14 +285,16 @@ func (p *Container) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// place setup pipe before user supplied extra files, this is later restored by init
|
// place setup pipe before user supplied extra files, this is later restored by init
|
||||||
if fd, f, err := Setup(&p.cmd.ExtraFiles); err != nil {
|
if r, w, err := os.Pipe(); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
Step: "set up params stream",
|
Step: "set up params stream",
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.setup = f
|
fd := 3 + len(p.cmd.ExtraFiles)
|
||||||
|
p.cmd.ExtraFiles = append(p.cmd.ExtraFiles, r)
|
||||||
|
p.setup[0], p.setup[1] = r, w
|
||||||
p.cmd.Env = []string{setupEnv + "=" + strconv.Itoa(fd)}
|
p.cmd.Env = []string{setupEnv + "=" + strconv.Itoa(fd)}
|
||||||
}
|
}
|
||||||
p.cmd.ExtraFiles = append(p.cmd.ExtraFiles, p.ExtraFiles...)
|
p.cmd.ExtraFiles = append(p.cmd.ExtraFiles, p.ExtraFiles...)
|
||||||
@@ -310,7 +308,7 @@ func (p *Container) Start() error {
|
|||||||
done <- func() error {
|
done <- func() error {
|
||||||
// PR_SET_NO_NEW_PRIVS: thread-directed but acts on all processes
|
// PR_SET_NO_NEW_PRIVS: thread-directed but acts on all processes
|
||||||
// created from the calling thread
|
// created from the calling thread
|
||||||
if err := SetNoNewPrivs(); err != nil {
|
if err := setNoNewPrivs(); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
Step: "prctl(PR_SET_NO_NEW_PRIVS)",
|
Step: "prctl(PR_SET_NO_NEW_PRIVS)",
|
||||||
@@ -320,15 +318,17 @@ func (p *Container) Start() error {
|
|||||||
|
|
||||||
// landlock: depends on per-thread state but acts on a process group
|
// landlock: depends on per-thread state but acts on a process group
|
||||||
{
|
{
|
||||||
rulesetAttr := &RulesetAttr{Scoped: LANDLOCK_SCOPE_SIGNAL}
|
rulesetAttr := &landlock.RulesetAttr{
|
||||||
|
Scoped: landlock.LANDLOCK_SCOPE_SIGNAL,
|
||||||
|
}
|
||||||
if !p.HostAbstract {
|
if !p.HostAbstract {
|
||||||
rulesetAttr.Scoped |= LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET
|
rulesetAttr.Scoped |= landlock.LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET
|
||||||
}
|
}
|
||||||
|
|
||||||
if abi, err := LandlockGetABI(); err != nil {
|
if abi, err := landlock.GetABI(); err != nil {
|
||||||
if p.HostAbstract {
|
if p.HostAbstract || !p.HostNet {
|
||||||
// landlock can be skipped here as it restricts access
|
// landlock can be skipped here as it restricts access
|
||||||
// to resources already covered by namespaces (pid)
|
// to resources already covered by namespaces (pid, net)
|
||||||
goto landlockOut
|
goto landlockOut
|
||||||
}
|
}
|
||||||
return &StartError{Step: "get landlock ABI", Err: err}
|
return &StartError{Step: "get landlock ABI", Err: err}
|
||||||
@@ -354,7 +354,7 @@ func (p *Container) Start() error {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.msg.Verbosef("enforcing landlock ruleset %s", rulesetAttr)
|
p.msg.Verbosef("enforcing landlock ruleset %s", rulesetAttr)
|
||||||
if err = LandlockRestrictSelf(rulesetFd, 0); err != nil {
|
if err = landlock.RestrictSelf(rulesetFd, 0); err != nil {
|
||||||
_ = Close(rulesetFd)
|
_ = Close(rulesetFd)
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
@@ -373,7 +373,15 @@ func (p *Container) Start() error {
|
|||||||
|
|
||||||
// sched_setscheduler: thread-directed but acts on all processes
|
// sched_setscheduler: thread-directed but acts on all processes
|
||||||
// created from the calling thread
|
// created from the calling thread
|
||||||
if p.SchedPolicy > 0 && p.SchedPolicy <= _SCHED_LAST {
|
if p.SetScheduler {
|
||||||
|
if p.SchedPolicy < 0 || p.SchedPolicy > ext.SCHED_LAST {
|
||||||
|
return &StartError{
|
||||||
|
Fatal: false,
|
||||||
|
Step: "set scheduling policy",
|
||||||
|
Err: EINVAL,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var param schedParam
|
var param schedParam
|
||||||
if priority, err := p.SchedPolicy.GetPriorityMin(); err != nil {
|
if priority, err := p.SchedPolicy.GetPriorityMin(); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
@@ -382,10 +390,13 @@ func (p *Container) Start() error {
|
|||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
param.priority = priority
|
param.priority = max(priority, p.SchedPriority)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.msg.Verbosef("setting scheduling policy %d", p.SchedPolicy)
|
p.msg.Verbosef(
|
||||||
|
"setting scheduling policy %s priority %d",
|
||||||
|
p.SchedPolicy, param.priority,
|
||||||
|
)
|
||||||
if err := schedSetscheduler(
|
if err := schedSetscheduler(
|
||||||
0, // calling thread
|
0, // calling thread
|
||||||
p.SchedPolicy,
|
p.SchedPolicy,
|
||||||
@@ -393,7 +404,7 @@ func (p *Container) Start() error {
|
|||||||
); err != nil {
|
); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
Step: "enforce landlock ruleset",
|
Step: "set scheduling policy",
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,24 +430,33 @@ func (p *Container) Start() error {
|
|||||||
// Serve serves [Container.Params] to the container init.
|
// Serve serves [Container.Params] to the container init.
|
||||||
//
|
//
|
||||||
// Serve must only be called once.
|
// Serve must only be called once.
|
||||||
func (p *Container) Serve() error {
|
func (p *Container) Serve() (err error) {
|
||||||
if p.setup == nil {
|
if p.setup[0] == nil || p.setup[1] == nil {
|
||||||
panic("invalid serve")
|
panic("invalid serve")
|
||||||
}
|
}
|
||||||
|
|
||||||
setup := p.setup
|
done := make(chan struct{})
|
||||||
p.setup = nil
|
defer func() {
|
||||||
if err := setup.SetDeadline(time.Now().Add(initSetupTimeout)); err != nil {
|
if closeErr := p.setup[1].Close(); err == nil {
|
||||||
|
err = closeErr
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
p.cancel()
|
||||||
|
}
|
||||||
|
close(done)
|
||||||
|
p.setup[0], p.setup[1] = nil, nil
|
||||||
|
}()
|
||||||
|
if err = p.setup[0].Close(); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
Step: "set init pipe deadline",
|
Step: "close read end of init pipe",
|
||||||
Err: err,
|
Err: err,
|
||||||
Passthrough: true,
|
Passthrough: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Path == nil {
|
if p.Path == nil {
|
||||||
p.cancel()
|
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Step: "invalid executable pathname",
|
Step: "invalid executable pathname",
|
||||||
Err: EINVAL,
|
Err: EINVAL,
|
||||||
@@ -452,18 +472,27 @@ func (p *Container) Serve() error {
|
|||||||
p.SeccompRules = make([]std.NativeRule, 0)
|
p.SeccompRules = make([]std.NativeRule, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := gob.NewEncoder(setup).Encode(&initParams{
|
t := time.Now().UTC()
|
||||||
|
go func(f *os.File) {
|
||||||
|
select {
|
||||||
|
case <-p.ctx.Done():
|
||||||
|
if cancelErr := f.SetWriteDeadline(t); cancelErr != nil {
|
||||||
|
p.msg.Verbose(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
case <-done:
|
||||||
|
p.msg.Verbose("setup payload took", time.Since(t))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}(p.setup[1])
|
||||||
|
|
||||||
|
return gob.NewEncoder(p.setup[1]).Encode(&initParams{
|
||||||
p.Params,
|
p.Params,
|
||||||
Getuid(),
|
Getuid(),
|
||||||
Getgid(),
|
Getgid(),
|
||||||
len(p.ExtraFiles),
|
len(p.ExtraFiles),
|
||||||
p.msg.IsVerbose(),
|
p.msg.IsVerbose(),
|
||||||
})
|
})
|
||||||
_ = setup.Close()
|
|
||||||
if err != nil {
|
|
||||||
p.cancel()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait blocks until the container init process to exit and releases any
|
// Wait blocks until the container init process to exit and releases any
|
||||||
|
|||||||
@@ -16,18 +16,21 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
|
"hakurei.app/check"
|
||||||
"hakurei.app/command"
|
"hakurei.app/command"
|
||||||
"hakurei.app/container"
|
"hakurei.app/container"
|
||||||
"hakurei.app/container/check"
|
|
||||||
"hakurei.app/container/fhs"
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/ext"
|
||||||
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/hst"
|
"hakurei.app/hst"
|
||||||
|
"hakurei.app/internal/info"
|
||||||
|
"hakurei.app/internal/landlock"
|
||||||
|
"hakurei.app/internal/params"
|
||||||
"hakurei.app/ldd"
|
"hakurei.app/ldd"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Note: this package requires cgo, which is unavailable in the Go playground.
|
// Note: this package requires cgo, which is unavailable in the Go playground.
|
||||||
@@ -83,9 +86,9 @@ func TestStartError(t *testing.T) {
|
|||||||
{"params env", &container.StartError{
|
{"params env", &container.StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
Step: "set up params stream",
|
Step: "set up params stream",
|
||||||
Err: container.ErrReceiveEnv,
|
Err: params.ErrReceiveEnv,
|
||||||
}, "set up params stream: environment variable not set",
|
}, "set up params stream: environment variable not set",
|
||||||
container.ErrReceiveEnv, syscall.EBADF,
|
params.ErrReceiveEnv, syscall.EBADF,
|
||||||
"cannot set up params stream: environment variable not set"},
|
"cannot set up params stream: environment variable not set"},
|
||||||
|
|
||||||
{"params", &container.StartError{
|
{"params", &container.StartError{
|
||||||
@@ -258,7 +261,7 @@ var containerTestCases = []struct {
|
|||||||
1000, 100, nil, 0, std.PresetExt},
|
1000, 100, nil, 0, std.PresetExt},
|
||||||
{"custom rules", true, true, true, false,
|
{"custom rules", true, true, true, false,
|
||||||
emptyOps, emptyMnt,
|
emptyOps, emptyMnt,
|
||||||
1, 31, []std.NativeRule{{Syscall: std.ScmpSyscall(syscall.SYS_SETUID), Errno: std.ScmpErrno(syscall.EPERM)}}, 0, std.PresetExt},
|
1, 31, []std.NativeRule{{Syscall: ext.SyscallNum(syscall.SYS_SETUID), Errno: std.ScmpErrno(syscall.EPERM)}}, 0, std.PresetExt},
|
||||||
|
|
||||||
{"tmpfs", true, false, false, true,
|
{"tmpfs", true, false, false, true,
|
||||||
earlyOps(new(container.Ops).
|
earlyOps(new(container.Ops).
|
||||||
@@ -435,11 +438,8 @@ func TestContainer(t *testing.T) {
|
|||||||
wantOps, wantOpsCtx := tc.ops(t)
|
wantOps, wantOpsCtx := tc.ops(t)
|
||||||
wantMnt := tc.mnt(t, wantOpsCtx)
|
wantMnt := tc.mnt(t, wantOpsCtx)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(t.Context(), helperDefaultTimeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
var libPaths []*check.Absolute
|
var libPaths []*check.Absolute
|
||||||
c := helperNewContainerLibPaths(ctx, &libPaths, "container", strconv.Itoa(i))
|
c := helperNewContainerLibPaths(t.Context(), &libPaths, "container", strconv.Itoa(i))
|
||||||
c.Uid = tc.uid
|
c.Uid = tc.uid
|
||||||
c.Gid = tc.gid
|
c.Gid = tc.gid
|
||||||
c.Hostname = hostnameFromTestCase(tc.name)
|
c.Hostname = hostnameFromTestCase(tc.name)
|
||||||
@@ -449,7 +449,6 @@ func TestContainer(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
c.Stdout, c.Stderr = os.Stdout, os.Stderr
|
c.Stdout, c.Stderr = os.Stdout, os.Stderr
|
||||||
}
|
}
|
||||||
c.WaitDelay = helperDefaultTimeout
|
|
||||||
*c.Ops = append(*c.Ops, *wantOps...)
|
*c.Ops = append(*c.Ops, *wantOps...)
|
||||||
c.SeccompRules = tc.rules
|
c.SeccompRules = tc.rules
|
||||||
c.SeccompFlags = tc.flags | seccomp.AllowMultiarch
|
c.SeccompFlags = tc.flags | seccomp.AllowMultiarch
|
||||||
@@ -457,6 +456,15 @@ func TestContainer(t *testing.T) {
|
|||||||
c.SeccompDisable = !tc.filter
|
c.SeccompDisable = !tc.filter
|
||||||
c.RetainSession = tc.session
|
c.RetainSession = tc.session
|
||||||
c.HostNet = tc.net
|
c.HostNet = tc.net
|
||||||
|
if info.CanDegrade {
|
||||||
|
if _, err := landlock.GetABI(); err != nil {
|
||||||
|
if !errors.Is(err, syscall.ENOSYS) {
|
||||||
|
t.Fatalf("LandlockGetABI: error = %v", err)
|
||||||
|
}
|
||||||
|
c.HostAbstract = true
|
||||||
|
t.Log("Landlock LSM is unavailable, enabling HostAbstract")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.
|
c.
|
||||||
Readonly(check.MustAbs(pathReadonly), 0755).
|
Readonly(check.MustAbs(pathReadonly), 0755).
|
||||||
@@ -552,11 +560,10 @@ func testContainerCancel(
|
|||||||
) func(t *testing.T) {
|
) func(t *testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx, cancel := context.WithTimeout(t.Context(), helperDefaultTimeout)
|
ctx, cancel := context.WithCancel(t.Context())
|
||||||
|
|
||||||
c := helperNewContainer(ctx, "block")
|
c := helperNewContainer(ctx, "block")
|
||||||
c.Stdout, c.Stderr = os.Stdout, os.Stderr
|
c.Stdout, c.Stderr = os.Stdout, os.Stderr
|
||||||
c.WaitDelay = helperDefaultTimeout
|
|
||||||
if containerExtra != nil {
|
if containerExtra != nil {
|
||||||
containerExtra(c)
|
containerExtra(c)
|
||||||
}
|
}
|
||||||
@@ -737,8 +744,7 @@ func init() {
|
|||||||
const (
|
const (
|
||||||
envDoCheck = "HAKUREI_TEST_DO_CHECK"
|
envDoCheck = "HAKUREI_TEST_DO_CHECK"
|
||||||
|
|
||||||
helperDefaultTimeout = 5 * time.Second
|
helperInnerPath = "/usr/bin/helper"
|
||||||
helperInnerPath = "/usr/bin/helper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -12,6 +14,9 @@ import (
|
|||||||
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/ext"
|
||||||
|
"hakurei.app/internal/netlink"
|
||||||
|
"hakurei.app/internal/params"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,7 +57,7 @@ type syscallDispatcher interface {
|
|||||||
// isatty provides [Isatty].
|
// isatty provides [Isatty].
|
||||||
isatty(fd int) bool
|
isatty(fd int) bool
|
||||||
// receive provides [Receive].
|
// receive provides [Receive].
|
||||||
receive(key string, e any, fdp *uintptr) (closeFunc func() error, err error)
|
receive(key string, e any, fdp *int) (closeFunc func() error, err error)
|
||||||
|
|
||||||
// bindMount provides procPaths.bindMount.
|
// bindMount provides procPaths.bindMount.
|
||||||
bindMount(msg message.Msg, source, target string, flags uintptr) error
|
bindMount(msg message.Msg, source, target string, flags uintptr) error
|
||||||
@@ -63,7 +68,7 @@ type syscallDispatcher interface {
|
|||||||
// ensureFile provides ensureFile.
|
// ensureFile provides ensureFile.
|
||||||
ensureFile(name string, perm, pperm os.FileMode) error
|
ensureFile(name string, perm, pperm os.FileMode) error
|
||||||
// mustLoopback provides mustLoopback.
|
// mustLoopback provides mustLoopback.
|
||||||
mustLoopback(msg message.Msg)
|
mustLoopback(ctx context.Context, msg message.Msg)
|
||||||
|
|
||||||
// seccompLoad provides [seccomp.Load].
|
// seccompLoad provides [seccomp.Load].
|
||||||
seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error
|
seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error
|
||||||
@@ -141,18 +146,18 @@ func (k direct) new(f func(k syscallDispatcher)) { go f(k) }
|
|||||||
|
|
||||||
func (direct) lockOSThread() { runtime.LockOSThread() }
|
func (direct) lockOSThread() { runtime.LockOSThread() }
|
||||||
|
|
||||||
func (direct) setPtracer(pid uintptr) error { return SetPtracer(pid) }
|
func (direct) setPtracer(pid uintptr) error { return ext.SetPtracer(pid) }
|
||||||
func (direct) setDumpable(dumpable uintptr) error { return SetDumpable(dumpable) }
|
func (direct) setDumpable(dumpable uintptr) error { return ext.SetDumpable(dumpable) }
|
||||||
func (direct) setNoNewPrivs() error { return SetNoNewPrivs() }
|
func (direct) setNoNewPrivs() error { return setNoNewPrivs() }
|
||||||
|
|
||||||
func (direct) lastcap(msg message.Msg) uintptr { return LastCap(msg) }
|
func (direct) lastcap(msg message.Msg) uintptr { return LastCap(msg) }
|
||||||
func (direct) capset(hdrp *capHeader, datap *[2]capData) error { return capset(hdrp, datap) }
|
func (direct) capset(hdrp *capHeader, datap *[2]capData) error { return capset(hdrp, datap) }
|
||||||
func (direct) capBoundingSetDrop(cap uintptr) error { return capBoundingSetDrop(cap) }
|
func (direct) capBoundingSetDrop(cap uintptr) error { return capBoundingSetDrop(cap) }
|
||||||
func (direct) capAmbientClearAll() error { return capAmbientClearAll() }
|
func (direct) capAmbientClearAll() error { return capAmbientClearAll() }
|
||||||
func (direct) capAmbientRaise(cap uintptr) error { return capAmbientRaise(cap) }
|
func (direct) capAmbientRaise(cap uintptr) error { return capAmbientRaise(cap) }
|
||||||
func (direct) isatty(fd int) bool { return Isatty(fd) }
|
func (direct) isatty(fd int) bool { return ext.Isatty(fd) }
|
||||||
func (direct) receive(key string, e any, fdp *uintptr) (func() error, error) {
|
func (direct) receive(key string, e any, fdp *int) (func() error, error) {
|
||||||
return Receive(key, e, fdp)
|
return params.Receive(key, e, fdp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (direct) bindMount(msg message.Msg, source, target string, flags uintptr) error {
|
func (direct) bindMount(msg message.Msg, source, target string, flags uintptr) error {
|
||||||
@@ -167,7 +172,50 @@ func (k direct) mountTmpfs(fsname, target string, flags uintptr, size int, perm
|
|||||||
func (direct) ensureFile(name string, perm, pperm os.FileMode) error {
|
func (direct) ensureFile(name string, perm, pperm os.FileMode) error {
|
||||||
return ensureFile(name, perm, pperm)
|
return ensureFile(name, perm, pperm)
|
||||||
}
|
}
|
||||||
func (direct) mustLoopback(msg message.Msg) { mustLoopback(msg) }
|
func (direct) mustLoopback(ctx context.Context, msg message.Msg) {
|
||||||
|
var lo int
|
||||||
|
if ifi, err := net.InterfaceByName("lo"); err != nil {
|
||||||
|
msg.GetLogger().Fatalln(err)
|
||||||
|
} else {
|
||||||
|
lo = ifi.Index
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := netlink.DialRoute(0)
|
||||||
|
if err != nil {
|
||||||
|
msg.GetLogger().Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
must := func(err error) {
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if closeErr := c.Close(); closeErr != nil {
|
||||||
|
msg.Verbosef("cannot close RTNETLINK: %v", closeErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch err.(type) {
|
||||||
|
case *os.SyscallError:
|
||||||
|
msg.GetLogger().Fatalf("cannot %v", err)
|
||||||
|
|
||||||
|
case syscall.Errno:
|
||||||
|
msg.GetLogger().Fatalf("RTNETLINK answers: %v", err)
|
||||||
|
|
||||||
|
default:
|
||||||
|
if err == context.DeadlineExceeded || err == context.Canceled {
|
||||||
|
msg.GetLogger().Fatalf("interrupted RTNETLINK operation")
|
||||||
|
}
|
||||||
|
msg.GetLogger().Fatal("RTNETLINK answers with malformed message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
must(c.SendNewaddrLo(ctx, uint32(lo)))
|
||||||
|
must(c.SendIfInfomsg(ctx, syscall.RTM_NEWLINK, 0, &syscall.IfInfomsg{
|
||||||
|
Family: syscall.AF_UNSPEC,
|
||||||
|
Index: int32(lo),
|
||||||
|
Flags: syscall.IFF_UP,
|
||||||
|
Change: syscall.IFF_UP,
|
||||||
|
}))
|
||||||
|
must(c.Close())
|
||||||
|
}
|
||||||
|
|
||||||
func (direct) seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error {
|
func (direct) seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error {
|
||||||
return seccomp.Load(rules, flags)
|
return seccomp.Load(rules, flags)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package container
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -18,7 +19,7 @@ import (
|
|||||||
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -389,7 +390,7 @@ func (k *kstub) isatty(fd int) bool {
|
|||||||
return expect.Ret.(bool)
|
return expect.Ret.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kstub) receive(key string, e any, fdp *uintptr) (closeFunc func() error, err error) {
|
func (k *kstub) receive(key string, e any, fdp *int) (closeFunc func() error, err error) {
|
||||||
k.Helper()
|
k.Helper()
|
||||||
expect := k.Expects("receive")
|
expect := k.Expects("receive")
|
||||||
|
|
||||||
@@ -407,10 +408,17 @@ func (k *kstub) receive(key string, e any, fdp *uintptr) (closeFunc func() error
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// avoid changing test cases
|
||||||
|
var fdpComp *uintptr
|
||||||
|
if fdp != nil {
|
||||||
|
fdpComp = new(uintptr(*fdp))
|
||||||
|
}
|
||||||
|
|
||||||
err = expect.Error(
|
err = expect.Error(
|
||||||
stub.CheckArg(k.Stub, "key", key, 0),
|
stub.CheckArg(k.Stub, "key", key, 0),
|
||||||
stub.CheckArgReflect(k.Stub, "e", e, 1),
|
stub.CheckArgReflect(k.Stub, "e", e, 1),
|
||||||
stub.CheckArgReflect(k.Stub, "fdp", fdp, 2))
|
stub.CheckArgReflect(k.Stub, "fdp", fdpComp, 2))
|
||||||
|
|
||||||
// 3 is unused so stores params
|
// 3 is unused so stores params
|
||||||
if expect.Args[3] != nil {
|
if expect.Args[3] != nil {
|
||||||
@@ -425,7 +433,7 @@ func (k *kstub) receive(key string, e any, fdp *uintptr) (closeFunc func() error
|
|||||||
if expect.Args[4] != nil {
|
if expect.Args[4] != nil {
|
||||||
if v, ok := expect.Args[4].(uintptr); ok && v >= 3 {
|
if v, ok := expect.Args[4].(uintptr); ok && v >= 3 {
|
||||||
if fdp != nil {
|
if fdp != nil {
|
||||||
*fdp = v
|
*fdp = int(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,7 +476,7 @@ func (k *kstub) ensureFile(name string, perm, pperm os.FileMode) error {
|
|||||||
stub.CheckArg(k.Stub, "pperm", pperm, 2))
|
stub.CheckArg(k.Stub, "pperm", pperm, 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*kstub) mustLoopback(message.Msg) { /* noop */ }
|
func (*kstub) mustLoopback(context.Context, message.Msg) { /* noop */ }
|
||||||
|
|
||||||
func (k *kstub) seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error {
|
func (k *kstub) seccompLoad(rules []std.NativeRule, flags seccomp.ExportFlag) error {
|
||||||
k.Helper()
|
k.Helper()
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/vfs"
|
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// messageFromError returns a printable error message for a supported concrete type.
|
// messageFromError returns a printable error message for a supported concrete type.
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMessageFromError(t *testing.T) {
|
func TestMessageFromError(t *testing.T) {
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
"hakurei.app/message"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
executable string
|
|
||||||
executableOnce sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
func copyExecutable(msg message.Msg) {
|
|
||||||
if name, err := os.Executable(); err != nil {
|
|
||||||
m := fmt.Sprintf("cannot read executable path: %v", err)
|
|
||||||
if msg != nil {
|
|
||||||
msg.BeforeExit()
|
|
||||||
msg.GetLogger().Fatal(m)
|
|
||||||
} else {
|
|
||||||
log.Fatal(m)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
executable = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MustExecutable calls [os.Executable] and terminates the process on error.
|
|
||||||
//
|
|
||||||
// Deprecated: This is no longer used and will be removed in 0.4.
|
|
||||||
func MustExecutable(msg message.Msg) string {
|
|
||||||
executableOnce.Do(func() { copyExecutable(msg) })
|
|
||||||
return executable
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package container_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"hakurei.app/container"
|
|
||||||
"hakurei.app/message"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestExecutable(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
for i := 0; i < 16; i++ {
|
|
||||||
if got := container.MustExecutable(message.New(nil)); got != os.Args[0] {
|
|
||||||
t.Errorf("MustExecutable: %q, want %q", got, os.Args[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -15,8 +16,10 @@ import (
|
|||||||
. "syscall"
|
. "syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/fhs"
|
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
|
"hakurei.app/ext"
|
||||||
|
"hakurei.app/fhs"
|
||||||
|
"hakurei.app/internal/params"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -145,44 +148,46 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
params initParams
|
param initParams
|
||||||
closeSetup func() error
|
closeSetup func() error
|
||||||
setupFd uintptr
|
setupFd int
|
||||||
offsetSetup int
|
|
||||||
)
|
)
|
||||||
if f, err := k.receive(setupEnv, ¶ms, &setupFd); err != nil {
|
if f, err := k.receive(setupEnv, ¶m, &setupFd); err != nil {
|
||||||
if errors.Is(err, EBADF) {
|
if errors.Is(err, EBADF) {
|
||||||
k.fatal(msg, "invalid setup descriptor")
|
k.fatal(msg, "invalid setup descriptor")
|
||||||
}
|
}
|
||||||
if errors.Is(err, ErrReceiveEnv) {
|
if errors.Is(err, params.ErrReceiveEnv) {
|
||||||
k.fatal(msg, setupEnv+" not set")
|
k.fatal(msg, setupEnv+" not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
k.fatalf(msg, "cannot decode init setup payload: %v", err)
|
k.fatalf(msg, "cannot decode init setup payload: %v", err)
|
||||||
} else {
|
} else {
|
||||||
if params.Ops == nil {
|
if param.Ops == nil {
|
||||||
k.fatal(msg, "invalid setup parameters")
|
k.fatal(msg, "invalid setup parameters")
|
||||||
}
|
}
|
||||||
if params.ParentPerm == 0 {
|
if param.ParentPerm == 0 {
|
||||||
params.ParentPerm = 0755
|
param.ParentPerm = 0755
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.SwapVerbose(params.Verbose)
|
msg.SwapVerbose(param.Verbose)
|
||||||
msg.Verbose("received setup parameters")
|
msg.Verbose("received setup parameters")
|
||||||
closeSetup = f
|
closeSetup = f
|
||||||
offsetSetup = int(setupFd + 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !params.HostNet {
|
if !param.HostNet {
|
||||||
k.mustLoopback(msg)
|
ctx, cancel := signal.NotifyContext(context.Background(), CancelSignal,
|
||||||
|
os.Interrupt, SIGTERM, SIGQUIT)
|
||||||
|
defer cancel() // for panics
|
||||||
|
k.mustLoopback(ctx, msg)
|
||||||
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// write uid/gid map here so parent does not need to set dumpable
|
// write uid/gid map here so parent does not need to set dumpable
|
||||||
if err := k.setDumpable(SUID_DUMP_USER); err != nil {
|
if err := k.setDumpable(ext.SUID_DUMP_USER); err != nil {
|
||||||
k.fatalf(msg, "cannot set SUID_DUMP_USER: %v", err)
|
k.fatalf(msg, "cannot set SUID_DUMP_USER: %v", err)
|
||||||
}
|
}
|
||||||
if err := k.writeFile(fhs.Proc+"self/uid_map",
|
if err := k.writeFile(fhs.Proc+"self/uid_map",
|
||||||
append([]byte{}, strconv.Itoa(params.Uid)+" "+strconv.Itoa(params.HostUid)+" 1\n"...),
|
append([]byte{}, strconv.Itoa(param.Uid)+" "+strconv.Itoa(param.HostUid)+" 1\n"...),
|
||||||
0); err != nil {
|
0); err != nil {
|
||||||
k.fatalf(msg, "%v", err)
|
k.fatalf(msg, "%v", err)
|
||||||
}
|
}
|
||||||
@@ -192,17 +197,17 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
k.fatalf(msg, "%v", err)
|
k.fatalf(msg, "%v", err)
|
||||||
}
|
}
|
||||||
if err := k.writeFile(fhs.Proc+"self/gid_map",
|
if err := k.writeFile(fhs.Proc+"self/gid_map",
|
||||||
append([]byte{}, strconv.Itoa(params.Gid)+" "+strconv.Itoa(params.HostGid)+" 1\n"...),
|
append([]byte{}, strconv.Itoa(param.Gid)+" "+strconv.Itoa(param.HostGid)+" 1\n"...),
|
||||||
0); err != nil {
|
0); err != nil {
|
||||||
k.fatalf(msg, "%v", err)
|
k.fatalf(msg, "%v", err)
|
||||||
}
|
}
|
||||||
if err := k.setDumpable(SUID_DUMP_DISABLE); err != nil {
|
if err := k.setDumpable(ext.SUID_DUMP_DISABLE); err != nil {
|
||||||
k.fatalf(msg, "cannot set SUID_DUMP_DISABLE: %v", err)
|
k.fatalf(msg, "cannot set SUID_DUMP_DISABLE: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
oldmask := k.umask(0)
|
oldmask := k.umask(0)
|
||||||
if params.Hostname != "" {
|
if param.Hostname != "" {
|
||||||
if err := k.sethostname([]byte(params.Hostname)); err != nil {
|
if err := k.sethostname([]byte(param.Hostname)); err != nil {
|
||||||
k.fatalf(msg, "cannot set hostname: %v", err)
|
k.fatalf(msg, "cannot set hostname: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,7 +220,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
state := &setupState{process: make(map[int]WaitStatus), Params: ¶ms.Params, Msg: msg, Context: ctx}
|
state := &setupState{process: make(map[int]WaitStatus), Params: ¶m.Params, Msg: msg, Context: ctx}
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
/* early is called right before pivot_root into intermediate root;
|
/* early is called right before pivot_root into intermediate root;
|
||||||
@@ -223,7 +228,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
difficult to obtain via library functions after pivot_root, and
|
difficult to obtain via library functions after pivot_root, and
|
||||||
implementations are expected to avoid changing the state of the mount
|
implementations are expected to avoid changing the state of the mount
|
||||||
namespace */
|
namespace */
|
||||||
for i, op := range *params.Ops {
|
for i, op := range *param.Ops {
|
||||||
if op == nil || !op.Valid() {
|
if op == nil || !op.Valid() {
|
||||||
k.fatalf(msg, "invalid op at index %d", i)
|
k.fatalf(msg, "invalid op at index %d", i)
|
||||||
}
|
}
|
||||||
@@ -266,7 +271,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
step sets up the container filesystem, and implementations are expected to
|
step sets up the container filesystem, and implementations are expected to
|
||||||
keep the host root and sysroot mount points intact but otherwise can do
|
keep the host root and sysroot mount points intact but otherwise can do
|
||||||
whatever they need to. Calling chdir is allowed but discouraged. */
|
whatever they need to. Calling chdir is allowed but discouraged. */
|
||||||
for i, op := range *params.Ops {
|
for i, op := range *param.Ops {
|
||||||
// ops already checked during early setup
|
// ops already checked during early setup
|
||||||
if prefix, ok := op.prefix(); ok {
|
if prefix, ok := op.prefix(); ok {
|
||||||
msg.Verbosef("%s %s", prefix, op)
|
msg.Verbosef("%s %s", prefix, op)
|
||||||
@@ -290,7 +295,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
var fd int
|
var fd int
|
||||||
if err := IgnoringEINTR(func() (err error) {
|
if err := ext.IgnoringEINTR(func() (err error) {
|
||||||
fd, err = k.open(fhs.Root, O_DIRECTORY|O_RDONLY, 0)
|
fd, err = k.open(fhs.Root, O_DIRECTORY|O_RDONLY, 0)
|
||||||
return
|
return
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -322,7 +327,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
k.fatalf(msg, "cannot clear the ambient capability set: %v", err)
|
k.fatalf(msg, "cannot clear the ambient capability set: %v", err)
|
||||||
}
|
}
|
||||||
for i := uintptr(0); i <= lastcap; i++ {
|
for i := uintptr(0); i <= lastcap; i++ {
|
||||||
if params.Privileged && i == CAP_SYS_ADMIN {
|
if param.Privileged && i == CAP_SYS_ADMIN {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := k.capBoundingSetDrop(i); err != nil {
|
if err := k.capBoundingSetDrop(i); err != nil {
|
||||||
@@ -331,7 +336,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keep [2]uint32
|
var keep [2]uint32
|
||||||
if params.Privileged {
|
if param.Privileged {
|
||||||
keep[capToIndex(CAP_SYS_ADMIN)] |= capToMask(CAP_SYS_ADMIN)
|
keep[capToIndex(CAP_SYS_ADMIN)] |= capToMask(CAP_SYS_ADMIN)
|
||||||
|
|
||||||
if err := k.capAmbientRaise(CAP_SYS_ADMIN); err != nil {
|
if err := k.capAmbientRaise(CAP_SYS_ADMIN); err != nil {
|
||||||
@@ -345,13 +350,13 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
k.fatalf(msg, "cannot capset: %v", err)
|
k.fatalf(msg, "cannot capset: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !params.SeccompDisable {
|
if !param.SeccompDisable {
|
||||||
rules := params.SeccompRules
|
rules := param.SeccompRules
|
||||||
if len(rules) == 0 { // non-empty rules slice always overrides presets
|
if len(rules) == 0 { // non-empty rules slice always overrides presets
|
||||||
msg.Verbosef("resolving presets %#x", params.SeccompPresets)
|
msg.Verbosef("resolving presets %#x", param.SeccompPresets)
|
||||||
rules = seccomp.Preset(params.SeccompPresets, params.SeccompFlags)
|
rules = seccomp.Preset(param.SeccompPresets, param.SeccompFlags)
|
||||||
}
|
}
|
||||||
if err := k.seccompLoad(rules, params.SeccompFlags); err != nil {
|
if err := k.seccompLoad(rules, param.SeccompFlags); err != nil {
|
||||||
// this also indirectly asserts PR_SET_NO_NEW_PRIVS
|
// this also indirectly asserts PR_SET_NO_NEW_PRIVS
|
||||||
k.fatalf(msg, "cannot load syscall filter: %v", err)
|
k.fatalf(msg, "cannot load syscall filter: %v", err)
|
||||||
}
|
}
|
||||||
@@ -360,10 +365,10 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
msg.Verbose("syscall filter not configured")
|
msg.Verbose("syscall filter not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
extraFiles := make([]*os.File, params.Count)
|
extraFiles := make([]*os.File, param.Count)
|
||||||
for i := range extraFiles {
|
for i := range extraFiles {
|
||||||
// setup fd is placed before all extra files
|
// setup fd is placed before all extra files
|
||||||
extraFiles[i] = k.newFile(uintptr(offsetSetup+i), "extra file "+strconv.Itoa(i))
|
extraFiles[i] = k.newFile(uintptr(setupFd+1+i), "extra file "+strconv.Itoa(i))
|
||||||
}
|
}
|
||||||
k.umask(oldmask)
|
k.umask(oldmask)
|
||||||
|
|
||||||
@@ -441,7 +446,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
|
|
||||||
// called right before startup of initial process, all state changes to the
|
// called right before startup of initial process, all state changes to the
|
||||||
// current process is prohibited during late
|
// current process is prohibited during late
|
||||||
for i, op := range *params.Ops {
|
for i, op := range *param.Ops {
|
||||||
// ops already checked during early setup
|
// ops already checked during early setup
|
||||||
if err := op.late(state, k); err != nil {
|
if err := op.late(state, k); err != nil {
|
||||||
if m, ok := messageFromError(err); ok {
|
if m, ok := messageFromError(err); ok {
|
||||||
@@ -462,14 +467,14 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
k.fatalf(msg, "cannot close setup pipe: %v", err)
|
k.fatalf(msg, "cannot close setup pipe: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(params.Path.String())
|
cmd := exec.Command(param.Path.String())
|
||||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
cmd.Args = params.Args
|
cmd.Args = param.Args
|
||||||
cmd.Env = params.Env
|
cmd.Env = param.Env
|
||||||
cmd.ExtraFiles = extraFiles
|
cmd.ExtraFiles = extraFiles
|
||||||
cmd.Dir = params.Dir.String()
|
cmd.Dir = param.Dir.String()
|
||||||
|
|
||||||
msg.Verbosef("starting initial process %s", params.Path)
|
msg.Verbosef("starting initial process %s", param.Path)
|
||||||
if err := k.start(cmd); err != nil {
|
if err := k.start(cmd); err != nil {
|
||||||
k.fatalf(msg, "%v", err)
|
k.fatalf(msg, "%v", err)
|
||||||
}
|
}
|
||||||
@@ -487,9 +492,9 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case s := <-sig:
|
case s := <-sig:
|
||||||
if s == CancelSignal && params.ForwardCancel && cmd.Process != nil {
|
if s == CancelSignal && param.ForwardCancel && cmd.Process != nil {
|
||||||
msg.Verbose("forwarding context cancellation")
|
msg.Verbose("forwarding context cancellation")
|
||||||
if err := k.signal(cmd, os.Interrupt); err != nil {
|
if err := k.signal(cmd, os.Interrupt); err != nil && !errors.Is(err, os.ErrProcessDone) {
|
||||||
k.printf(msg, "cannot forward cancellation: %v", err)
|
k.printf(msg, "cannot forward cancellation: %v", err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -519,7 +524,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
|
|||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
// start timeout early
|
// start timeout early
|
||||||
go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }()
|
go func() { time.Sleep(param.AdoptWaitDelay); close(timeout) }()
|
||||||
|
|
||||||
// close initial process files; this also keeps them alive
|
// close initial process files; this also keeps them alive
|
||||||
for _, f := range extraFiles {
|
for _, f := range extraFiles {
|
||||||
@@ -563,7 +568,7 @@ func TryArgv0(msg message.Msg) {
|
|||||||
msg = message.New(log.Default())
|
msg = message.New(log.Default())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(os.Args) > 0 && path.Base(os.Args[0]) == initName {
|
if len(os.Args) > 0 && filepath.Base(os.Args[0]) == initName {
|
||||||
Init(msg)
|
Init(msg)
|
||||||
msg.BeforeExit()
|
msg.BeforeExit()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/seccomp"
|
"hakurei.app/container/seccomp"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/params"
|
||||||
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitEntrypoint(t *testing.T) {
|
func TestInitEntrypoint(t *testing.T) {
|
||||||
@@ -40,7 +41,7 @@ func TestInitEntrypoint(t *testing.T) {
|
|||||||
call("lockOSThread", stub.ExpectArgs{}, nil, nil),
|
call("lockOSThread", stub.ExpectArgs{}, nil, nil),
|
||||||
call("getpid", stub.ExpectArgs{}, 1, nil),
|
call("getpid", stub.ExpectArgs{}, 1, nil),
|
||||||
call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil),
|
call("setPtracer", stub.ExpectArgs{uintptr(0)}, nil, nil),
|
||||||
call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, ErrReceiveEnv),
|
call("receive", stub.ExpectArgs{"HAKUREI_SETUP", new(initParams), new(uintptr)}, nil, params.ErrReceiveEnv),
|
||||||
call("fatal", stub.ExpectArgs{[]any{"HAKUREI_SETUP not set"}}, nil, nil),
|
call("fatal", stub.ExpectArgs{[]any{"HAKUREI_SETUP not set"}}, nil, nil),
|
||||||
},
|
},
|
||||||
}, nil},
|
}, nil},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBindMountOp(t *testing.T) {
|
func TestBindMountOp(t *testing.T) {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(DaemonOp)) }
|
func init() { gob.Register(new(DaemonOp)) }
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package container
|
|||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(MountDevOp)) }
|
func init() { gob.Register(new(MountDevOp)) }
|
||||||
@@ -46,7 +46,7 @@ func (d *MountDevOp) apply(state *setupState, k syscallDispatcher) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, name := range []string{"null", "zero", "full", "random", "urandom", "tty"} {
|
for _, name := range []string{"null", "zero", "full", "random", "urandom", "tty"} {
|
||||||
targetPath := path.Join(target, name)
|
targetPath := filepath.Join(target, name)
|
||||||
if err := k.ensureFile(targetPath, 0444, state.ParentPerm); err != nil {
|
if err := k.ensureFile(targetPath, 0444, state.ParentPerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func (d *MountDevOp) apply(state *setupState, k syscallDispatcher) error {
|
|||||||
for i, name := range []string{"stdin", "stdout", "stderr"} {
|
for i, name := range []string{"stdin", "stdout", "stderr"} {
|
||||||
if err := k.symlink(
|
if err := k.symlink(
|
||||||
fhs.Proc+"self/fd/"+string(rune(i+'0')),
|
fhs.Proc+"self/fd/"+string(rune(i+'0')),
|
||||||
path.Join(target, name),
|
filepath.Join(target, name),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -72,13 +72,13 @@ func (d *MountDevOp) apply(state *setupState, k syscallDispatcher) error {
|
|||||||
{fhs.Proc + "kcore", "core"},
|
{fhs.Proc + "kcore", "core"},
|
||||||
{"pts/ptmx", "ptmx"},
|
{"pts/ptmx", "ptmx"},
|
||||||
} {
|
} {
|
||||||
if err := k.symlink(pair[0], path.Join(target, pair[1])); err != nil {
|
if err := k.symlink(pair[0], filepath.Join(target, pair[1])); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
devShmPath := path.Join(target, "shm")
|
devShmPath := filepath.Join(target, "shm")
|
||||||
devPtsPath := path.Join(target, "pts")
|
devPtsPath := filepath.Join(target, "pts")
|
||||||
for _, name := range []string{devShmPath, devPtsPath} {
|
for _, name := range []string{devShmPath, devPtsPath} {
|
||||||
if err := k.mkdir(name, state.ParentPerm); err != nil {
|
if err := k.mkdir(name, state.ParentPerm); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -92,7 +92,7 @@ func (d *MountDevOp) apply(state *setupState, k syscallDispatcher) error {
|
|||||||
|
|
||||||
if state.RetainSession {
|
if state.RetainSession {
|
||||||
if k.isatty(Stdout) {
|
if k.isatty(Stdout) {
|
||||||
consolePath := path.Join(target, "console")
|
consolePath := filepath.Join(target, "console")
|
||||||
if err := k.ensureFile(consolePath, 0444, state.ParentPerm); err != nil {
|
if err := k.ensureFile(consolePath, 0444, state.ParentPerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ func (d *MountDevOp) apply(state *setupState, k syscallDispatcher) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if d.Mqueue {
|
if d.Mqueue {
|
||||||
mqueueTarget := path.Join(target, "mqueue")
|
mqueueTarget := filepath.Join(target, "mqueue")
|
||||||
if err := k.mkdir(mqueueTarget, state.ParentPerm); err != nil {
|
if err := k.mkdir(mqueueTarget, state.ParentPerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMountDevOp(t *testing.T) {
|
func TestMountDevOp(t *testing.T) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(MkdirOp)) }
|
func init() { gob.Register(new(MkdirOp)) }
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMkdirOp(t *testing.T) {
|
func TestMkdirOp(t *testing.T) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMountOverlayOp(t *testing.T) {
|
func TestMountOverlayOp(t *testing.T) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTmpfileOp(t *testing.T) {
|
func TestTmpfileOp(t *testing.T) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(MountProcOp)) }
|
func init() { gob.Register(new(MountProcOp)) }
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMountProcOp(t *testing.T) {
|
func TestMountProcOp(t *testing.T) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(RemountOp)) }
|
func init() { gob.Register(new(RemountOp)) }
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRemountOp(t *testing.T) {
|
func TestRemountOp(t *testing.T) {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package container
|
|||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(SymlinkOp)) }
|
func init() { gob.Register(new(SymlinkOp)) }
|
||||||
@@ -30,7 +30,7 @@ func (l *SymlinkOp) Valid() bool { return l != nil && l.Target != nil && l.LinkN
|
|||||||
|
|
||||||
func (l *SymlinkOp) early(_ *setupState, k syscallDispatcher) error {
|
func (l *SymlinkOp) early(_ *setupState, k syscallDispatcher) error {
|
||||||
if l.Dereference {
|
if l.Dereference {
|
||||||
if !path.IsAbs(l.LinkName) {
|
if !filepath.IsAbs(l.LinkName) {
|
||||||
return check.AbsoluteError(l.LinkName)
|
return check.AbsoluteError(l.LinkName)
|
||||||
}
|
}
|
||||||
if name, err := k.readlink(l.LinkName); err != nil {
|
if name, err := k.readlink(l.LinkName); err != nil {
|
||||||
@@ -44,7 +44,7 @@ func (l *SymlinkOp) early(_ *setupState, k syscallDispatcher) error {
|
|||||||
|
|
||||||
func (l *SymlinkOp) apply(state *setupState, k syscallDispatcher) error {
|
func (l *SymlinkOp) apply(state *setupState, k syscallDispatcher) error {
|
||||||
target := toSysroot(l.Target.String())
|
target := toSysroot(l.Target.String())
|
||||||
if err := k.mkdirAll(path.Dir(target), state.ParentPerm); err != nil {
|
if err := k.mkdirAll(filepath.Dir(target), state.ParentPerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return k.symlink(l.LinkName, target)
|
return k.symlink(l.LinkName, target)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSymlinkOp(t *testing.T) {
|
func TestSymlinkOp(t *testing.T) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(MountTmpfsOp)) }
|
func init() { gob.Register(new(MountTmpfsOp)) }
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMountTmpfsOp(t *testing.T) {
|
func TestMountTmpfsOp(t *testing.T) {
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package container_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"hakurei.app/container"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestLandlockString(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
rulesetAttr *container.RulesetAttr
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
{"nil", nil, "NULL"},
|
|
||||||
{"zero", new(container.RulesetAttr), "0"},
|
|
||||||
{"some", &container.RulesetAttr{Scoped: container.LANDLOCK_SCOPE_SIGNAL}, "scoped: signal"},
|
|
||||||
{"set", &container.RulesetAttr{
|
|
||||||
HandledAccessFS: container.LANDLOCK_ACCESS_FS_MAKE_SYM | container.LANDLOCK_ACCESS_FS_IOCTL_DEV | container.LANDLOCK_ACCESS_FS_WRITE_FILE,
|
|
||||||
HandledAccessNet: container.LANDLOCK_ACCESS_NET_BIND_TCP,
|
|
||||||
Scoped: container.LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET | container.LANDLOCK_SCOPE_SIGNAL,
|
|
||||||
}, "fs: write_file make_sym fs_ioctl_dev, net: bind_tcp, scoped: abstract_unix_socket signal"},
|
|
||||||
{"all", &container.RulesetAttr{
|
|
||||||
HandledAccessFS: container.LANDLOCK_ACCESS_FS_EXECUTE |
|
|
||||||
container.LANDLOCK_ACCESS_FS_WRITE_FILE |
|
|
||||||
container.LANDLOCK_ACCESS_FS_READ_FILE |
|
|
||||||
container.LANDLOCK_ACCESS_FS_READ_DIR |
|
|
||||||
container.LANDLOCK_ACCESS_FS_REMOVE_DIR |
|
|
||||||
container.LANDLOCK_ACCESS_FS_REMOVE_FILE |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_CHAR |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_DIR |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_REG |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_SOCK |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_FIFO |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_BLOCK |
|
|
||||||
container.LANDLOCK_ACCESS_FS_MAKE_SYM |
|
|
||||||
container.LANDLOCK_ACCESS_FS_REFER |
|
|
||||||
container.LANDLOCK_ACCESS_FS_TRUNCATE |
|
|
||||||
container.LANDLOCK_ACCESS_FS_IOCTL_DEV,
|
|
||||||
HandledAccessNet: container.LANDLOCK_ACCESS_NET_BIND_TCP |
|
|
||||||
container.LANDLOCK_ACCESS_NET_CONNECT_TCP,
|
|
||||||
Scoped: container.LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET |
|
|
||||||
container.LANDLOCK_SCOPE_SIGNAL,
|
|
||||||
}, "fs: execute write_file read_file read_dir remove_dir remove_file make_char make_dir make_reg make_sock make_fifo make_block make_sym fs_refer fs_truncate fs_ioctl_dev, net: bind_tcp connect_tcp, scoped: abstract_unix_socket signal"},
|
|
||||||
}
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
if got := tc.rulesetAttr.String(); got != tc.want {
|
|
||||||
t.Errorf("String: %s, want %s", got, tc.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLandlockAttrSize(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
want := 24
|
|
||||||
if got := unsafe.Sizeof(container.RulesetAttr{}); got != uintptr(want) {
|
|
||||||
t.Errorf("Sizeof: %d, want %d", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
|
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/ext"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -115,7 +116,7 @@ func (p *procPaths) remount(msg message.Msg, target string, flags uintptr) error
|
|||||||
var targetKFinal string
|
var targetKFinal string
|
||||||
{
|
{
|
||||||
var destFd int
|
var destFd int
|
||||||
if err := IgnoringEINTR(func() (err error) {
|
if err := ext.IgnoringEINTR(func() (err error) {
|
||||||
destFd, err = p.k.open(targetFinal, O_PATH|O_CLOEXEC, 0)
|
destFd, err = p.k.open(targetFinal, O_PATH|O_CLOEXEC, 0)
|
||||||
return
|
return
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/stub"
|
"hakurei.app/internal/stub"
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBindMount(t *testing.T) {
|
func TestBindMount(t *testing.T) {
|
||||||
|
|||||||
@@ -1,269 +0,0 @@
|
|||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
|
||||||
"net"
|
|
||||||
"os"
|
|
||||||
. "syscall"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
|
||||||
"hakurei.app/message"
|
|
||||||
)
|
|
||||||
|
|
||||||
// rtnetlink represents a NETLINK_ROUTE socket.
|
|
||||||
type rtnetlink struct {
|
|
||||||
// Sent as part of rtnetlink messages.
|
|
||||||
pid uint32
|
|
||||||
// AF_NETLINK socket.
|
|
||||||
fd int
|
|
||||||
// Whether the socket is open.
|
|
||||||
ok bool
|
|
||||||
// Message sequence number.
|
|
||||||
seq uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
// open creates the underlying NETLINK_ROUTE socket.
|
|
||||||
func (s *rtnetlink) open() (err error) {
|
|
||||||
if s.ok || s.fd < 0 {
|
|
||||||
return os.ErrInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
s.pid = uint32(Getpid())
|
|
||||||
if s.fd, err = Socket(
|
|
||||||
AF_NETLINK,
|
|
||||||
SOCK_RAW|SOCK_CLOEXEC,
|
|
||||||
NETLINK_ROUTE,
|
|
||||||
); err != nil {
|
|
||||||
return os.NewSyscallError("socket", err)
|
|
||||||
} else if err = Bind(s.fd, &SockaddrNetlink{
|
|
||||||
Family: AF_NETLINK,
|
|
||||||
Pid: s.pid,
|
|
||||||
}); err != nil {
|
|
||||||
_ = s.close()
|
|
||||||
return os.NewSyscallError("bind", err)
|
|
||||||
} else {
|
|
||||||
s.ok = true
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// close closes the underlying NETLINK_ROUTE socket.
|
|
||||||
func (s *rtnetlink) close() error {
|
|
||||||
if !s.ok {
|
|
||||||
return os.ErrInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
s.ok = false
|
|
||||||
err := Close(s.fd)
|
|
||||||
s.fd = -1
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// roundtrip sends a netlink message and handles the reply.
|
|
||||||
func (s *rtnetlink) roundtrip(data []byte) error {
|
|
||||||
if !s.ok {
|
|
||||||
return os.ErrInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() { s.seq++ }()
|
|
||||||
|
|
||||||
if err := Sendto(s.fd, data, 0, &SockaddrNetlink{
|
|
||||||
Family: AF_NETLINK,
|
|
||||||
}); err != nil {
|
|
||||||
return os.NewSyscallError("sendto", err)
|
|
||||||
}
|
|
||||||
buf := make([]byte, Getpagesize())
|
|
||||||
|
|
||||||
done:
|
|
||||||
for {
|
|
||||||
p := buf
|
|
||||||
if n, _, err := Recvfrom(s.fd, p, 0); err != nil {
|
|
||||||
return os.NewSyscallError("recvfrom", err)
|
|
||||||
} else if n < NLMSG_HDRLEN {
|
|
||||||
return errors.ErrUnsupported
|
|
||||||
} else {
|
|
||||||
p = p[:n]
|
|
||||||
}
|
|
||||||
|
|
||||||
if msgs, err := ParseNetlinkMessage(p); err != nil {
|
|
||||||
return err
|
|
||||||
} else {
|
|
||||||
for _, m := range msgs {
|
|
||||||
if m.Header.Seq != s.seq || m.Header.Pid != s.pid {
|
|
||||||
return errors.ErrUnsupported
|
|
||||||
}
|
|
||||||
if m.Header.Type == NLMSG_DONE {
|
|
||||||
break done
|
|
||||||
}
|
|
||||||
if m.Header.Type == NLMSG_ERROR {
|
|
||||||
if len(m.Data) >= 4 {
|
|
||||||
errno := Errno(-std.Int(binary.NativeEndian.Uint32(m.Data)))
|
|
||||||
if errno == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return errors.ErrUnsupported
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mustRoundtrip calls roundtrip and terminates via msg for a non-nil error.
|
|
||||||
func (s *rtnetlink) mustRoundtrip(msg message.Msg, data []byte) {
|
|
||||||
err := s.roundtrip(data)
|
|
||||||
if err == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if closeErr := Close(s.fd); closeErr != nil {
|
|
||||||
msg.Verbosef("cannot close: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch err.(type) {
|
|
||||||
case *os.SyscallError:
|
|
||||||
msg.GetLogger().Fatalf("cannot %v", err)
|
|
||||||
|
|
||||||
case Errno:
|
|
||||||
msg.GetLogger().Fatalf("RTNETLINK answers: %v", err)
|
|
||||||
|
|
||||||
default:
|
|
||||||
msg.GetLogger().Fatalln("RTNETLINK answers with unexpected message")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newaddrLo represents a RTM_NEWADDR message with two addresses.
|
|
||||||
type newaddrLo struct {
|
|
||||||
header NlMsghdr
|
|
||||||
data IfAddrmsg
|
|
||||||
|
|
||||||
r0 RtAttr
|
|
||||||
a0 [4]byte // in_addr
|
|
||||||
r1 RtAttr
|
|
||||||
a1 [4]byte // in_addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// sizeofNewaddrLo is the expected size of newaddrLo.
|
|
||||||
const sizeofNewaddrLo = NLMSG_HDRLEN + SizeofIfAddrmsg + (SizeofRtAttr+4)*2
|
|
||||||
|
|
||||||
// newaddrLo returns the address of a populated newaddrLo.
|
|
||||||
func (s *rtnetlink) newaddrLo(lo int) *newaddrLo {
|
|
||||||
return &newaddrLo{NlMsghdr{
|
|
||||||
Len: sizeofNewaddrLo,
|
|
||||||
Type: RTM_NEWADDR,
|
|
||||||
Flags: NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_EXCL,
|
|
||||||
Seq: s.seq,
|
|
||||||
Pid: s.pid,
|
|
||||||
}, IfAddrmsg{
|
|
||||||
Family: AF_INET,
|
|
||||||
Prefixlen: 8,
|
|
||||||
Flags: IFA_F_PERMANENT,
|
|
||||||
Scope: RT_SCOPE_HOST,
|
|
||||||
Index: uint32(lo),
|
|
||||||
}, RtAttr{
|
|
||||||
Len: uint16(SizeofRtAttr + len(newaddrLo{}.a0)),
|
|
||||||
Type: IFA_LOCAL,
|
|
||||||
}, [4]byte{127, 0, 0, 1}, RtAttr{
|
|
||||||
Len: uint16(SizeofRtAttr + len(newaddrLo{}.a1)),
|
|
||||||
Type: IFA_ADDRESS,
|
|
||||||
}, [4]byte{127, 0, 0, 1}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (msg *newaddrLo) toWireFormat() []byte {
|
|
||||||
var buf [sizeofNewaddrLo]byte
|
|
||||||
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[0:4][0])) = msg.header.Len
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[4:6][0])) = msg.header.Type
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[6:8][0])) = msg.header.Flags
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[8:12][0])) = msg.header.Seq
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[12:16][0])) = msg.header.Pid
|
|
||||||
|
|
||||||
buf[16] = msg.data.Family
|
|
||||||
buf[17] = msg.data.Prefixlen
|
|
||||||
buf[18] = msg.data.Flags
|
|
||||||
buf[19] = msg.data.Scope
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[20:24][0])) = msg.data.Index
|
|
||||||
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[24:26][0])) = msg.r0.Len
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[26:28][0])) = msg.r0.Type
|
|
||||||
copy(buf[28:32], msg.a0[:])
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[32:34][0])) = msg.r1.Len
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[34:36][0])) = msg.r1.Type
|
|
||||||
copy(buf[36:40], msg.a1[:])
|
|
||||||
|
|
||||||
return buf[:]
|
|
||||||
}
|
|
||||||
|
|
||||||
// newlinkLo represents a RTM_NEWLINK message.
|
|
||||||
type newlinkLo struct {
|
|
||||||
header NlMsghdr
|
|
||||||
data IfInfomsg
|
|
||||||
}
|
|
||||||
|
|
||||||
// sizeofNewlinkLo is the expected size of newlinkLo.
|
|
||||||
const sizeofNewlinkLo = NLMSG_HDRLEN + SizeofIfInfomsg
|
|
||||||
|
|
||||||
// newlinkLo returns the address of a populated newlinkLo.
|
|
||||||
func (s *rtnetlink) newlinkLo(lo int) *newlinkLo {
|
|
||||||
return &newlinkLo{NlMsghdr{
|
|
||||||
Len: sizeofNewlinkLo,
|
|
||||||
Type: RTM_NEWLINK,
|
|
||||||
Flags: NLM_F_REQUEST | NLM_F_ACK,
|
|
||||||
Seq: s.seq,
|
|
||||||
Pid: s.pid,
|
|
||||||
}, IfInfomsg{
|
|
||||||
Family: AF_UNSPEC,
|
|
||||||
Index: int32(lo),
|
|
||||||
Flags: IFF_UP,
|
|
||||||
Change: IFF_UP,
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (msg *newlinkLo) toWireFormat() []byte {
|
|
||||||
var buf [sizeofNewlinkLo]byte
|
|
||||||
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[0:4][0])) = msg.header.Len
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[4:6][0])) = msg.header.Type
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[6:8][0])) = msg.header.Flags
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[8:12][0])) = msg.header.Seq
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[12:16][0])) = msg.header.Pid
|
|
||||||
|
|
||||||
buf[16] = msg.data.Family
|
|
||||||
*(*uint16)(unsafe.Pointer(&buf[18:20][0])) = msg.data.Type
|
|
||||||
*(*int32)(unsafe.Pointer(&buf[20:24][0])) = msg.data.Index
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[24:28][0])) = msg.data.Flags
|
|
||||||
*(*uint32)(unsafe.Pointer(&buf[28:32][0])) = msg.data.Change
|
|
||||||
|
|
||||||
return buf[:]
|
|
||||||
}
|
|
||||||
|
|
||||||
// mustLoopback creates the loopback address and brings the lo interface up.
|
|
||||||
// mustLoopback calls a fatal method of the underlying [log.Logger] of m with a
|
|
||||||
// user-facing error message if RTNETLINK behaves unexpectedly.
|
|
||||||
func mustLoopback(msg message.Msg) {
|
|
||||||
log := msg.GetLogger()
|
|
||||||
|
|
||||||
var lo int
|
|
||||||
if ifi, err := net.InterfaceByName("lo"); err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
} else {
|
|
||||||
lo = ifi.Index
|
|
||||||
}
|
|
||||||
|
|
||||||
var s rtnetlink
|
|
||||||
if err := s.open(); err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := s.close(); err != nil {
|
|
||||||
msg.Verbosef("cannot close netlink: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
s.mustRoundtrip(msg, s.newaddrLo(lo).toWireFormat())
|
|
||||||
s.mustRoundtrip(msg, s.newlinkLo(lo).toWireFormat())
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSizeof(t *testing.T) {
|
|
||||||
if got := unsafe.Sizeof(newaddrLo{}); got != sizeofNewaddrLo {
|
|
||||||
t.Fatalf("newaddrLo: sizeof = %#x, want %#x", got, sizeofNewaddrLo)
|
|
||||||
}
|
|
||||||
|
|
||||||
if got := unsafe.Sizeof(newlinkLo{}); got != sizeofNewlinkLo {
|
|
||||||
t.Fatalf("newlinkLo: sizeof = %#x, want %#x", got, sizeofNewlinkLo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRtnetlinkMessage(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
msg interface{ toWireFormat() []byte }
|
|
||||||
want []byte
|
|
||||||
}{
|
|
||||||
{"newaddrLo", (&rtnetlink{pid: 1, seq: 0}).newaddrLo(1), []byte{
|
|
||||||
/* Len */ 0x28, 0, 0, 0,
|
|
||||||
/* Type */ 0x14, 0,
|
|
||||||
/* Flags */ 5, 6,
|
|
||||||
/* Seq */ 0, 0, 0, 0,
|
|
||||||
/* Pid */ 1, 0, 0, 0,
|
|
||||||
|
|
||||||
/* Family */ 2,
|
|
||||||
/* Prefixlen */ 8,
|
|
||||||
/* Flags */ 0x80,
|
|
||||||
/* Scope */ 0xfe,
|
|
||||||
/* Index */ 1, 0, 0, 0,
|
|
||||||
|
|
||||||
/* Len */ 8, 0,
|
|
||||||
/* Type */ 2, 0,
|
|
||||||
/* in_addr */ 127, 0, 0, 1,
|
|
||||||
|
|
||||||
/* Len */ 8, 0,
|
|
||||||
/* Type */ 1, 0,
|
|
||||||
/* in_addr */ 127, 0, 0, 1,
|
|
||||||
}},
|
|
||||||
|
|
||||||
{"newlinkLo", (&rtnetlink{pid: 1, seq: 1}).newlinkLo(1), []byte{
|
|
||||||
/* Len */ 0x20, 0, 0, 0,
|
|
||||||
/* Type */ 0x10, 0,
|
|
||||||
/* Flags */ 5, 0,
|
|
||||||
/* Seq */ 1, 0, 0, 0,
|
|
||||||
/* Pid */ 1, 0, 0, 0,
|
|
||||||
|
|
||||||
/* Family */ 0,
|
|
||||||
/* pad */ 0,
|
|
||||||
/* Type */ 0, 0,
|
|
||||||
/* Index */ 1, 0, 0, 0,
|
|
||||||
/* Flags */ 1, 0, 0, 0,
|
|
||||||
/* Change */ 1, 0, 0, 0,
|
|
||||||
}},
|
|
||||||
}
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
if got := tc.msg.toWireFormat(); string(got) != string(tc.want) {
|
|
||||||
t.Fatalf("toWireFormat: %#v, want %#v", got, tc.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/gob"
|
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Setup appends the read end of a pipe for setup params transmission and returns its fd.
|
|
||||||
func Setup(extraFiles *[]*os.File) (int, *os.File, error) {
|
|
||||||
if r, w, err := os.Pipe(); err != nil {
|
|
||||||
return -1, nil, err
|
|
||||||
} else {
|
|
||||||
fd := 3 + len(*extraFiles)
|
|
||||||
*extraFiles = append(*extraFiles, r)
|
|
||||||
return fd, w, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrReceiveEnv = errors.New("environment variable not set")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Receive retrieves setup fd from the environment and receives params.
|
|
||||||
func Receive(key string, e any, fdp *uintptr) (func() error, error) {
|
|
||||||
var setup *os.File
|
|
||||||
|
|
||||||
if s, ok := os.LookupEnv(key); !ok {
|
|
||||||
return nil, ErrReceiveEnv
|
|
||||||
} else {
|
|
||||||
if fd, err := strconv.Atoi(s); err != nil {
|
|
||||||
return nil, optionalErrorUnwrap(err)
|
|
||||||
} else {
|
|
||||||
setup = os.NewFile(uintptr(fd), "setup")
|
|
||||||
if setup == nil {
|
|
||||||
return nil, syscall.EDOM
|
|
||||||
}
|
|
||||||
if fdp != nil {
|
|
||||||
*fdp = setup.Fd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return setup.Close, gob.NewDecoder(setup).Decode(e)
|
|
||||||
}
|
|
||||||
@@ -4,13 +4,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -29,16 +29,16 @@ const (
|
|||||||
|
|
||||||
func toSysroot(name string) string {
|
func toSysroot(name string) string {
|
||||||
name = strings.TrimLeftFunc(name, func(r rune) bool { return r == '/' })
|
name = strings.TrimLeftFunc(name, func(r rune) bool { return r == '/' })
|
||||||
return path.Join(sysrootPath, name)
|
return filepath.Join(sysrootPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toHost(name string) string {
|
func toHost(name string) string {
|
||||||
name = strings.TrimLeftFunc(name, func(r rune) bool { return r == '/' })
|
name = strings.TrimLeftFunc(name, func(r rune) bool { return r == '/' })
|
||||||
return path.Join(hostPath, name)
|
return filepath.Join(hostPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFile(name string, perm, pperm os.FileMode, content []byte) error {
|
func createFile(name string, perm, pperm os.FileMode, content []byte) error {
|
||||||
if err := os.MkdirAll(path.Dir(name), pperm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(name), pperm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f, err := os.OpenFile(name, syscall.O_CREAT|syscall.O_EXCL|syscall.O_WRONLY, perm)
|
f, err := os.OpenFile(name, syscall.O_CREAT|syscall.O_EXCL|syscall.O_WRONLY, perm)
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/container/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container/vfs"
|
"hakurei.app/vfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestToSysroot(t *testing.T) {
|
func TestToSysroot(t *testing.T) {
|
||||||
@@ -61,7 +61,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
Path: "/proc/nonexistent",
|
Path: "/proc/nonexistent",
|
||||||
Err: syscall.ENOENT,
|
Err: syscall.ENOENT,
|
||||||
}
|
}
|
||||||
if err := createFile(path.Join(Nonexistent, ":3"), 0644, 0755, nil); !reflect.DeepEqual(err, wantErr) {
|
if err := createFile(filepath.Join(Nonexistent, ":3"), 0644, 0755, nil); !reflect.DeepEqual(err, wantErr) {
|
||||||
t.Errorf("createFile: error = %#v, want %#v", err, wantErr)
|
t.Errorf("createFile: error = %#v, want %#v", err, wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -72,7 +72,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
Path: "/proc/nonexistent",
|
Path: "/proc/nonexistent",
|
||||||
Err: syscall.ENOENT,
|
Err: syscall.ENOENT,
|
||||||
}
|
}
|
||||||
if err := createFile(path.Join(Nonexistent), 0644, 0755, nil); !reflect.DeepEqual(err, wantErr) {
|
if err := createFile(filepath.Join(Nonexistent), 0644, 0755, nil); !reflect.DeepEqual(err, wantErr) {
|
||||||
t.Errorf("createFile: error = %#v, want %#v", err, wantErr)
|
t.Errorf("createFile: error = %#v, want %#v", err, wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -80,7 +80,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("touch", func(t *testing.T) {
|
t.Run("touch", func(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
pathname := path.Join(tempDir, "empty")
|
pathname := filepath.Join(tempDir, "empty")
|
||||||
if err := createFile(pathname, 0644, 0755, nil); err != nil {
|
if err := createFile(pathname, 0644, 0755, nil); err != nil {
|
||||||
t.Fatalf("createFile: error = %v", err)
|
t.Fatalf("createFile: error = %v", err)
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("write", func(t *testing.T) {
|
t.Run("write", func(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
pathname := path.Join(tempDir, "zero")
|
pathname := filepath.Join(tempDir, "zero")
|
||||||
if err := createFile(pathname, 0644, 0755, []byte{0}); err != nil {
|
if err := createFile(pathname, 0644, 0755, []byte{0}); err != nil {
|
||||||
t.Fatalf("createFile: error = %v", err)
|
t.Fatalf("createFile: error = %v", err)
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestEnsureFile(t *testing.T) {
|
func TestEnsureFile(t *testing.T) {
|
||||||
t.Run("create", func(t *testing.T) {
|
t.Run("create", func(t *testing.T) {
|
||||||
if err := ensureFile(path.Join(t.TempDir(), "ensure"), 0644, 0755); err != nil {
|
if err := ensureFile(filepath.Join(t.TempDir(), "ensure"), 0644, 0755); err != nil {
|
||||||
t.Errorf("ensureFile: error = %v", err)
|
t.Errorf("ensureFile: error = %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -115,7 +115,7 @@ func TestEnsureFile(t *testing.T) {
|
|||||||
t.Run("stat", func(t *testing.T) {
|
t.Run("stat", func(t *testing.T) {
|
||||||
t.Run("inaccessible", func(t *testing.T) {
|
t.Run("inaccessible", func(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
pathname := path.Join(tempDir, "inaccessible")
|
pathname := filepath.Join(tempDir, "inaccessible")
|
||||||
if f, err := os.Create(pathname); err != nil {
|
if f, err := os.Create(pathname); err != nil {
|
||||||
t.Fatalf("Create: error = %v", err)
|
t.Fatalf("Create: error = %v", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -150,7 +150,7 @@ func TestEnsureFile(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("ensure", func(t *testing.T) {
|
t.Run("ensure", func(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
pathname := path.Join(tempDir, "ensure")
|
pathname := filepath.Join(tempDir, "ensure")
|
||||||
if f, err := os.Create(pathname); err != nil {
|
if f, err := os.Create(pathname); err != nil {
|
||||||
t.Fatalf("Create: error = %v", err)
|
t.Fatalf("Create: error = %v", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -195,12 +195,12 @@ func TestProcPaths(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("sample", func(t *testing.T) {
|
t.Run("sample", func(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
if err := os.MkdirAll(path.Join(tempDir, "proc/self"), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Join(tempDir, "proc/self"), 0755); err != nil {
|
||||||
t.Fatalf("MkdirAll: error = %v", err)
|
t.Fatalf("MkdirAll: error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("clean", func(t *testing.T) {
|
t.Run("clean", func(t *testing.T) {
|
||||||
if err := os.WriteFile(path.Join(tempDir, "proc/self/mountinfo"), []byte(`15 20 0:3 / /proc rw,relatime - proc /proc rw
|
if err := os.WriteFile(filepath.Join(tempDir, "proc/self/mountinfo"), []byte(`15 20 0:3 / /proc rw,relatime - proc /proc rw
|
||||||
16 20 0:15 / /sys rw,relatime - sysfs /sys rw
|
16 20 0:15 / /sys rw,relatime - sysfs /sys rw
|
||||||
17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755`), 0644); err != nil {
|
17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755`), 0644); err != nil {
|
||||||
t.Fatalf("WriteFile: error = %v", err)
|
t.Fatalf("WriteFile: error = %v", err)
|
||||||
@@ -243,8 +243,8 @@ func TestProcPaths(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("malformed", func(t *testing.T) {
|
t.Run("malformed", func(t *testing.T) {
|
||||||
path.Join(tempDir, "proc/self/mountinfo")
|
filepath.Join(tempDir, "proc/self/mountinfo")
|
||||||
if err := os.WriteFile(path.Join(tempDir, "proc/self/mountinfo"), []byte{0}, 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tempDir, "proc/self/mountinfo"), []byte{0}, 0644); err != nil {
|
||||||
t.Fatalf("WriteFile: error = %v", err)
|
t.Fatalf("WriteFile: error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrInvalidRules is returned for a zero-length rules slice.
|
// ErrInvalidRules is returned for a zero-length rules slice.
|
||||||
@@ -219,9 +220,9 @@ const (
|
|||||||
|
|
||||||
// syscallResolveName resolves a syscall number by name via seccomp_syscall_resolve_name.
|
// syscallResolveName resolves a syscall number by name via seccomp_syscall_resolve_name.
|
||||||
// This function is only for testing the lookup tables and included here for convenience.
|
// This function is only for testing the lookup tables and included here for convenience.
|
||||||
func syscallResolveName(s string) (num std.ScmpSyscall, ok bool) {
|
func syscallResolveName(s string) (num ext.SyscallNum, ok bool) {
|
||||||
v := C.CString(s)
|
v := C.CString(s)
|
||||||
num = std.ScmpSyscall(C.seccomp_syscall_resolve_name(v))
|
num = ext.SyscallNum(C.seccomp_syscall_resolve_name(v))
|
||||||
C.free(unsafe.Pointer(v))
|
C.free(unsafe.Pointer(v))
|
||||||
ok = num != C.__NR_SCMP_ERROR
|
ok = num != C.__NR_SCMP_ERROR
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
. "syscall"
|
. "syscall"
|
||||||
|
|
||||||
. "hakurei.app/container/std"
|
. "hakurei.app/container/std"
|
||||||
|
. "hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Preset(presets FilterPreset, flags ExportFlag) (rules []NativeRule) {
|
func Preset(presets FilterPreset, flags ExportFlag) (rules []NativeRule) {
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/container/std"
|
||||||
|
"hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSyscallResolveName(t *testing.T) {
|
func TestSyscallResolveName(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
for name, want := range std.Syscalls() {
|
for name, want := range ext.Syscalls() {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -24,8 +25,10 @@ func TestSyscallResolveName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRuleType(t *testing.T) {
|
func TestRuleType(t *testing.T) {
|
||||||
assertKind[std.Uint, scmpUint](t)
|
assertKind[ext.Uint, scmpUint](t)
|
||||||
assertKind[std.Int, scmpInt](t)
|
assertOverflow(t, ext.Uint(ext.MaxUint))
|
||||||
|
assertKind[ext.Int, scmpInt](t)
|
||||||
|
assertOverflow(t, ext.Int(ext.MaxInt))
|
||||||
|
|
||||||
assertSize[std.NativeRule, syscallRule](t)
|
assertSize[std.NativeRule, syscallRule](t)
|
||||||
assertKind[std.ScmpDatum, scmpDatum](t)
|
assertKind[std.ScmpDatum, scmpDatum](t)
|
||||||
@@ -61,3 +64,14 @@ func assertKind[native, equivalent any](t *testing.T) {
|
|||||||
t.Fatalf("%s: %s, want %s", nativeType.Name(), nativeType.Kind(), equivalentType.Kind())
|
t.Fatalf("%s: %s, want %s", nativeType.Name(), nativeType.Kind(), equivalentType.Kind())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assertOverflow asserts that incrementing m overflows.
|
||||||
|
func assertOverflow[T ~int32 | ~uint32](t *testing.T, m T) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
old := m
|
||||||
|
m++
|
||||||
|
if m > old {
|
||||||
|
t.Fatalf("unexpected value %#x", m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,34 +1,20 @@
|
|||||||
package std
|
package std
|
||||||
|
|
||||||
import (
|
import "hakurei.app/ext"
|
||||||
"encoding/json"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// ScmpUint is equivalent to C.uint.
|
|
||||||
//
|
|
||||||
// Deprecated: This type has been renamed to Uint and will be removed in 0.4.
|
|
||||||
ScmpUint = Uint
|
|
||||||
// ScmpInt is equivalent to C.int.
|
|
||||||
//
|
|
||||||
// Deprecated: This type has been renamed to Int and will be removed in 0.4.
|
|
||||||
ScmpInt = Int
|
|
||||||
|
|
||||||
// ScmpSyscall represents a syscall number passed to libseccomp via [NativeRule.Syscall].
|
|
||||||
ScmpSyscall Int
|
|
||||||
// ScmpErrno represents an errno value passed to libseccomp via [NativeRule.Errno].
|
// ScmpErrno represents an errno value passed to libseccomp via [NativeRule.Errno].
|
||||||
ScmpErrno Int
|
ScmpErrno = ext.Int
|
||||||
|
|
||||||
// ScmpCompare is equivalent to enum scmp_compare;
|
// ScmpCompare is equivalent to enum scmp_compare;
|
||||||
ScmpCompare Uint
|
ScmpCompare = ext.Uint
|
||||||
// ScmpDatum is equivalent to scmp_datum_t.
|
// ScmpDatum is equivalent to scmp_datum_t.
|
||||||
ScmpDatum uint64
|
ScmpDatum = uint64
|
||||||
|
|
||||||
// ScmpArgCmp is equivalent to struct scmp_arg_cmp.
|
// ScmpArgCmp is equivalent to struct scmp_arg_cmp.
|
||||||
ScmpArgCmp struct {
|
ScmpArgCmp struct {
|
||||||
// argument number, starting at 0
|
// argument number, starting at 0
|
||||||
Arg Uint `json:"arg"`
|
Arg ext.Uint `json:"arg"`
|
||||||
// the comparison op, e.g. SCMP_CMP_*
|
// the comparison op, e.g. SCMP_CMP_*
|
||||||
Op ScmpCompare `json:"op"`
|
Op ScmpCompare `json:"op"`
|
||||||
|
|
||||||
@@ -39,42 +25,10 @@ type (
|
|||||||
// A NativeRule specifies an arch-specific action taken by seccomp under certain conditions.
|
// A NativeRule specifies an arch-specific action taken by seccomp under certain conditions.
|
||||||
NativeRule struct {
|
NativeRule struct {
|
||||||
// Syscall is the arch-dependent syscall number to act against.
|
// Syscall is the arch-dependent syscall number to act against.
|
||||||
Syscall ScmpSyscall `json:"syscall"`
|
Syscall ext.SyscallNum `json:"syscall"`
|
||||||
// Errno is the errno value to return when the condition is satisfied.
|
// Errno is the errno value to return when the condition is satisfied.
|
||||||
Errno ScmpErrno `json:"errno"`
|
Errno ScmpErrno `json:"errno"`
|
||||||
// Arg is the optional struct scmp_arg_cmp passed to libseccomp.
|
// Arg is the optional struct scmp_arg_cmp passed to libseccomp.
|
||||||
Arg *ScmpArgCmp `json:"arg,omitempty"`
|
Arg *ScmpArgCmp `json:"arg,omitempty"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// MarshalJSON resolves the name of [ScmpSyscall] and encodes it as a [json] string.
|
|
||||||
// If such a name does not exist, the syscall number is encoded instead.
|
|
||||||
func (num *ScmpSyscall) MarshalJSON() ([]byte, error) {
|
|
||||||
n := *num
|
|
||||||
for name, cur := range Syscalls() {
|
|
||||||
if cur == n {
|
|
||||||
return json.Marshal(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return json.Marshal(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SyscallNameError is returned when trying to unmarshal an invalid syscall name into [ScmpSyscall].
|
|
||||||
type SyscallNameError string
|
|
||||||
|
|
||||||
func (e SyscallNameError) Error() string { return "invalid syscall name " + strconv.Quote(string(e)) }
|
|
||||||
|
|
||||||
// UnmarshalJSON looks up the syscall number corresponding to name encoded in data
|
|
||||||
// by calling [SyscallResolveName].
|
|
||||||
func (num *ScmpSyscall) UnmarshalJSON(data []byte) error {
|
|
||||||
var name string
|
|
||||||
if err := json.Unmarshal(data, &name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if n, ok := SyscallResolveName(name); !ok {
|
|
||||||
return SyscallNameError(name)
|
|
||||||
} else {
|
|
||||||
*num = n
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
import "iter"
|
|
||||||
|
|
||||||
// Syscalls returns an iterator over all wired syscalls.
|
|
||||||
func Syscalls() iter.Seq2[string, ScmpSyscall] {
|
|
||||||
return func(yield func(string, ScmpSyscall) bool) {
|
|
||||||
for name, num := range syscallNum {
|
|
||||||
if !yield(name, num) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for name, num := range syscallNumExtra {
|
|
||||||
if !yield(name, num) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SyscallResolveName resolves a syscall number from its string representation.
|
|
||||||
func SyscallResolveName(name string) (num ScmpSyscall, ok bool) {
|
|
||||||
if num, ok = syscallNum[name]; ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
num, ok = syscallNumExtra[name]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
var syscallNumExtra = map[string]ScmpSyscall{
|
|
||||||
"kexec_file_load": SNR_KEXEC_FILE_LOAD,
|
|
||||||
"subpage_prot": SNR_SUBPAGE_PROT,
|
|
||||||
"switch_endian": SNR_SWITCH_ENDIAN,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_KEXEC_FILE_LOAD ScmpSyscall = __PNR_kexec_file_load
|
|
||||||
SNR_SUBPAGE_PROT ScmpSyscall = __PNR_subpage_prot
|
|
||||||
SNR_SWITCH_ENDIAN ScmpSyscall = __PNR_switch_endian
|
|
||||||
)
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
var syscallNumExtra = map[string]ScmpSyscall{
|
|
||||||
"umount": SNR_UMOUNT,
|
|
||||||
"subpage_prot": SNR_SUBPAGE_PROT,
|
|
||||||
"switch_endian": SNR_SWITCH_ENDIAN,
|
|
||||||
"vm86": SNR_VM86,
|
|
||||||
"vm86old": SNR_VM86OLD,
|
|
||||||
"clock_adjtime64": SNR_CLOCK_ADJTIME64,
|
|
||||||
"clock_settime64": SNR_CLOCK_SETTIME64,
|
|
||||||
"chown32": SNR_CHOWN32,
|
|
||||||
"fchown32": SNR_FCHOWN32,
|
|
||||||
"lchown32": SNR_LCHOWN32,
|
|
||||||
"setgid32": SNR_SETGID32,
|
|
||||||
"setgroups32": SNR_SETGROUPS32,
|
|
||||||
"setregid32": SNR_SETREGID32,
|
|
||||||
"setresgid32": SNR_SETRESGID32,
|
|
||||||
"setresuid32": SNR_SETRESUID32,
|
|
||||||
"setreuid32": SNR_SETREUID32,
|
|
||||||
"setuid32": SNR_SETUID32,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_UMOUNT ScmpSyscall = __PNR_umount
|
|
||||||
SNR_SUBPAGE_PROT ScmpSyscall = __PNR_subpage_prot
|
|
||||||
SNR_SWITCH_ENDIAN ScmpSyscall = __PNR_switch_endian
|
|
||||||
SNR_VM86 ScmpSyscall = __PNR_vm86
|
|
||||||
SNR_VM86OLD ScmpSyscall = __PNR_vm86old
|
|
||||||
SNR_CLOCK_ADJTIME64 ScmpSyscall = __PNR_clock_adjtime64
|
|
||||||
SNR_CLOCK_SETTIME64 ScmpSyscall = __PNR_clock_settime64
|
|
||||||
SNR_CHOWN32 ScmpSyscall = __PNR_chown32
|
|
||||||
SNR_FCHOWN32 ScmpSyscall = __PNR_fchown32
|
|
||||||
SNR_LCHOWN32 ScmpSyscall = __PNR_lchown32
|
|
||||||
SNR_SETGID32 ScmpSyscall = __PNR_setgid32
|
|
||||||
SNR_SETGROUPS32 ScmpSyscall = __PNR_setgroups32
|
|
||||||
SNR_SETREGID32 ScmpSyscall = __PNR_setregid32
|
|
||||||
SNR_SETRESGID32 ScmpSyscall = __PNR_setresgid32
|
|
||||||
SNR_SETRESUID32 ScmpSyscall = __PNR_setresuid32
|
|
||||||
SNR_SETREUID32 ScmpSyscall = __PNR_setreuid32
|
|
||||||
SNR_SETUID32 ScmpSyscall = __PNR_setuid32
|
|
||||||
)
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_NEWFSTATAT = syscall.SYS_FSTATAT
|
|
||||||
)
|
|
||||||
|
|
||||||
var syscallNumExtra = map[string]ScmpSyscall{
|
|
||||||
"uselib": SNR_USELIB,
|
|
||||||
"clock_adjtime64": SNR_CLOCK_ADJTIME64,
|
|
||||||
"clock_settime64": SNR_CLOCK_SETTIME64,
|
|
||||||
"umount": SNR_UMOUNT,
|
|
||||||
"chown": SNR_CHOWN,
|
|
||||||
"chown32": SNR_CHOWN32,
|
|
||||||
"fchown32": SNR_FCHOWN32,
|
|
||||||
"lchown": SNR_LCHOWN,
|
|
||||||
"lchown32": SNR_LCHOWN32,
|
|
||||||
"setgid32": SNR_SETGID32,
|
|
||||||
"setgroups32": SNR_SETGROUPS32,
|
|
||||||
"setregid32": SNR_SETREGID32,
|
|
||||||
"setresgid32": SNR_SETRESGID32,
|
|
||||||
"setresuid32": SNR_SETRESUID32,
|
|
||||||
"setreuid32": SNR_SETREUID32,
|
|
||||||
"setuid32": SNR_SETUID32,
|
|
||||||
"modify_ldt": SNR_MODIFY_LDT,
|
|
||||||
"subpage_prot": SNR_SUBPAGE_PROT,
|
|
||||||
"switch_endian": SNR_SWITCH_ENDIAN,
|
|
||||||
"vm86": SNR_VM86,
|
|
||||||
"vm86old": SNR_VM86OLD,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_USELIB ScmpSyscall = __PNR_uselib
|
|
||||||
SNR_CLOCK_ADJTIME64 ScmpSyscall = __PNR_clock_adjtime64
|
|
||||||
SNR_CLOCK_SETTIME64 ScmpSyscall = __PNR_clock_settime64
|
|
||||||
SNR_UMOUNT ScmpSyscall = __PNR_umount
|
|
||||||
SNR_CHOWN ScmpSyscall = __PNR_chown
|
|
||||||
SNR_CHOWN32 ScmpSyscall = __PNR_chown32
|
|
||||||
SNR_FCHOWN32 ScmpSyscall = __PNR_fchown32
|
|
||||||
SNR_LCHOWN ScmpSyscall = __PNR_lchown
|
|
||||||
SNR_LCHOWN32 ScmpSyscall = __PNR_lchown32
|
|
||||||
SNR_SETGID32 ScmpSyscall = __PNR_setgid32
|
|
||||||
SNR_SETGROUPS32 ScmpSyscall = __PNR_setgroups32
|
|
||||||
SNR_SETREGID32 ScmpSyscall = __PNR_setregid32
|
|
||||||
SNR_SETRESGID32 ScmpSyscall = __PNR_setresgid32
|
|
||||||
SNR_SETRESUID32 ScmpSyscall = __PNR_setresuid32
|
|
||||||
SNR_SETREUID32 ScmpSyscall = __PNR_setreuid32
|
|
||||||
SNR_SETUID32 ScmpSyscall = __PNR_setuid32
|
|
||||||
SNR_MODIFY_LDT ScmpSyscall = __PNR_modify_ldt
|
|
||||||
SNR_SUBPAGE_PROT ScmpSyscall = __PNR_subpage_prot
|
|
||||||
SNR_SWITCH_ENDIAN ScmpSyscall = __PNR_switch_endian
|
|
||||||
SNR_VM86 ScmpSyscall = __PNR_vm86
|
|
||||||
SNR_VM86OLD ScmpSyscall = __PNR_vm86old
|
|
||||||
)
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_NEWFSTATAT = syscall.SYS_FSTATAT
|
|
||||||
)
|
|
||||||
|
|
||||||
var syscallNumExtra = map[string]ScmpSyscall{
|
|
||||||
"uselib": SNR_USELIB,
|
|
||||||
"clock_adjtime64": SNR_CLOCK_ADJTIME64,
|
|
||||||
"clock_settime64": SNR_CLOCK_SETTIME64,
|
|
||||||
"umount": SNR_UMOUNT,
|
|
||||||
"chown": SNR_CHOWN,
|
|
||||||
"chown32": SNR_CHOWN32,
|
|
||||||
"fchown32": SNR_FCHOWN32,
|
|
||||||
"lchown": SNR_LCHOWN,
|
|
||||||
"lchown32": SNR_LCHOWN32,
|
|
||||||
"setgid32": SNR_SETGID32,
|
|
||||||
"setgroups32": SNR_SETGROUPS32,
|
|
||||||
"setregid32": SNR_SETREGID32,
|
|
||||||
"setresgid32": SNR_SETRESGID32,
|
|
||||||
"setresuid32": SNR_SETRESUID32,
|
|
||||||
"setreuid32": SNR_SETREUID32,
|
|
||||||
"setuid32": SNR_SETUID32,
|
|
||||||
"modify_ldt": SNR_MODIFY_LDT,
|
|
||||||
"subpage_prot": SNR_SUBPAGE_PROT,
|
|
||||||
"switch_endian": SNR_SWITCH_ENDIAN,
|
|
||||||
"vm86": SNR_VM86,
|
|
||||||
"vm86old": SNR_VM86OLD,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_USELIB ScmpSyscall = __PNR_uselib
|
|
||||||
SNR_CLOCK_ADJTIME64 ScmpSyscall = __PNR_clock_adjtime64
|
|
||||||
SNR_CLOCK_SETTIME64 ScmpSyscall = __PNR_clock_settime64
|
|
||||||
SNR_UMOUNT ScmpSyscall = __PNR_umount
|
|
||||||
SNR_CHOWN ScmpSyscall = __PNR_chown
|
|
||||||
SNR_CHOWN32 ScmpSyscall = __PNR_chown32
|
|
||||||
SNR_FCHOWN32 ScmpSyscall = __PNR_fchown32
|
|
||||||
SNR_LCHOWN ScmpSyscall = __PNR_lchown
|
|
||||||
SNR_LCHOWN32 ScmpSyscall = __PNR_lchown32
|
|
||||||
SNR_SETGID32 ScmpSyscall = __PNR_setgid32
|
|
||||||
SNR_SETGROUPS32 ScmpSyscall = __PNR_setgroups32
|
|
||||||
SNR_SETREGID32 ScmpSyscall = __PNR_setregid32
|
|
||||||
SNR_SETRESGID32 ScmpSyscall = __PNR_setresgid32
|
|
||||||
SNR_SETRESUID32 ScmpSyscall = __PNR_setresuid32
|
|
||||||
SNR_SETREUID32 ScmpSyscall = __PNR_setreuid32
|
|
||||||
SNR_SETUID32 ScmpSyscall = __PNR_setuid32
|
|
||||||
SNR_MODIFY_LDT ScmpSyscall = __PNR_modify_ldt
|
|
||||||
SNR_SUBPAGE_PROT ScmpSyscall = __PNR_subpage_prot
|
|
||||||
SNR_SWITCH_ENDIAN ScmpSyscall = __PNR_switch_endian
|
|
||||||
SNR_VM86 ScmpSyscall = __PNR_vm86
|
|
||||||
SNR_VM86OLD ScmpSyscall = __PNR_vm86old
|
|
||||||
)
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,837 +0,0 @@
|
|||||||
// mksysnum_linux.pl /usr/include/asm/unistd_64.h
|
|
||||||
// Code generated by the command above; DO NOT EDIT.
|
|
||||||
|
|
||||||
package std
|
|
||||||
|
|
||||||
import . "syscall"
|
|
||||||
|
|
||||||
var syscallNum = map[string]ScmpSyscall{
|
|
||||||
"read": SNR_READ,
|
|
||||||
"write": SNR_WRITE,
|
|
||||||
"open": SNR_OPEN,
|
|
||||||
"close": SNR_CLOSE,
|
|
||||||
"stat": SNR_STAT,
|
|
||||||
"fstat": SNR_FSTAT,
|
|
||||||
"lstat": SNR_LSTAT,
|
|
||||||
"poll": SNR_POLL,
|
|
||||||
"lseek": SNR_LSEEK,
|
|
||||||
"mmap": SNR_MMAP,
|
|
||||||
"mprotect": SNR_MPROTECT,
|
|
||||||
"munmap": SNR_MUNMAP,
|
|
||||||
"brk": SNR_BRK,
|
|
||||||
"rt_sigaction": SNR_RT_SIGACTION,
|
|
||||||
"rt_sigprocmask": SNR_RT_SIGPROCMASK,
|
|
||||||
"rt_sigreturn": SNR_RT_SIGRETURN,
|
|
||||||
"ioctl": SNR_IOCTL,
|
|
||||||
"pread64": SNR_PREAD64,
|
|
||||||
"pwrite64": SNR_PWRITE64,
|
|
||||||
"readv": SNR_READV,
|
|
||||||
"writev": SNR_WRITEV,
|
|
||||||
"access": SNR_ACCESS,
|
|
||||||
"pipe": SNR_PIPE,
|
|
||||||
"select": SNR_SELECT,
|
|
||||||
"sched_yield": SNR_SCHED_YIELD,
|
|
||||||
"mremap": SNR_MREMAP,
|
|
||||||
"msync": SNR_MSYNC,
|
|
||||||
"mincore": SNR_MINCORE,
|
|
||||||
"madvise": SNR_MADVISE,
|
|
||||||
"shmget": SNR_SHMGET,
|
|
||||||
"shmat": SNR_SHMAT,
|
|
||||||
"shmctl": SNR_SHMCTL,
|
|
||||||
"dup": SNR_DUP,
|
|
||||||
"dup2": SNR_DUP2,
|
|
||||||
"pause": SNR_PAUSE,
|
|
||||||
"nanosleep": SNR_NANOSLEEP,
|
|
||||||
"getitimer": SNR_GETITIMER,
|
|
||||||
"alarm": SNR_ALARM,
|
|
||||||
"setitimer": SNR_SETITIMER,
|
|
||||||
"getpid": SNR_GETPID,
|
|
||||||
"sendfile": SNR_SENDFILE,
|
|
||||||
"socket": SNR_SOCKET,
|
|
||||||
"connect": SNR_CONNECT,
|
|
||||||
"accept": SNR_ACCEPT,
|
|
||||||
"sendto": SNR_SENDTO,
|
|
||||||
"recvfrom": SNR_RECVFROM,
|
|
||||||
"sendmsg": SNR_SENDMSG,
|
|
||||||
"recvmsg": SNR_RECVMSG,
|
|
||||||
"shutdown": SNR_SHUTDOWN,
|
|
||||||
"bind": SNR_BIND,
|
|
||||||
"listen": SNR_LISTEN,
|
|
||||||
"getsockname": SNR_GETSOCKNAME,
|
|
||||||
"getpeername": SNR_GETPEERNAME,
|
|
||||||
"socketpair": SNR_SOCKETPAIR,
|
|
||||||
"setsockopt": SNR_SETSOCKOPT,
|
|
||||||
"getsockopt": SNR_GETSOCKOPT,
|
|
||||||
"clone": SNR_CLONE,
|
|
||||||
"fork": SNR_FORK,
|
|
||||||
"vfork": SNR_VFORK,
|
|
||||||
"execve": SNR_EXECVE,
|
|
||||||
"exit": SNR_EXIT,
|
|
||||||
"wait4": SNR_WAIT4,
|
|
||||||
"kill": SNR_KILL,
|
|
||||||
"uname": SNR_UNAME,
|
|
||||||
"semget": SNR_SEMGET,
|
|
||||||
"semop": SNR_SEMOP,
|
|
||||||
"semctl": SNR_SEMCTL,
|
|
||||||
"shmdt": SNR_SHMDT,
|
|
||||||
"msgget": SNR_MSGGET,
|
|
||||||
"msgsnd": SNR_MSGSND,
|
|
||||||
"msgrcv": SNR_MSGRCV,
|
|
||||||
"msgctl": SNR_MSGCTL,
|
|
||||||
"fcntl": SNR_FCNTL,
|
|
||||||
"flock": SNR_FLOCK,
|
|
||||||
"fsync": SNR_FSYNC,
|
|
||||||
"fdatasync": SNR_FDATASYNC,
|
|
||||||
"truncate": SNR_TRUNCATE,
|
|
||||||
"ftruncate": SNR_FTRUNCATE,
|
|
||||||
"getdents": SNR_GETDENTS,
|
|
||||||
"getcwd": SNR_GETCWD,
|
|
||||||
"chdir": SNR_CHDIR,
|
|
||||||
"fchdir": SNR_FCHDIR,
|
|
||||||
"rename": SNR_RENAME,
|
|
||||||
"mkdir": SNR_MKDIR,
|
|
||||||
"rmdir": SNR_RMDIR,
|
|
||||||
"creat": SNR_CREAT,
|
|
||||||
"link": SNR_LINK,
|
|
||||||
"unlink": SNR_UNLINK,
|
|
||||||
"symlink": SNR_SYMLINK,
|
|
||||||
"readlink": SNR_READLINK,
|
|
||||||
"chmod": SNR_CHMOD,
|
|
||||||
"fchmod": SNR_FCHMOD,
|
|
||||||
"chown": SNR_CHOWN,
|
|
||||||
"fchown": SNR_FCHOWN,
|
|
||||||
"lchown": SNR_LCHOWN,
|
|
||||||
"umask": SNR_UMASK,
|
|
||||||
"gettimeofday": SNR_GETTIMEOFDAY,
|
|
||||||
"getrlimit": SNR_GETRLIMIT,
|
|
||||||
"getrusage": SNR_GETRUSAGE,
|
|
||||||
"sysinfo": SNR_SYSINFO,
|
|
||||||
"times": SNR_TIMES,
|
|
||||||
"ptrace": SNR_PTRACE,
|
|
||||||
"getuid": SNR_GETUID,
|
|
||||||
"syslog": SNR_SYSLOG,
|
|
||||||
"getgid": SNR_GETGID,
|
|
||||||
"setuid": SNR_SETUID,
|
|
||||||
"setgid": SNR_SETGID,
|
|
||||||
"geteuid": SNR_GETEUID,
|
|
||||||
"getegid": SNR_GETEGID,
|
|
||||||
"setpgid": SNR_SETPGID,
|
|
||||||
"getppid": SNR_GETPPID,
|
|
||||||
"getpgrp": SNR_GETPGRP,
|
|
||||||
"setsid": SNR_SETSID,
|
|
||||||
"setreuid": SNR_SETREUID,
|
|
||||||
"setregid": SNR_SETREGID,
|
|
||||||
"getgroups": SNR_GETGROUPS,
|
|
||||||
"setgroups": SNR_SETGROUPS,
|
|
||||||
"setresuid": SNR_SETRESUID,
|
|
||||||
"getresuid": SNR_GETRESUID,
|
|
||||||
"setresgid": SNR_SETRESGID,
|
|
||||||
"getresgid": SNR_GETRESGID,
|
|
||||||
"getpgid": SNR_GETPGID,
|
|
||||||
"setfsuid": SNR_SETFSUID,
|
|
||||||
"setfsgid": SNR_SETFSGID,
|
|
||||||
"getsid": SNR_GETSID,
|
|
||||||
"capget": SNR_CAPGET,
|
|
||||||
"capset": SNR_CAPSET,
|
|
||||||
"rt_sigpending": SNR_RT_SIGPENDING,
|
|
||||||
"rt_sigtimedwait": SNR_RT_SIGTIMEDWAIT,
|
|
||||||
"rt_sigqueueinfo": SNR_RT_SIGQUEUEINFO,
|
|
||||||
"rt_sigsuspend": SNR_RT_SIGSUSPEND,
|
|
||||||
"sigaltstack": SNR_SIGALTSTACK,
|
|
||||||
"utime": SNR_UTIME,
|
|
||||||
"mknod": SNR_MKNOD,
|
|
||||||
"uselib": SNR_USELIB,
|
|
||||||
"personality": SNR_PERSONALITY,
|
|
||||||
"ustat": SNR_USTAT,
|
|
||||||
"statfs": SNR_STATFS,
|
|
||||||
"fstatfs": SNR_FSTATFS,
|
|
||||||
"sysfs": SNR_SYSFS,
|
|
||||||
"getpriority": SNR_GETPRIORITY,
|
|
||||||
"setpriority": SNR_SETPRIORITY,
|
|
||||||
"sched_setparam": SNR_SCHED_SETPARAM,
|
|
||||||
"sched_getparam": SNR_SCHED_GETPARAM,
|
|
||||||
"sched_setscheduler": SNR_SCHED_SETSCHEDULER,
|
|
||||||
"sched_getscheduler": SNR_SCHED_GETSCHEDULER,
|
|
||||||
"sched_get_priority_max": SNR_SCHED_GET_PRIORITY_MAX,
|
|
||||||
"sched_get_priority_min": SNR_SCHED_GET_PRIORITY_MIN,
|
|
||||||
"sched_rr_get_interval": SNR_SCHED_RR_GET_INTERVAL,
|
|
||||||
"mlock": SNR_MLOCK,
|
|
||||||
"munlock": SNR_MUNLOCK,
|
|
||||||
"mlockall": SNR_MLOCKALL,
|
|
||||||
"munlockall": SNR_MUNLOCKALL,
|
|
||||||
"vhangup": SNR_VHANGUP,
|
|
||||||
"modify_ldt": SNR_MODIFY_LDT,
|
|
||||||
"pivot_root": SNR_PIVOT_ROOT,
|
|
||||||
"_sysctl": SNR__SYSCTL,
|
|
||||||
"prctl": SNR_PRCTL,
|
|
||||||
"arch_prctl": SNR_ARCH_PRCTL,
|
|
||||||
"adjtimex": SNR_ADJTIMEX,
|
|
||||||
"setrlimit": SNR_SETRLIMIT,
|
|
||||||
"chroot": SNR_CHROOT,
|
|
||||||
"sync": SNR_SYNC,
|
|
||||||
"acct": SNR_ACCT,
|
|
||||||
"settimeofday": SNR_SETTIMEOFDAY,
|
|
||||||
"mount": SNR_MOUNT,
|
|
||||||
"umount2": SNR_UMOUNT2,
|
|
||||||
"swapon": SNR_SWAPON,
|
|
||||||
"swapoff": SNR_SWAPOFF,
|
|
||||||
"reboot": SNR_REBOOT,
|
|
||||||
"sethostname": SNR_SETHOSTNAME,
|
|
||||||
"setdomainname": SNR_SETDOMAINNAME,
|
|
||||||
"iopl": SNR_IOPL,
|
|
||||||
"ioperm": SNR_IOPERM,
|
|
||||||
"create_module": SNR_CREATE_MODULE,
|
|
||||||
"init_module": SNR_INIT_MODULE,
|
|
||||||
"delete_module": SNR_DELETE_MODULE,
|
|
||||||
"get_kernel_syms": SNR_GET_KERNEL_SYMS,
|
|
||||||
"query_module": SNR_QUERY_MODULE,
|
|
||||||
"quotactl": SNR_QUOTACTL,
|
|
||||||
"nfsservctl": SNR_NFSSERVCTL,
|
|
||||||
"getpmsg": SNR_GETPMSG,
|
|
||||||
"putpmsg": SNR_PUTPMSG,
|
|
||||||
"afs_syscall": SNR_AFS_SYSCALL,
|
|
||||||
"tuxcall": SNR_TUXCALL,
|
|
||||||
"security": SNR_SECURITY,
|
|
||||||
"gettid": SNR_GETTID,
|
|
||||||
"readahead": SNR_READAHEAD,
|
|
||||||
"setxattr": SNR_SETXATTR,
|
|
||||||
"lsetxattr": SNR_LSETXATTR,
|
|
||||||
"fsetxattr": SNR_FSETXATTR,
|
|
||||||
"getxattr": SNR_GETXATTR,
|
|
||||||
"lgetxattr": SNR_LGETXATTR,
|
|
||||||
"fgetxattr": SNR_FGETXATTR,
|
|
||||||
"listxattr": SNR_LISTXATTR,
|
|
||||||
"llistxattr": SNR_LLISTXATTR,
|
|
||||||
"flistxattr": SNR_FLISTXATTR,
|
|
||||||
"removexattr": SNR_REMOVEXATTR,
|
|
||||||
"lremovexattr": SNR_LREMOVEXATTR,
|
|
||||||
"fremovexattr": SNR_FREMOVEXATTR,
|
|
||||||
"tkill": SNR_TKILL,
|
|
||||||
"time": SNR_TIME,
|
|
||||||
"futex": SNR_FUTEX,
|
|
||||||
"sched_setaffinity": SNR_SCHED_SETAFFINITY,
|
|
||||||
"sched_getaffinity": SNR_SCHED_GETAFFINITY,
|
|
||||||
"set_thread_area": SNR_SET_THREAD_AREA,
|
|
||||||
"io_setup": SNR_IO_SETUP,
|
|
||||||
"io_destroy": SNR_IO_DESTROY,
|
|
||||||
"io_getevents": SNR_IO_GETEVENTS,
|
|
||||||
"io_submit": SNR_IO_SUBMIT,
|
|
||||||
"io_cancel": SNR_IO_CANCEL,
|
|
||||||
"get_thread_area": SNR_GET_THREAD_AREA,
|
|
||||||
"lookup_dcookie": SNR_LOOKUP_DCOOKIE,
|
|
||||||
"epoll_create": SNR_EPOLL_CREATE,
|
|
||||||
"epoll_ctl_old": SNR_EPOLL_CTL_OLD,
|
|
||||||
"epoll_wait_old": SNR_EPOLL_WAIT_OLD,
|
|
||||||
"remap_file_pages": SNR_REMAP_FILE_PAGES,
|
|
||||||
"getdents64": SNR_GETDENTS64,
|
|
||||||
"set_tid_address": SNR_SET_TID_ADDRESS,
|
|
||||||
"restart_syscall": SNR_RESTART_SYSCALL,
|
|
||||||
"semtimedop": SNR_SEMTIMEDOP,
|
|
||||||
"fadvise64": SNR_FADVISE64,
|
|
||||||
"timer_create": SNR_TIMER_CREATE,
|
|
||||||
"timer_settime": SNR_TIMER_SETTIME,
|
|
||||||
"timer_gettime": SNR_TIMER_GETTIME,
|
|
||||||
"timer_getoverrun": SNR_TIMER_GETOVERRUN,
|
|
||||||
"timer_delete": SNR_TIMER_DELETE,
|
|
||||||
"clock_settime": SNR_CLOCK_SETTIME,
|
|
||||||
"clock_gettime": SNR_CLOCK_GETTIME,
|
|
||||||
"clock_getres": SNR_CLOCK_GETRES,
|
|
||||||
"clock_nanosleep": SNR_CLOCK_NANOSLEEP,
|
|
||||||
"exit_group": SNR_EXIT_GROUP,
|
|
||||||
"epoll_wait": SNR_EPOLL_WAIT,
|
|
||||||
"epoll_ctl": SNR_EPOLL_CTL,
|
|
||||||
"tgkill": SNR_TGKILL,
|
|
||||||
"utimes": SNR_UTIMES,
|
|
||||||
"vserver": SNR_VSERVER,
|
|
||||||
"mbind": SNR_MBIND,
|
|
||||||
"set_mempolicy": SNR_SET_MEMPOLICY,
|
|
||||||
"get_mempolicy": SNR_GET_MEMPOLICY,
|
|
||||||
"mq_open": SNR_MQ_OPEN,
|
|
||||||
"mq_unlink": SNR_MQ_UNLINK,
|
|
||||||
"mq_timedsend": SNR_MQ_TIMEDSEND,
|
|
||||||
"mq_timedreceive": SNR_MQ_TIMEDRECEIVE,
|
|
||||||
"mq_notify": SNR_MQ_NOTIFY,
|
|
||||||
"mq_getsetattr": SNR_MQ_GETSETATTR,
|
|
||||||
"kexec_load": SNR_KEXEC_LOAD,
|
|
||||||
"waitid": SNR_WAITID,
|
|
||||||
"add_key": SNR_ADD_KEY,
|
|
||||||
"request_key": SNR_REQUEST_KEY,
|
|
||||||
"keyctl": SNR_KEYCTL,
|
|
||||||
"ioprio_set": SNR_IOPRIO_SET,
|
|
||||||
"ioprio_get": SNR_IOPRIO_GET,
|
|
||||||
"inotify_init": SNR_INOTIFY_INIT,
|
|
||||||
"inotify_add_watch": SNR_INOTIFY_ADD_WATCH,
|
|
||||||
"inotify_rm_watch": SNR_INOTIFY_RM_WATCH,
|
|
||||||
"migrate_pages": SNR_MIGRATE_PAGES,
|
|
||||||
"openat": SNR_OPENAT,
|
|
||||||
"mkdirat": SNR_MKDIRAT,
|
|
||||||
"mknodat": SNR_MKNODAT,
|
|
||||||
"fchownat": SNR_FCHOWNAT,
|
|
||||||
"futimesat": SNR_FUTIMESAT,
|
|
||||||
"newfstatat": SNR_NEWFSTATAT,
|
|
||||||
"unlinkat": SNR_UNLINKAT,
|
|
||||||
"renameat": SNR_RENAMEAT,
|
|
||||||
"linkat": SNR_LINKAT,
|
|
||||||
"symlinkat": SNR_SYMLINKAT,
|
|
||||||
"readlinkat": SNR_READLINKAT,
|
|
||||||
"fchmodat": SNR_FCHMODAT,
|
|
||||||
"faccessat": SNR_FACCESSAT,
|
|
||||||
"pselect6": SNR_PSELECT6,
|
|
||||||
"ppoll": SNR_PPOLL,
|
|
||||||
"unshare": SNR_UNSHARE,
|
|
||||||
"set_robust_list": SNR_SET_ROBUST_LIST,
|
|
||||||
"get_robust_list": SNR_GET_ROBUST_LIST,
|
|
||||||
"splice": SNR_SPLICE,
|
|
||||||
"tee": SNR_TEE,
|
|
||||||
"sync_file_range": SNR_SYNC_FILE_RANGE,
|
|
||||||
"vmsplice": SNR_VMSPLICE,
|
|
||||||
"move_pages": SNR_MOVE_PAGES,
|
|
||||||
"utimensat": SNR_UTIMENSAT,
|
|
||||||
"epoll_pwait": SNR_EPOLL_PWAIT,
|
|
||||||
"signalfd": SNR_SIGNALFD,
|
|
||||||
"timerfd_create": SNR_TIMERFD_CREATE,
|
|
||||||
"eventfd": SNR_EVENTFD,
|
|
||||||
"fallocate": SNR_FALLOCATE,
|
|
||||||
"timerfd_settime": SNR_TIMERFD_SETTIME,
|
|
||||||
"timerfd_gettime": SNR_TIMERFD_GETTIME,
|
|
||||||
"accept4": SNR_ACCEPT4,
|
|
||||||
"signalfd4": SNR_SIGNALFD4,
|
|
||||||
"eventfd2": SNR_EVENTFD2,
|
|
||||||
"epoll_create1": SNR_EPOLL_CREATE1,
|
|
||||||
"dup3": SNR_DUP3,
|
|
||||||
"pipe2": SNR_PIPE2,
|
|
||||||
"inotify_init1": SNR_INOTIFY_INIT1,
|
|
||||||
"preadv": SNR_PREADV,
|
|
||||||
"pwritev": SNR_PWRITEV,
|
|
||||||
"rt_tgsigqueueinfo": SNR_RT_TGSIGQUEUEINFO,
|
|
||||||
"perf_event_open": SNR_PERF_EVENT_OPEN,
|
|
||||||
"recvmmsg": SNR_RECVMMSG,
|
|
||||||
"fanotify_init": SNR_FANOTIFY_INIT,
|
|
||||||
"fanotify_mark": SNR_FANOTIFY_MARK,
|
|
||||||
"prlimit64": SNR_PRLIMIT64,
|
|
||||||
"name_to_handle_at": SNR_NAME_TO_HANDLE_AT,
|
|
||||||
"open_by_handle_at": SNR_OPEN_BY_HANDLE_AT,
|
|
||||||
"clock_adjtime": SNR_CLOCK_ADJTIME,
|
|
||||||
"syncfs": SNR_SYNCFS,
|
|
||||||
"sendmmsg": SNR_SENDMMSG,
|
|
||||||
"setns": SNR_SETNS,
|
|
||||||
"getcpu": SNR_GETCPU,
|
|
||||||
"process_vm_readv": SNR_PROCESS_VM_READV,
|
|
||||||
"process_vm_writev": SNR_PROCESS_VM_WRITEV,
|
|
||||||
"kcmp": SNR_KCMP,
|
|
||||||
"finit_module": SNR_FINIT_MODULE,
|
|
||||||
"sched_setattr": SNR_SCHED_SETATTR,
|
|
||||||
"sched_getattr": SNR_SCHED_GETATTR,
|
|
||||||
"renameat2": SNR_RENAMEAT2,
|
|
||||||
"seccomp": SNR_SECCOMP,
|
|
||||||
"getrandom": SNR_GETRANDOM,
|
|
||||||
"memfd_create": SNR_MEMFD_CREATE,
|
|
||||||
"kexec_file_load": SNR_KEXEC_FILE_LOAD,
|
|
||||||
"bpf": SNR_BPF,
|
|
||||||
"execveat": SNR_EXECVEAT,
|
|
||||||
"userfaultfd": SNR_USERFAULTFD,
|
|
||||||
"membarrier": SNR_MEMBARRIER,
|
|
||||||
"mlock2": SNR_MLOCK2,
|
|
||||||
"copy_file_range": SNR_COPY_FILE_RANGE,
|
|
||||||
"preadv2": SNR_PREADV2,
|
|
||||||
"pwritev2": SNR_PWRITEV2,
|
|
||||||
"pkey_mprotect": SNR_PKEY_MPROTECT,
|
|
||||||
"pkey_alloc": SNR_PKEY_ALLOC,
|
|
||||||
"pkey_free": SNR_PKEY_FREE,
|
|
||||||
"statx": SNR_STATX,
|
|
||||||
"io_pgetevents": SNR_IO_PGETEVENTS,
|
|
||||||
"rseq": SNR_RSEQ,
|
|
||||||
"uretprobe": SNR_URETPROBE,
|
|
||||||
"pidfd_send_signal": SNR_PIDFD_SEND_SIGNAL,
|
|
||||||
"io_uring_setup": SNR_IO_URING_SETUP,
|
|
||||||
"io_uring_enter": SNR_IO_URING_ENTER,
|
|
||||||
"io_uring_register": SNR_IO_URING_REGISTER,
|
|
||||||
"open_tree": SNR_OPEN_TREE,
|
|
||||||
"move_mount": SNR_MOVE_MOUNT,
|
|
||||||
"fsopen": SNR_FSOPEN,
|
|
||||||
"fsconfig": SNR_FSCONFIG,
|
|
||||||
"fsmount": SNR_FSMOUNT,
|
|
||||||
"fspick": SNR_FSPICK,
|
|
||||||
"pidfd_open": SNR_PIDFD_OPEN,
|
|
||||||
"clone3": SNR_CLONE3,
|
|
||||||
"close_range": SNR_CLOSE_RANGE,
|
|
||||||
"openat2": SNR_OPENAT2,
|
|
||||||
"pidfd_getfd": SNR_PIDFD_GETFD,
|
|
||||||
"faccessat2": SNR_FACCESSAT2,
|
|
||||||
"process_madvise": SNR_PROCESS_MADVISE,
|
|
||||||
"epoll_pwait2": SNR_EPOLL_PWAIT2,
|
|
||||||
"mount_setattr": SNR_MOUNT_SETATTR,
|
|
||||||
"quotactl_fd": SNR_QUOTACTL_FD,
|
|
||||||
"landlock_create_ruleset": SNR_LANDLOCK_CREATE_RULESET,
|
|
||||||
"landlock_add_rule": SNR_LANDLOCK_ADD_RULE,
|
|
||||||
"landlock_restrict_self": SNR_LANDLOCK_RESTRICT_SELF,
|
|
||||||
"memfd_secret": SNR_MEMFD_SECRET,
|
|
||||||
"process_mrelease": SNR_PROCESS_MRELEASE,
|
|
||||||
"futex_waitv": SNR_FUTEX_WAITV,
|
|
||||||
"set_mempolicy_home_node": SNR_SET_MEMPOLICY_HOME_NODE,
|
|
||||||
"cachestat": SNR_CACHESTAT,
|
|
||||||
"fchmodat2": SNR_FCHMODAT2,
|
|
||||||
"map_shadow_stack": SNR_MAP_SHADOW_STACK,
|
|
||||||
"futex_wake": SNR_FUTEX_WAKE,
|
|
||||||
"futex_wait": SNR_FUTEX_WAIT,
|
|
||||||
"futex_requeue": SNR_FUTEX_REQUEUE,
|
|
||||||
"statmount": SNR_STATMOUNT,
|
|
||||||
"listmount": SNR_LISTMOUNT,
|
|
||||||
"lsm_get_self_attr": SNR_LSM_GET_SELF_ATTR,
|
|
||||||
"lsm_set_self_attr": SNR_LSM_SET_SELF_ATTR,
|
|
||||||
"lsm_list_modules": SNR_LSM_LIST_MODULES,
|
|
||||||
"mseal": SNR_MSEAL,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_NAME_TO_HANDLE_AT = 303
|
|
||||||
SYS_OPEN_BY_HANDLE_AT = 304
|
|
||||||
SYS_CLOCK_ADJTIME = 305
|
|
||||||
SYS_SYNCFS = 306
|
|
||||||
SYS_SENDMMSG = 307
|
|
||||||
SYS_SETNS = 308
|
|
||||||
SYS_GETCPU = 309
|
|
||||||
SYS_PROCESS_VM_READV = 310
|
|
||||||
SYS_PROCESS_VM_WRITEV = 311
|
|
||||||
SYS_KCMP = 312
|
|
||||||
SYS_FINIT_MODULE = 313
|
|
||||||
SYS_SCHED_SETATTR = 314
|
|
||||||
SYS_SCHED_GETATTR = 315
|
|
||||||
SYS_RENAMEAT2 = 316
|
|
||||||
SYS_SECCOMP = 317
|
|
||||||
SYS_GETRANDOM = 318
|
|
||||||
SYS_MEMFD_CREATE = 319
|
|
||||||
SYS_KEXEC_FILE_LOAD = 320
|
|
||||||
SYS_BPF = 321
|
|
||||||
SYS_EXECVEAT = 322
|
|
||||||
SYS_USERFAULTFD = 323
|
|
||||||
SYS_MEMBARRIER = 324
|
|
||||||
SYS_MLOCK2 = 325
|
|
||||||
SYS_COPY_FILE_RANGE = 326
|
|
||||||
SYS_PREADV2 = 327
|
|
||||||
SYS_PWRITEV2 = 328
|
|
||||||
SYS_PKEY_MPROTECT = 329
|
|
||||||
SYS_PKEY_ALLOC = 330
|
|
||||||
SYS_PKEY_FREE = 331
|
|
||||||
SYS_STATX = 332
|
|
||||||
SYS_IO_PGETEVENTS = 333
|
|
||||||
SYS_RSEQ = 334
|
|
||||||
SYS_URETPROBE = 335
|
|
||||||
SYS_PIDFD_SEND_SIGNAL = 424
|
|
||||||
SYS_IO_URING_SETUP = 425
|
|
||||||
SYS_IO_URING_ENTER = 426
|
|
||||||
SYS_IO_URING_REGISTER = 427
|
|
||||||
SYS_OPEN_TREE = 428
|
|
||||||
SYS_MOVE_MOUNT = 429
|
|
||||||
SYS_FSOPEN = 430
|
|
||||||
SYS_FSCONFIG = 431
|
|
||||||
SYS_FSMOUNT = 432
|
|
||||||
SYS_FSPICK = 433
|
|
||||||
SYS_PIDFD_OPEN = 434
|
|
||||||
SYS_CLONE3 = 435
|
|
||||||
SYS_CLOSE_RANGE = 436
|
|
||||||
SYS_OPENAT2 = 437
|
|
||||||
SYS_PIDFD_GETFD = 438
|
|
||||||
SYS_FACCESSAT2 = 439
|
|
||||||
SYS_PROCESS_MADVISE = 440
|
|
||||||
SYS_EPOLL_PWAIT2 = 441
|
|
||||||
SYS_MOUNT_SETATTR = 442
|
|
||||||
SYS_QUOTACTL_FD = 443
|
|
||||||
SYS_LANDLOCK_CREATE_RULESET = 444
|
|
||||||
SYS_LANDLOCK_ADD_RULE = 445
|
|
||||||
SYS_LANDLOCK_RESTRICT_SELF = 446
|
|
||||||
SYS_MEMFD_SECRET = 447
|
|
||||||
SYS_PROCESS_MRELEASE = 448
|
|
||||||
SYS_FUTEX_WAITV = 449
|
|
||||||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
|
||||||
SYS_CACHESTAT = 451
|
|
||||||
SYS_FCHMODAT2 = 452
|
|
||||||
SYS_MAP_SHADOW_STACK = 453
|
|
||||||
SYS_FUTEX_WAKE = 454
|
|
||||||
SYS_FUTEX_WAIT = 455
|
|
||||||
SYS_FUTEX_REQUEUE = 456
|
|
||||||
SYS_STATMOUNT = 457
|
|
||||||
SYS_LISTMOUNT = 458
|
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
|
||||||
SYS_LSM_LIST_MODULES = 461
|
|
||||||
SYS_MSEAL = 462
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_READ ScmpSyscall = SYS_READ
|
|
||||||
SNR_WRITE ScmpSyscall = SYS_WRITE
|
|
||||||
SNR_OPEN ScmpSyscall = SYS_OPEN
|
|
||||||
SNR_CLOSE ScmpSyscall = SYS_CLOSE
|
|
||||||
SNR_STAT ScmpSyscall = SYS_STAT
|
|
||||||
SNR_FSTAT ScmpSyscall = SYS_FSTAT
|
|
||||||
SNR_LSTAT ScmpSyscall = SYS_LSTAT
|
|
||||||
SNR_POLL ScmpSyscall = SYS_POLL
|
|
||||||
SNR_LSEEK ScmpSyscall = SYS_LSEEK
|
|
||||||
SNR_MMAP ScmpSyscall = SYS_MMAP
|
|
||||||
SNR_MPROTECT ScmpSyscall = SYS_MPROTECT
|
|
||||||
SNR_MUNMAP ScmpSyscall = SYS_MUNMAP
|
|
||||||
SNR_BRK ScmpSyscall = SYS_BRK
|
|
||||||
SNR_RT_SIGACTION ScmpSyscall = SYS_RT_SIGACTION
|
|
||||||
SNR_RT_SIGPROCMASK ScmpSyscall = SYS_RT_SIGPROCMASK
|
|
||||||
SNR_RT_SIGRETURN ScmpSyscall = SYS_RT_SIGRETURN
|
|
||||||
SNR_IOCTL ScmpSyscall = SYS_IOCTL
|
|
||||||
SNR_PREAD64 ScmpSyscall = SYS_PREAD64
|
|
||||||
SNR_PWRITE64 ScmpSyscall = SYS_PWRITE64
|
|
||||||
SNR_READV ScmpSyscall = SYS_READV
|
|
||||||
SNR_WRITEV ScmpSyscall = SYS_WRITEV
|
|
||||||
SNR_ACCESS ScmpSyscall = SYS_ACCESS
|
|
||||||
SNR_PIPE ScmpSyscall = SYS_PIPE
|
|
||||||
SNR_SELECT ScmpSyscall = SYS_SELECT
|
|
||||||
SNR_SCHED_YIELD ScmpSyscall = SYS_SCHED_YIELD
|
|
||||||
SNR_MREMAP ScmpSyscall = SYS_MREMAP
|
|
||||||
SNR_MSYNC ScmpSyscall = SYS_MSYNC
|
|
||||||
SNR_MINCORE ScmpSyscall = SYS_MINCORE
|
|
||||||
SNR_MADVISE ScmpSyscall = SYS_MADVISE
|
|
||||||
SNR_SHMGET ScmpSyscall = SYS_SHMGET
|
|
||||||
SNR_SHMAT ScmpSyscall = SYS_SHMAT
|
|
||||||
SNR_SHMCTL ScmpSyscall = SYS_SHMCTL
|
|
||||||
SNR_DUP ScmpSyscall = SYS_DUP
|
|
||||||
SNR_DUP2 ScmpSyscall = SYS_DUP2
|
|
||||||
SNR_PAUSE ScmpSyscall = SYS_PAUSE
|
|
||||||
SNR_NANOSLEEP ScmpSyscall = SYS_NANOSLEEP
|
|
||||||
SNR_GETITIMER ScmpSyscall = SYS_GETITIMER
|
|
||||||
SNR_ALARM ScmpSyscall = SYS_ALARM
|
|
||||||
SNR_SETITIMER ScmpSyscall = SYS_SETITIMER
|
|
||||||
SNR_GETPID ScmpSyscall = SYS_GETPID
|
|
||||||
SNR_SENDFILE ScmpSyscall = SYS_SENDFILE
|
|
||||||
SNR_SOCKET ScmpSyscall = SYS_SOCKET
|
|
||||||
SNR_CONNECT ScmpSyscall = SYS_CONNECT
|
|
||||||
SNR_ACCEPT ScmpSyscall = SYS_ACCEPT
|
|
||||||
SNR_SENDTO ScmpSyscall = SYS_SENDTO
|
|
||||||
SNR_RECVFROM ScmpSyscall = SYS_RECVFROM
|
|
||||||
SNR_SENDMSG ScmpSyscall = SYS_SENDMSG
|
|
||||||
SNR_RECVMSG ScmpSyscall = SYS_RECVMSG
|
|
||||||
SNR_SHUTDOWN ScmpSyscall = SYS_SHUTDOWN
|
|
||||||
SNR_BIND ScmpSyscall = SYS_BIND
|
|
||||||
SNR_LISTEN ScmpSyscall = SYS_LISTEN
|
|
||||||
SNR_GETSOCKNAME ScmpSyscall = SYS_GETSOCKNAME
|
|
||||||
SNR_GETPEERNAME ScmpSyscall = SYS_GETPEERNAME
|
|
||||||
SNR_SOCKETPAIR ScmpSyscall = SYS_SOCKETPAIR
|
|
||||||
SNR_SETSOCKOPT ScmpSyscall = SYS_SETSOCKOPT
|
|
||||||
SNR_GETSOCKOPT ScmpSyscall = SYS_GETSOCKOPT
|
|
||||||
SNR_CLONE ScmpSyscall = SYS_CLONE
|
|
||||||
SNR_FORK ScmpSyscall = SYS_FORK
|
|
||||||
SNR_VFORK ScmpSyscall = SYS_VFORK
|
|
||||||
SNR_EXECVE ScmpSyscall = SYS_EXECVE
|
|
||||||
SNR_EXIT ScmpSyscall = SYS_EXIT
|
|
||||||
SNR_WAIT4 ScmpSyscall = SYS_WAIT4
|
|
||||||
SNR_KILL ScmpSyscall = SYS_KILL
|
|
||||||
SNR_UNAME ScmpSyscall = SYS_UNAME
|
|
||||||
SNR_SEMGET ScmpSyscall = SYS_SEMGET
|
|
||||||
SNR_SEMOP ScmpSyscall = SYS_SEMOP
|
|
||||||
SNR_SEMCTL ScmpSyscall = SYS_SEMCTL
|
|
||||||
SNR_SHMDT ScmpSyscall = SYS_SHMDT
|
|
||||||
SNR_MSGGET ScmpSyscall = SYS_MSGGET
|
|
||||||
SNR_MSGSND ScmpSyscall = SYS_MSGSND
|
|
||||||
SNR_MSGRCV ScmpSyscall = SYS_MSGRCV
|
|
||||||
SNR_MSGCTL ScmpSyscall = SYS_MSGCTL
|
|
||||||
SNR_FCNTL ScmpSyscall = SYS_FCNTL
|
|
||||||
SNR_FLOCK ScmpSyscall = SYS_FLOCK
|
|
||||||
SNR_FSYNC ScmpSyscall = SYS_FSYNC
|
|
||||||
SNR_FDATASYNC ScmpSyscall = SYS_FDATASYNC
|
|
||||||
SNR_TRUNCATE ScmpSyscall = SYS_TRUNCATE
|
|
||||||
SNR_FTRUNCATE ScmpSyscall = SYS_FTRUNCATE
|
|
||||||
SNR_GETDENTS ScmpSyscall = SYS_GETDENTS
|
|
||||||
SNR_GETCWD ScmpSyscall = SYS_GETCWD
|
|
||||||
SNR_CHDIR ScmpSyscall = SYS_CHDIR
|
|
||||||
SNR_FCHDIR ScmpSyscall = SYS_FCHDIR
|
|
||||||
SNR_RENAME ScmpSyscall = SYS_RENAME
|
|
||||||
SNR_MKDIR ScmpSyscall = SYS_MKDIR
|
|
||||||
SNR_RMDIR ScmpSyscall = SYS_RMDIR
|
|
||||||
SNR_CREAT ScmpSyscall = SYS_CREAT
|
|
||||||
SNR_LINK ScmpSyscall = SYS_LINK
|
|
||||||
SNR_UNLINK ScmpSyscall = SYS_UNLINK
|
|
||||||
SNR_SYMLINK ScmpSyscall = SYS_SYMLINK
|
|
||||||
SNR_READLINK ScmpSyscall = SYS_READLINK
|
|
||||||
SNR_CHMOD ScmpSyscall = SYS_CHMOD
|
|
||||||
SNR_FCHMOD ScmpSyscall = SYS_FCHMOD
|
|
||||||
SNR_CHOWN ScmpSyscall = SYS_CHOWN
|
|
||||||
SNR_FCHOWN ScmpSyscall = SYS_FCHOWN
|
|
||||||
SNR_LCHOWN ScmpSyscall = SYS_LCHOWN
|
|
||||||
SNR_UMASK ScmpSyscall = SYS_UMASK
|
|
||||||
SNR_GETTIMEOFDAY ScmpSyscall = SYS_GETTIMEOFDAY
|
|
||||||
SNR_GETRLIMIT ScmpSyscall = SYS_GETRLIMIT
|
|
||||||
SNR_GETRUSAGE ScmpSyscall = SYS_GETRUSAGE
|
|
||||||
SNR_SYSINFO ScmpSyscall = SYS_SYSINFO
|
|
||||||
SNR_TIMES ScmpSyscall = SYS_TIMES
|
|
||||||
SNR_PTRACE ScmpSyscall = SYS_PTRACE
|
|
||||||
SNR_GETUID ScmpSyscall = SYS_GETUID
|
|
||||||
SNR_SYSLOG ScmpSyscall = SYS_SYSLOG
|
|
||||||
SNR_GETGID ScmpSyscall = SYS_GETGID
|
|
||||||
SNR_SETUID ScmpSyscall = SYS_SETUID
|
|
||||||
SNR_SETGID ScmpSyscall = SYS_SETGID
|
|
||||||
SNR_GETEUID ScmpSyscall = SYS_GETEUID
|
|
||||||
SNR_GETEGID ScmpSyscall = SYS_GETEGID
|
|
||||||
SNR_SETPGID ScmpSyscall = SYS_SETPGID
|
|
||||||
SNR_GETPPID ScmpSyscall = SYS_GETPPID
|
|
||||||
SNR_GETPGRP ScmpSyscall = SYS_GETPGRP
|
|
||||||
SNR_SETSID ScmpSyscall = SYS_SETSID
|
|
||||||
SNR_SETREUID ScmpSyscall = SYS_SETREUID
|
|
||||||
SNR_SETREGID ScmpSyscall = SYS_SETREGID
|
|
||||||
SNR_GETGROUPS ScmpSyscall = SYS_GETGROUPS
|
|
||||||
SNR_SETGROUPS ScmpSyscall = SYS_SETGROUPS
|
|
||||||
SNR_SETRESUID ScmpSyscall = SYS_SETRESUID
|
|
||||||
SNR_GETRESUID ScmpSyscall = SYS_GETRESUID
|
|
||||||
SNR_SETRESGID ScmpSyscall = SYS_SETRESGID
|
|
||||||
SNR_GETRESGID ScmpSyscall = SYS_GETRESGID
|
|
||||||
SNR_GETPGID ScmpSyscall = SYS_GETPGID
|
|
||||||
SNR_SETFSUID ScmpSyscall = SYS_SETFSUID
|
|
||||||
SNR_SETFSGID ScmpSyscall = SYS_SETFSGID
|
|
||||||
SNR_GETSID ScmpSyscall = SYS_GETSID
|
|
||||||
SNR_CAPGET ScmpSyscall = SYS_CAPGET
|
|
||||||
SNR_CAPSET ScmpSyscall = SYS_CAPSET
|
|
||||||
SNR_RT_SIGPENDING ScmpSyscall = SYS_RT_SIGPENDING
|
|
||||||
SNR_RT_SIGTIMEDWAIT ScmpSyscall = SYS_RT_SIGTIMEDWAIT
|
|
||||||
SNR_RT_SIGQUEUEINFO ScmpSyscall = SYS_RT_SIGQUEUEINFO
|
|
||||||
SNR_RT_SIGSUSPEND ScmpSyscall = SYS_RT_SIGSUSPEND
|
|
||||||
SNR_SIGALTSTACK ScmpSyscall = SYS_SIGALTSTACK
|
|
||||||
SNR_UTIME ScmpSyscall = SYS_UTIME
|
|
||||||
SNR_MKNOD ScmpSyscall = SYS_MKNOD
|
|
||||||
SNR_USELIB ScmpSyscall = SYS_USELIB
|
|
||||||
SNR_PERSONALITY ScmpSyscall = SYS_PERSONALITY
|
|
||||||
SNR_USTAT ScmpSyscall = SYS_USTAT
|
|
||||||
SNR_STATFS ScmpSyscall = SYS_STATFS
|
|
||||||
SNR_FSTATFS ScmpSyscall = SYS_FSTATFS
|
|
||||||
SNR_SYSFS ScmpSyscall = SYS_SYSFS
|
|
||||||
SNR_GETPRIORITY ScmpSyscall = SYS_GETPRIORITY
|
|
||||||
SNR_SETPRIORITY ScmpSyscall = SYS_SETPRIORITY
|
|
||||||
SNR_SCHED_SETPARAM ScmpSyscall = SYS_SCHED_SETPARAM
|
|
||||||
SNR_SCHED_GETPARAM ScmpSyscall = SYS_SCHED_GETPARAM
|
|
||||||
SNR_SCHED_SETSCHEDULER ScmpSyscall = SYS_SCHED_SETSCHEDULER
|
|
||||||
SNR_SCHED_GETSCHEDULER ScmpSyscall = SYS_SCHED_GETSCHEDULER
|
|
||||||
SNR_SCHED_GET_PRIORITY_MAX ScmpSyscall = SYS_SCHED_GET_PRIORITY_MAX
|
|
||||||
SNR_SCHED_GET_PRIORITY_MIN ScmpSyscall = SYS_SCHED_GET_PRIORITY_MIN
|
|
||||||
SNR_SCHED_RR_GET_INTERVAL ScmpSyscall = SYS_SCHED_RR_GET_INTERVAL
|
|
||||||
SNR_MLOCK ScmpSyscall = SYS_MLOCK
|
|
||||||
SNR_MUNLOCK ScmpSyscall = SYS_MUNLOCK
|
|
||||||
SNR_MLOCKALL ScmpSyscall = SYS_MLOCKALL
|
|
||||||
SNR_MUNLOCKALL ScmpSyscall = SYS_MUNLOCKALL
|
|
||||||
SNR_VHANGUP ScmpSyscall = SYS_VHANGUP
|
|
||||||
SNR_MODIFY_LDT ScmpSyscall = SYS_MODIFY_LDT
|
|
||||||
SNR_PIVOT_ROOT ScmpSyscall = SYS_PIVOT_ROOT
|
|
||||||
SNR__SYSCTL ScmpSyscall = SYS__SYSCTL
|
|
||||||
SNR_PRCTL ScmpSyscall = SYS_PRCTL
|
|
||||||
SNR_ARCH_PRCTL ScmpSyscall = SYS_ARCH_PRCTL
|
|
||||||
SNR_ADJTIMEX ScmpSyscall = SYS_ADJTIMEX
|
|
||||||
SNR_SETRLIMIT ScmpSyscall = SYS_SETRLIMIT
|
|
||||||
SNR_CHROOT ScmpSyscall = SYS_CHROOT
|
|
||||||
SNR_SYNC ScmpSyscall = SYS_SYNC
|
|
||||||
SNR_ACCT ScmpSyscall = SYS_ACCT
|
|
||||||
SNR_SETTIMEOFDAY ScmpSyscall = SYS_SETTIMEOFDAY
|
|
||||||
SNR_MOUNT ScmpSyscall = SYS_MOUNT
|
|
||||||
SNR_UMOUNT2 ScmpSyscall = SYS_UMOUNT2
|
|
||||||
SNR_SWAPON ScmpSyscall = SYS_SWAPON
|
|
||||||
SNR_SWAPOFF ScmpSyscall = SYS_SWAPOFF
|
|
||||||
SNR_REBOOT ScmpSyscall = SYS_REBOOT
|
|
||||||
SNR_SETHOSTNAME ScmpSyscall = SYS_SETHOSTNAME
|
|
||||||
SNR_SETDOMAINNAME ScmpSyscall = SYS_SETDOMAINNAME
|
|
||||||
SNR_IOPL ScmpSyscall = SYS_IOPL
|
|
||||||
SNR_IOPERM ScmpSyscall = SYS_IOPERM
|
|
||||||
SNR_CREATE_MODULE ScmpSyscall = SYS_CREATE_MODULE
|
|
||||||
SNR_INIT_MODULE ScmpSyscall = SYS_INIT_MODULE
|
|
||||||
SNR_DELETE_MODULE ScmpSyscall = SYS_DELETE_MODULE
|
|
||||||
SNR_GET_KERNEL_SYMS ScmpSyscall = SYS_GET_KERNEL_SYMS
|
|
||||||
SNR_QUERY_MODULE ScmpSyscall = SYS_QUERY_MODULE
|
|
||||||
SNR_QUOTACTL ScmpSyscall = SYS_QUOTACTL
|
|
||||||
SNR_NFSSERVCTL ScmpSyscall = SYS_NFSSERVCTL
|
|
||||||
SNR_GETPMSG ScmpSyscall = SYS_GETPMSG
|
|
||||||
SNR_PUTPMSG ScmpSyscall = SYS_PUTPMSG
|
|
||||||
SNR_AFS_SYSCALL ScmpSyscall = SYS_AFS_SYSCALL
|
|
||||||
SNR_TUXCALL ScmpSyscall = SYS_TUXCALL
|
|
||||||
SNR_SECURITY ScmpSyscall = SYS_SECURITY
|
|
||||||
SNR_GETTID ScmpSyscall = SYS_GETTID
|
|
||||||
SNR_READAHEAD ScmpSyscall = SYS_READAHEAD
|
|
||||||
SNR_SETXATTR ScmpSyscall = SYS_SETXATTR
|
|
||||||
SNR_LSETXATTR ScmpSyscall = SYS_LSETXATTR
|
|
||||||
SNR_FSETXATTR ScmpSyscall = SYS_FSETXATTR
|
|
||||||
SNR_GETXATTR ScmpSyscall = SYS_GETXATTR
|
|
||||||
SNR_LGETXATTR ScmpSyscall = SYS_LGETXATTR
|
|
||||||
SNR_FGETXATTR ScmpSyscall = SYS_FGETXATTR
|
|
||||||
SNR_LISTXATTR ScmpSyscall = SYS_LISTXATTR
|
|
||||||
SNR_LLISTXATTR ScmpSyscall = SYS_LLISTXATTR
|
|
||||||
SNR_FLISTXATTR ScmpSyscall = SYS_FLISTXATTR
|
|
||||||
SNR_REMOVEXATTR ScmpSyscall = SYS_REMOVEXATTR
|
|
||||||
SNR_LREMOVEXATTR ScmpSyscall = SYS_LREMOVEXATTR
|
|
||||||
SNR_FREMOVEXATTR ScmpSyscall = SYS_FREMOVEXATTR
|
|
||||||
SNR_TKILL ScmpSyscall = SYS_TKILL
|
|
||||||
SNR_TIME ScmpSyscall = SYS_TIME
|
|
||||||
SNR_FUTEX ScmpSyscall = SYS_FUTEX
|
|
||||||
SNR_SCHED_SETAFFINITY ScmpSyscall = SYS_SCHED_SETAFFINITY
|
|
||||||
SNR_SCHED_GETAFFINITY ScmpSyscall = SYS_SCHED_GETAFFINITY
|
|
||||||
SNR_SET_THREAD_AREA ScmpSyscall = SYS_SET_THREAD_AREA
|
|
||||||
SNR_IO_SETUP ScmpSyscall = SYS_IO_SETUP
|
|
||||||
SNR_IO_DESTROY ScmpSyscall = SYS_IO_DESTROY
|
|
||||||
SNR_IO_GETEVENTS ScmpSyscall = SYS_IO_GETEVENTS
|
|
||||||
SNR_IO_SUBMIT ScmpSyscall = SYS_IO_SUBMIT
|
|
||||||
SNR_IO_CANCEL ScmpSyscall = SYS_IO_CANCEL
|
|
||||||
SNR_GET_THREAD_AREA ScmpSyscall = SYS_GET_THREAD_AREA
|
|
||||||
SNR_LOOKUP_DCOOKIE ScmpSyscall = SYS_LOOKUP_DCOOKIE
|
|
||||||
SNR_EPOLL_CREATE ScmpSyscall = SYS_EPOLL_CREATE
|
|
||||||
SNR_EPOLL_CTL_OLD ScmpSyscall = SYS_EPOLL_CTL_OLD
|
|
||||||
SNR_EPOLL_WAIT_OLD ScmpSyscall = SYS_EPOLL_WAIT_OLD
|
|
||||||
SNR_REMAP_FILE_PAGES ScmpSyscall = SYS_REMAP_FILE_PAGES
|
|
||||||
SNR_GETDENTS64 ScmpSyscall = SYS_GETDENTS64
|
|
||||||
SNR_SET_TID_ADDRESS ScmpSyscall = SYS_SET_TID_ADDRESS
|
|
||||||
SNR_RESTART_SYSCALL ScmpSyscall = SYS_RESTART_SYSCALL
|
|
||||||
SNR_SEMTIMEDOP ScmpSyscall = SYS_SEMTIMEDOP
|
|
||||||
SNR_FADVISE64 ScmpSyscall = SYS_FADVISE64
|
|
||||||
SNR_TIMER_CREATE ScmpSyscall = SYS_TIMER_CREATE
|
|
||||||
SNR_TIMER_SETTIME ScmpSyscall = SYS_TIMER_SETTIME
|
|
||||||
SNR_TIMER_GETTIME ScmpSyscall = SYS_TIMER_GETTIME
|
|
||||||
SNR_TIMER_GETOVERRUN ScmpSyscall = SYS_TIMER_GETOVERRUN
|
|
||||||
SNR_TIMER_DELETE ScmpSyscall = SYS_TIMER_DELETE
|
|
||||||
SNR_CLOCK_SETTIME ScmpSyscall = SYS_CLOCK_SETTIME
|
|
||||||
SNR_CLOCK_GETTIME ScmpSyscall = SYS_CLOCK_GETTIME
|
|
||||||
SNR_CLOCK_GETRES ScmpSyscall = SYS_CLOCK_GETRES
|
|
||||||
SNR_CLOCK_NANOSLEEP ScmpSyscall = SYS_CLOCK_NANOSLEEP
|
|
||||||
SNR_EXIT_GROUP ScmpSyscall = SYS_EXIT_GROUP
|
|
||||||
SNR_EPOLL_WAIT ScmpSyscall = SYS_EPOLL_WAIT
|
|
||||||
SNR_EPOLL_CTL ScmpSyscall = SYS_EPOLL_CTL
|
|
||||||
SNR_TGKILL ScmpSyscall = SYS_TGKILL
|
|
||||||
SNR_UTIMES ScmpSyscall = SYS_UTIMES
|
|
||||||
SNR_VSERVER ScmpSyscall = SYS_VSERVER
|
|
||||||
SNR_MBIND ScmpSyscall = SYS_MBIND
|
|
||||||
SNR_SET_MEMPOLICY ScmpSyscall = SYS_SET_MEMPOLICY
|
|
||||||
SNR_GET_MEMPOLICY ScmpSyscall = SYS_GET_MEMPOLICY
|
|
||||||
SNR_MQ_OPEN ScmpSyscall = SYS_MQ_OPEN
|
|
||||||
SNR_MQ_UNLINK ScmpSyscall = SYS_MQ_UNLINK
|
|
||||||
SNR_MQ_TIMEDSEND ScmpSyscall = SYS_MQ_TIMEDSEND
|
|
||||||
SNR_MQ_TIMEDRECEIVE ScmpSyscall = SYS_MQ_TIMEDRECEIVE
|
|
||||||
SNR_MQ_NOTIFY ScmpSyscall = SYS_MQ_NOTIFY
|
|
||||||
SNR_MQ_GETSETATTR ScmpSyscall = SYS_MQ_GETSETATTR
|
|
||||||
SNR_KEXEC_LOAD ScmpSyscall = SYS_KEXEC_LOAD
|
|
||||||
SNR_WAITID ScmpSyscall = SYS_WAITID
|
|
||||||
SNR_ADD_KEY ScmpSyscall = SYS_ADD_KEY
|
|
||||||
SNR_REQUEST_KEY ScmpSyscall = SYS_REQUEST_KEY
|
|
||||||
SNR_KEYCTL ScmpSyscall = SYS_KEYCTL
|
|
||||||
SNR_IOPRIO_SET ScmpSyscall = SYS_IOPRIO_SET
|
|
||||||
SNR_IOPRIO_GET ScmpSyscall = SYS_IOPRIO_GET
|
|
||||||
SNR_INOTIFY_INIT ScmpSyscall = SYS_INOTIFY_INIT
|
|
||||||
SNR_INOTIFY_ADD_WATCH ScmpSyscall = SYS_INOTIFY_ADD_WATCH
|
|
||||||
SNR_INOTIFY_RM_WATCH ScmpSyscall = SYS_INOTIFY_RM_WATCH
|
|
||||||
SNR_MIGRATE_PAGES ScmpSyscall = SYS_MIGRATE_PAGES
|
|
||||||
SNR_OPENAT ScmpSyscall = SYS_OPENAT
|
|
||||||
SNR_MKDIRAT ScmpSyscall = SYS_MKDIRAT
|
|
||||||
SNR_MKNODAT ScmpSyscall = SYS_MKNODAT
|
|
||||||
SNR_FCHOWNAT ScmpSyscall = SYS_FCHOWNAT
|
|
||||||
SNR_FUTIMESAT ScmpSyscall = SYS_FUTIMESAT
|
|
||||||
SNR_NEWFSTATAT ScmpSyscall = SYS_NEWFSTATAT
|
|
||||||
SNR_UNLINKAT ScmpSyscall = SYS_UNLINKAT
|
|
||||||
SNR_RENAMEAT ScmpSyscall = SYS_RENAMEAT
|
|
||||||
SNR_LINKAT ScmpSyscall = SYS_LINKAT
|
|
||||||
SNR_SYMLINKAT ScmpSyscall = SYS_SYMLINKAT
|
|
||||||
SNR_READLINKAT ScmpSyscall = SYS_READLINKAT
|
|
||||||
SNR_FCHMODAT ScmpSyscall = SYS_FCHMODAT
|
|
||||||
SNR_FACCESSAT ScmpSyscall = SYS_FACCESSAT
|
|
||||||
SNR_PSELECT6 ScmpSyscall = SYS_PSELECT6
|
|
||||||
SNR_PPOLL ScmpSyscall = SYS_PPOLL
|
|
||||||
SNR_UNSHARE ScmpSyscall = SYS_UNSHARE
|
|
||||||
SNR_SET_ROBUST_LIST ScmpSyscall = SYS_SET_ROBUST_LIST
|
|
||||||
SNR_GET_ROBUST_LIST ScmpSyscall = SYS_GET_ROBUST_LIST
|
|
||||||
SNR_SPLICE ScmpSyscall = SYS_SPLICE
|
|
||||||
SNR_TEE ScmpSyscall = SYS_TEE
|
|
||||||
SNR_SYNC_FILE_RANGE ScmpSyscall = SYS_SYNC_FILE_RANGE
|
|
||||||
SNR_VMSPLICE ScmpSyscall = SYS_VMSPLICE
|
|
||||||
SNR_MOVE_PAGES ScmpSyscall = SYS_MOVE_PAGES
|
|
||||||
SNR_UTIMENSAT ScmpSyscall = SYS_UTIMENSAT
|
|
||||||
SNR_EPOLL_PWAIT ScmpSyscall = SYS_EPOLL_PWAIT
|
|
||||||
SNR_SIGNALFD ScmpSyscall = SYS_SIGNALFD
|
|
||||||
SNR_TIMERFD_CREATE ScmpSyscall = SYS_TIMERFD_CREATE
|
|
||||||
SNR_EVENTFD ScmpSyscall = SYS_EVENTFD
|
|
||||||
SNR_FALLOCATE ScmpSyscall = SYS_FALLOCATE
|
|
||||||
SNR_TIMERFD_SETTIME ScmpSyscall = SYS_TIMERFD_SETTIME
|
|
||||||
SNR_TIMERFD_GETTIME ScmpSyscall = SYS_TIMERFD_GETTIME
|
|
||||||
SNR_ACCEPT4 ScmpSyscall = SYS_ACCEPT4
|
|
||||||
SNR_SIGNALFD4 ScmpSyscall = SYS_SIGNALFD4
|
|
||||||
SNR_EVENTFD2 ScmpSyscall = SYS_EVENTFD2
|
|
||||||
SNR_EPOLL_CREATE1 ScmpSyscall = SYS_EPOLL_CREATE1
|
|
||||||
SNR_DUP3 ScmpSyscall = SYS_DUP3
|
|
||||||
SNR_PIPE2 ScmpSyscall = SYS_PIPE2
|
|
||||||
SNR_INOTIFY_INIT1 ScmpSyscall = SYS_INOTIFY_INIT1
|
|
||||||
SNR_PREADV ScmpSyscall = SYS_PREADV
|
|
||||||
SNR_PWRITEV ScmpSyscall = SYS_PWRITEV
|
|
||||||
SNR_RT_TGSIGQUEUEINFO ScmpSyscall = SYS_RT_TGSIGQUEUEINFO
|
|
||||||
SNR_PERF_EVENT_OPEN ScmpSyscall = SYS_PERF_EVENT_OPEN
|
|
||||||
SNR_RECVMMSG ScmpSyscall = SYS_RECVMMSG
|
|
||||||
SNR_FANOTIFY_INIT ScmpSyscall = SYS_FANOTIFY_INIT
|
|
||||||
SNR_FANOTIFY_MARK ScmpSyscall = SYS_FANOTIFY_MARK
|
|
||||||
SNR_PRLIMIT64 ScmpSyscall = SYS_PRLIMIT64
|
|
||||||
SNR_NAME_TO_HANDLE_AT ScmpSyscall = SYS_NAME_TO_HANDLE_AT
|
|
||||||
SNR_OPEN_BY_HANDLE_AT ScmpSyscall = SYS_OPEN_BY_HANDLE_AT
|
|
||||||
SNR_CLOCK_ADJTIME ScmpSyscall = SYS_CLOCK_ADJTIME
|
|
||||||
SNR_SYNCFS ScmpSyscall = SYS_SYNCFS
|
|
||||||
SNR_SENDMMSG ScmpSyscall = SYS_SENDMMSG
|
|
||||||
SNR_SETNS ScmpSyscall = SYS_SETNS
|
|
||||||
SNR_GETCPU ScmpSyscall = SYS_GETCPU
|
|
||||||
SNR_PROCESS_VM_READV ScmpSyscall = SYS_PROCESS_VM_READV
|
|
||||||
SNR_PROCESS_VM_WRITEV ScmpSyscall = SYS_PROCESS_VM_WRITEV
|
|
||||||
SNR_KCMP ScmpSyscall = SYS_KCMP
|
|
||||||
SNR_FINIT_MODULE ScmpSyscall = SYS_FINIT_MODULE
|
|
||||||
SNR_SCHED_SETATTR ScmpSyscall = SYS_SCHED_SETATTR
|
|
||||||
SNR_SCHED_GETATTR ScmpSyscall = SYS_SCHED_GETATTR
|
|
||||||
SNR_RENAMEAT2 ScmpSyscall = SYS_RENAMEAT2
|
|
||||||
SNR_SECCOMP ScmpSyscall = SYS_SECCOMP
|
|
||||||
SNR_GETRANDOM ScmpSyscall = SYS_GETRANDOM
|
|
||||||
SNR_MEMFD_CREATE ScmpSyscall = SYS_MEMFD_CREATE
|
|
||||||
SNR_KEXEC_FILE_LOAD ScmpSyscall = SYS_KEXEC_FILE_LOAD
|
|
||||||
SNR_BPF ScmpSyscall = SYS_BPF
|
|
||||||
SNR_EXECVEAT ScmpSyscall = SYS_EXECVEAT
|
|
||||||
SNR_USERFAULTFD ScmpSyscall = SYS_USERFAULTFD
|
|
||||||
SNR_MEMBARRIER ScmpSyscall = SYS_MEMBARRIER
|
|
||||||
SNR_MLOCK2 ScmpSyscall = SYS_MLOCK2
|
|
||||||
SNR_COPY_FILE_RANGE ScmpSyscall = SYS_COPY_FILE_RANGE
|
|
||||||
SNR_PREADV2 ScmpSyscall = SYS_PREADV2
|
|
||||||
SNR_PWRITEV2 ScmpSyscall = SYS_PWRITEV2
|
|
||||||
SNR_PKEY_MPROTECT ScmpSyscall = SYS_PKEY_MPROTECT
|
|
||||||
SNR_PKEY_ALLOC ScmpSyscall = SYS_PKEY_ALLOC
|
|
||||||
SNR_PKEY_FREE ScmpSyscall = SYS_PKEY_FREE
|
|
||||||
SNR_STATX ScmpSyscall = SYS_STATX
|
|
||||||
SNR_IO_PGETEVENTS ScmpSyscall = SYS_IO_PGETEVENTS
|
|
||||||
SNR_RSEQ ScmpSyscall = SYS_RSEQ
|
|
||||||
SNR_URETPROBE ScmpSyscall = SYS_URETPROBE
|
|
||||||
SNR_PIDFD_SEND_SIGNAL ScmpSyscall = SYS_PIDFD_SEND_SIGNAL
|
|
||||||
SNR_IO_URING_SETUP ScmpSyscall = SYS_IO_URING_SETUP
|
|
||||||
SNR_IO_URING_ENTER ScmpSyscall = SYS_IO_URING_ENTER
|
|
||||||
SNR_IO_URING_REGISTER ScmpSyscall = SYS_IO_URING_REGISTER
|
|
||||||
SNR_OPEN_TREE ScmpSyscall = SYS_OPEN_TREE
|
|
||||||
SNR_MOVE_MOUNT ScmpSyscall = SYS_MOVE_MOUNT
|
|
||||||
SNR_FSOPEN ScmpSyscall = SYS_FSOPEN
|
|
||||||
SNR_FSCONFIG ScmpSyscall = SYS_FSCONFIG
|
|
||||||
SNR_FSMOUNT ScmpSyscall = SYS_FSMOUNT
|
|
||||||
SNR_FSPICK ScmpSyscall = SYS_FSPICK
|
|
||||||
SNR_PIDFD_OPEN ScmpSyscall = SYS_PIDFD_OPEN
|
|
||||||
SNR_CLONE3 ScmpSyscall = SYS_CLONE3
|
|
||||||
SNR_CLOSE_RANGE ScmpSyscall = SYS_CLOSE_RANGE
|
|
||||||
SNR_OPENAT2 ScmpSyscall = SYS_OPENAT2
|
|
||||||
SNR_PIDFD_GETFD ScmpSyscall = SYS_PIDFD_GETFD
|
|
||||||
SNR_FACCESSAT2 ScmpSyscall = SYS_FACCESSAT2
|
|
||||||
SNR_PROCESS_MADVISE ScmpSyscall = SYS_PROCESS_MADVISE
|
|
||||||
SNR_EPOLL_PWAIT2 ScmpSyscall = SYS_EPOLL_PWAIT2
|
|
||||||
SNR_MOUNT_SETATTR ScmpSyscall = SYS_MOUNT_SETATTR
|
|
||||||
SNR_QUOTACTL_FD ScmpSyscall = SYS_QUOTACTL_FD
|
|
||||||
SNR_LANDLOCK_CREATE_RULESET ScmpSyscall = SYS_LANDLOCK_CREATE_RULESET
|
|
||||||
SNR_LANDLOCK_ADD_RULE ScmpSyscall = SYS_LANDLOCK_ADD_RULE
|
|
||||||
SNR_LANDLOCK_RESTRICT_SELF ScmpSyscall = SYS_LANDLOCK_RESTRICT_SELF
|
|
||||||
SNR_MEMFD_SECRET ScmpSyscall = SYS_MEMFD_SECRET
|
|
||||||
SNR_PROCESS_MRELEASE ScmpSyscall = SYS_PROCESS_MRELEASE
|
|
||||||
SNR_FUTEX_WAITV ScmpSyscall = SYS_FUTEX_WAITV
|
|
||||||
SNR_SET_MEMPOLICY_HOME_NODE ScmpSyscall = SYS_SET_MEMPOLICY_HOME_NODE
|
|
||||||
SNR_CACHESTAT ScmpSyscall = SYS_CACHESTAT
|
|
||||||
SNR_FCHMODAT2 ScmpSyscall = SYS_FCHMODAT2
|
|
||||||
SNR_MAP_SHADOW_STACK ScmpSyscall = SYS_MAP_SHADOW_STACK
|
|
||||||
SNR_FUTEX_WAKE ScmpSyscall = SYS_FUTEX_WAKE
|
|
||||||
SNR_FUTEX_WAIT ScmpSyscall = SYS_FUTEX_WAIT
|
|
||||||
SNR_FUTEX_REQUEUE ScmpSyscall = SYS_FUTEX_REQUEUE
|
|
||||||
SNR_STATMOUNT ScmpSyscall = SYS_STATMOUNT
|
|
||||||
SNR_LISTMOUNT ScmpSyscall = SYS_LISTMOUNT
|
|
||||||
SNR_LSM_GET_SELF_ATTR ScmpSyscall = SYS_LSM_GET_SELF_ATTR
|
|
||||||
SNR_LSM_SET_SELF_ATTR ScmpSyscall = SYS_LSM_SET_SELF_ATTR
|
|
||||||
SNR_LSM_LIST_MODULES ScmpSyscall = SYS_LSM_LIST_MODULES
|
|
||||||
SNR_MSEAL ScmpSyscall = SYS_MSEAL
|
|
||||||
)
|
|
||||||
@@ -1,703 +0,0 @@
|
|||||||
// mksysnum_linux.pl /usr/include/asm/unistd_64.h
|
|
||||||
// Code generated by the command above; DO NOT EDIT.
|
|
||||||
|
|
||||||
package std
|
|
||||||
|
|
||||||
import . "syscall"
|
|
||||||
|
|
||||||
var syscallNum = map[string]ScmpSyscall{
|
|
||||||
"io_setup": SNR_IO_SETUP,
|
|
||||||
"io_destroy": SNR_IO_DESTROY,
|
|
||||||
"io_submit": SNR_IO_SUBMIT,
|
|
||||||
"io_cancel": SNR_IO_CANCEL,
|
|
||||||
"io_getevents": SNR_IO_GETEVENTS,
|
|
||||||
"setxattr": SNR_SETXATTR,
|
|
||||||
"lsetxattr": SNR_LSETXATTR,
|
|
||||||
"fsetxattr": SNR_FSETXATTR,
|
|
||||||
"getxattr": SNR_GETXATTR,
|
|
||||||
"lgetxattr": SNR_LGETXATTR,
|
|
||||||
"fgetxattr": SNR_FGETXATTR,
|
|
||||||
"listxattr": SNR_LISTXATTR,
|
|
||||||
"llistxattr": SNR_LLISTXATTR,
|
|
||||||
"flistxattr": SNR_FLISTXATTR,
|
|
||||||
"removexattr": SNR_REMOVEXATTR,
|
|
||||||
"lremovexattr": SNR_LREMOVEXATTR,
|
|
||||||
"fremovexattr": SNR_FREMOVEXATTR,
|
|
||||||
"getcwd": SNR_GETCWD,
|
|
||||||
"lookup_dcookie": SNR_LOOKUP_DCOOKIE,
|
|
||||||
"eventfd2": SNR_EVENTFD2,
|
|
||||||
"epoll_create1": SNR_EPOLL_CREATE1,
|
|
||||||
"epoll_ctl": SNR_EPOLL_CTL,
|
|
||||||
"epoll_pwait": SNR_EPOLL_PWAIT,
|
|
||||||
"dup": SNR_DUP,
|
|
||||||
"dup3": SNR_DUP3,
|
|
||||||
"fcntl": SNR_FCNTL,
|
|
||||||
"inotify_init1": SNR_INOTIFY_INIT1,
|
|
||||||
"inotify_add_watch": SNR_INOTIFY_ADD_WATCH,
|
|
||||||
"inotify_rm_watch": SNR_INOTIFY_RM_WATCH,
|
|
||||||
"ioctl": SNR_IOCTL,
|
|
||||||
"ioprio_set": SNR_IOPRIO_SET,
|
|
||||||
"ioprio_get": SNR_IOPRIO_GET,
|
|
||||||
"flock": SNR_FLOCK,
|
|
||||||
"mknodat": SNR_MKNODAT,
|
|
||||||
"mkdirat": SNR_MKDIRAT,
|
|
||||||
"unlinkat": SNR_UNLINKAT,
|
|
||||||
"symlinkat": SNR_SYMLINKAT,
|
|
||||||
"linkat": SNR_LINKAT,
|
|
||||||
"renameat": SNR_RENAMEAT,
|
|
||||||
"umount2": SNR_UMOUNT2,
|
|
||||||
"mount": SNR_MOUNT,
|
|
||||||
"pivot_root": SNR_PIVOT_ROOT,
|
|
||||||
"nfsservctl": SNR_NFSSERVCTL,
|
|
||||||
"statfs": SNR_STATFS,
|
|
||||||
"fstatfs": SNR_FSTATFS,
|
|
||||||
"truncate": SNR_TRUNCATE,
|
|
||||||
"ftruncate": SNR_FTRUNCATE,
|
|
||||||
"fallocate": SNR_FALLOCATE,
|
|
||||||
"faccessat": SNR_FACCESSAT,
|
|
||||||
"chdir": SNR_CHDIR,
|
|
||||||
"fchdir": SNR_FCHDIR,
|
|
||||||
"chroot": SNR_CHROOT,
|
|
||||||
"fchmod": SNR_FCHMOD,
|
|
||||||
"fchmodat": SNR_FCHMODAT,
|
|
||||||
"fchownat": SNR_FCHOWNAT,
|
|
||||||
"fchown": SNR_FCHOWN,
|
|
||||||
"openat": SNR_OPENAT,
|
|
||||||
"close": SNR_CLOSE,
|
|
||||||
"vhangup": SNR_VHANGUP,
|
|
||||||
"pipe2": SNR_PIPE2,
|
|
||||||
"quotactl": SNR_QUOTACTL,
|
|
||||||
"getdents64": SNR_GETDENTS64,
|
|
||||||
"lseek": SNR_LSEEK,
|
|
||||||
"read": SNR_READ,
|
|
||||||
"write": SNR_WRITE,
|
|
||||||
"readv": SNR_READV,
|
|
||||||
"writev": SNR_WRITEV,
|
|
||||||
"pread64": SNR_PREAD64,
|
|
||||||
"pwrite64": SNR_PWRITE64,
|
|
||||||
"preadv": SNR_PREADV,
|
|
||||||
"pwritev": SNR_PWRITEV,
|
|
||||||
"sendfile": SNR_SENDFILE,
|
|
||||||
"pselect6": SNR_PSELECT6,
|
|
||||||
"ppoll": SNR_PPOLL,
|
|
||||||
"signalfd4": SNR_SIGNALFD4,
|
|
||||||
"vmsplice": SNR_VMSPLICE,
|
|
||||||
"splice": SNR_SPLICE,
|
|
||||||
"tee": SNR_TEE,
|
|
||||||
"readlinkat": SNR_READLINKAT,
|
|
||||||
"newfstatat": SNR_NEWFSTATAT,
|
|
||||||
"fstat": SNR_FSTAT,
|
|
||||||
"sync": SNR_SYNC,
|
|
||||||
"fsync": SNR_FSYNC,
|
|
||||||
"fdatasync": SNR_FDATASYNC,
|
|
||||||
"sync_file_range": SNR_SYNC_FILE_RANGE,
|
|
||||||
"timerfd_create": SNR_TIMERFD_CREATE,
|
|
||||||
"timerfd_settime": SNR_TIMERFD_SETTIME,
|
|
||||||
"timerfd_gettime": SNR_TIMERFD_GETTIME,
|
|
||||||
"utimensat": SNR_UTIMENSAT,
|
|
||||||
"acct": SNR_ACCT,
|
|
||||||
"capget": SNR_CAPGET,
|
|
||||||
"capset": SNR_CAPSET,
|
|
||||||
"personality": SNR_PERSONALITY,
|
|
||||||
"exit": SNR_EXIT,
|
|
||||||
"exit_group": SNR_EXIT_GROUP,
|
|
||||||
"waitid": SNR_WAITID,
|
|
||||||
"set_tid_address": SNR_SET_TID_ADDRESS,
|
|
||||||
"unshare": SNR_UNSHARE,
|
|
||||||
"futex": SNR_FUTEX,
|
|
||||||
"set_robust_list": SNR_SET_ROBUST_LIST,
|
|
||||||
"get_robust_list": SNR_GET_ROBUST_LIST,
|
|
||||||
"nanosleep": SNR_NANOSLEEP,
|
|
||||||
"getitimer": SNR_GETITIMER,
|
|
||||||
"setitimer": SNR_SETITIMER,
|
|
||||||
"kexec_load": SNR_KEXEC_LOAD,
|
|
||||||
"init_module": SNR_INIT_MODULE,
|
|
||||||
"delete_module": SNR_DELETE_MODULE,
|
|
||||||
"timer_create": SNR_TIMER_CREATE,
|
|
||||||
"timer_gettime": SNR_TIMER_GETTIME,
|
|
||||||
"timer_getoverrun": SNR_TIMER_GETOVERRUN,
|
|
||||||
"timer_settime": SNR_TIMER_SETTIME,
|
|
||||||
"timer_delete": SNR_TIMER_DELETE,
|
|
||||||
"clock_settime": SNR_CLOCK_SETTIME,
|
|
||||||
"clock_gettime": SNR_CLOCK_GETTIME,
|
|
||||||
"clock_getres": SNR_CLOCK_GETRES,
|
|
||||||
"clock_nanosleep": SNR_CLOCK_NANOSLEEP,
|
|
||||||
"syslog": SNR_SYSLOG,
|
|
||||||
"ptrace": SNR_PTRACE,
|
|
||||||
"sched_setparam": SNR_SCHED_SETPARAM,
|
|
||||||
"sched_setscheduler": SNR_SCHED_SETSCHEDULER,
|
|
||||||
"sched_getscheduler": SNR_SCHED_GETSCHEDULER,
|
|
||||||
"sched_getparam": SNR_SCHED_GETPARAM,
|
|
||||||
"sched_setaffinity": SNR_SCHED_SETAFFINITY,
|
|
||||||
"sched_getaffinity": SNR_SCHED_GETAFFINITY,
|
|
||||||
"sched_yield": SNR_SCHED_YIELD,
|
|
||||||
"sched_get_priority_max": SNR_SCHED_GET_PRIORITY_MAX,
|
|
||||||
"sched_get_priority_min": SNR_SCHED_GET_PRIORITY_MIN,
|
|
||||||
"sched_rr_get_interval": SNR_SCHED_RR_GET_INTERVAL,
|
|
||||||
"restart_syscall": SNR_RESTART_SYSCALL,
|
|
||||||
"kill": SNR_KILL,
|
|
||||||
"tkill": SNR_TKILL,
|
|
||||||
"tgkill": SNR_TGKILL,
|
|
||||||
"sigaltstack": SNR_SIGALTSTACK,
|
|
||||||
"rt_sigsuspend": SNR_RT_SIGSUSPEND,
|
|
||||||
"rt_sigaction": SNR_RT_SIGACTION,
|
|
||||||
"rt_sigprocmask": SNR_RT_SIGPROCMASK,
|
|
||||||
"rt_sigpending": SNR_RT_SIGPENDING,
|
|
||||||
"rt_sigtimedwait": SNR_RT_SIGTIMEDWAIT,
|
|
||||||
"rt_sigqueueinfo": SNR_RT_SIGQUEUEINFO,
|
|
||||||
"rt_sigreturn": SNR_RT_SIGRETURN,
|
|
||||||
"setpriority": SNR_SETPRIORITY,
|
|
||||||
"getpriority": SNR_GETPRIORITY,
|
|
||||||
"reboot": SNR_REBOOT,
|
|
||||||
"setregid": SNR_SETREGID,
|
|
||||||
"setgid": SNR_SETGID,
|
|
||||||
"setreuid": SNR_SETREUID,
|
|
||||||
"setuid": SNR_SETUID,
|
|
||||||
"setresuid": SNR_SETRESUID,
|
|
||||||
"getresuid": SNR_GETRESUID,
|
|
||||||
"setresgid": SNR_SETRESGID,
|
|
||||||
"getresgid": SNR_GETRESGID,
|
|
||||||
"setfsuid": SNR_SETFSUID,
|
|
||||||
"setfsgid": SNR_SETFSGID,
|
|
||||||
"times": SNR_TIMES,
|
|
||||||
"setpgid": SNR_SETPGID,
|
|
||||||
"getpgid": SNR_GETPGID,
|
|
||||||
"getsid": SNR_GETSID,
|
|
||||||
"setsid": SNR_SETSID,
|
|
||||||
"getgroups": SNR_GETGROUPS,
|
|
||||||
"setgroups": SNR_SETGROUPS,
|
|
||||||
"uname": SNR_UNAME,
|
|
||||||
"sethostname": SNR_SETHOSTNAME,
|
|
||||||
"setdomainname": SNR_SETDOMAINNAME,
|
|
||||||
"getrlimit": SNR_GETRLIMIT,
|
|
||||||
"setrlimit": SNR_SETRLIMIT,
|
|
||||||
"getrusage": SNR_GETRUSAGE,
|
|
||||||
"umask": SNR_UMASK,
|
|
||||||
"prctl": SNR_PRCTL,
|
|
||||||
"getcpu": SNR_GETCPU,
|
|
||||||
"gettimeofday": SNR_GETTIMEOFDAY,
|
|
||||||
"settimeofday": SNR_SETTIMEOFDAY,
|
|
||||||
"adjtimex": SNR_ADJTIMEX,
|
|
||||||
"getpid": SNR_GETPID,
|
|
||||||
"getppid": SNR_GETPPID,
|
|
||||||
"getuid": SNR_GETUID,
|
|
||||||
"geteuid": SNR_GETEUID,
|
|
||||||
"getgid": SNR_GETGID,
|
|
||||||
"getegid": SNR_GETEGID,
|
|
||||||
"gettid": SNR_GETTID,
|
|
||||||
"sysinfo": SNR_SYSINFO,
|
|
||||||
"mq_open": SNR_MQ_OPEN,
|
|
||||||
"mq_unlink": SNR_MQ_UNLINK,
|
|
||||||
"mq_timedsend": SNR_MQ_TIMEDSEND,
|
|
||||||
"mq_timedreceive": SNR_MQ_TIMEDRECEIVE,
|
|
||||||
"mq_notify": SNR_MQ_NOTIFY,
|
|
||||||
"mq_getsetattr": SNR_MQ_GETSETATTR,
|
|
||||||
"msgget": SNR_MSGGET,
|
|
||||||
"msgctl": SNR_MSGCTL,
|
|
||||||
"msgrcv": SNR_MSGRCV,
|
|
||||||
"msgsnd": SNR_MSGSND,
|
|
||||||
"semget": SNR_SEMGET,
|
|
||||||
"semctl": SNR_SEMCTL,
|
|
||||||
"semtimedop": SNR_SEMTIMEDOP,
|
|
||||||
"semop": SNR_SEMOP,
|
|
||||||
"shmget": SNR_SHMGET,
|
|
||||||
"shmctl": SNR_SHMCTL,
|
|
||||||
"shmat": SNR_SHMAT,
|
|
||||||
"shmdt": SNR_SHMDT,
|
|
||||||
"socket": SNR_SOCKET,
|
|
||||||
"socketpair": SNR_SOCKETPAIR,
|
|
||||||
"bind": SNR_BIND,
|
|
||||||
"listen": SNR_LISTEN,
|
|
||||||
"accept": SNR_ACCEPT,
|
|
||||||
"connect": SNR_CONNECT,
|
|
||||||
"getsockname": SNR_GETSOCKNAME,
|
|
||||||
"getpeername": SNR_GETPEERNAME,
|
|
||||||
"sendto": SNR_SENDTO,
|
|
||||||
"recvfrom": SNR_RECVFROM,
|
|
||||||
"setsockopt": SNR_SETSOCKOPT,
|
|
||||||
"getsockopt": SNR_GETSOCKOPT,
|
|
||||||
"shutdown": SNR_SHUTDOWN,
|
|
||||||
"sendmsg": SNR_SENDMSG,
|
|
||||||
"recvmsg": SNR_RECVMSG,
|
|
||||||
"readahead": SNR_READAHEAD,
|
|
||||||
"brk": SNR_BRK,
|
|
||||||
"munmap": SNR_MUNMAP,
|
|
||||||
"mremap": SNR_MREMAP,
|
|
||||||
"add_key": SNR_ADD_KEY,
|
|
||||||
"request_key": SNR_REQUEST_KEY,
|
|
||||||
"keyctl": SNR_KEYCTL,
|
|
||||||
"clone": SNR_CLONE,
|
|
||||||
"execve": SNR_EXECVE,
|
|
||||||
"mmap": SNR_MMAP,
|
|
||||||
"fadvise64": SNR_FADVISE64,
|
|
||||||
"swapon": SNR_SWAPON,
|
|
||||||
"swapoff": SNR_SWAPOFF,
|
|
||||||
"mprotect": SNR_MPROTECT,
|
|
||||||
"msync": SNR_MSYNC,
|
|
||||||
"mlock": SNR_MLOCK,
|
|
||||||
"munlock": SNR_MUNLOCK,
|
|
||||||
"mlockall": SNR_MLOCKALL,
|
|
||||||
"munlockall": SNR_MUNLOCKALL,
|
|
||||||
"mincore": SNR_MINCORE,
|
|
||||||
"madvise": SNR_MADVISE,
|
|
||||||
"remap_file_pages": SNR_REMAP_FILE_PAGES,
|
|
||||||
"mbind": SNR_MBIND,
|
|
||||||
"get_mempolicy": SNR_GET_MEMPOLICY,
|
|
||||||
"set_mempolicy": SNR_SET_MEMPOLICY,
|
|
||||||
"migrate_pages": SNR_MIGRATE_PAGES,
|
|
||||||
"move_pages": SNR_MOVE_PAGES,
|
|
||||||
"rt_tgsigqueueinfo": SNR_RT_TGSIGQUEUEINFO,
|
|
||||||
"perf_event_open": SNR_PERF_EVENT_OPEN,
|
|
||||||
"accept4": SNR_ACCEPT4,
|
|
||||||
"recvmmsg": SNR_RECVMMSG,
|
|
||||||
"wait4": SNR_WAIT4,
|
|
||||||
"prlimit64": SNR_PRLIMIT64,
|
|
||||||
"fanotify_init": SNR_FANOTIFY_INIT,
|
|
||||||
"fanotify_mark": SNR_FANOTIFY_MARK,
|
|
||||||
"name_to_handle_at": SNR_NAME_TO_HANDLE_AT,
|
|
||||||
"open_by_handle_at": SNR_OPEN_BY_HANDLE_AT,
|
|
||||||
"clock_adjtime": SNR_CLOCK_ADJTIME,
|
|
||||||
"syncfs": SNR_SYNCFS,
|
|
||||||
"setns": SNR_SETNS,
|
|
||||||
"sendmmsg": SNR_SENDMMSG,
|
|
||||||
"process_vm_readv": SNR_PROCESS_VM_READV,
|
|
||||||
"process_vm_writev": SNR_PROCESS_VM_WRITEV,
|
|
||||||
"kcmp": SNR_KCMP,
|
|
||||||
"finit_module": SNR_FINIT_MODULE,
|
|
||||||
"sched_setattr": SNR_SCHED_SETATTR,
|
|
||||||
"sched_getattr": SNR_SCHED_GETATTR,
|
|
||||||
"renameat2": SNR_RENAMEAT2,
|
|
||||||
"seccomp": SNR_SECCOMP,
|
|
||||||
"getrandom": SNR_GETRANDOM,
|
|
||||||
"memfd_create": SNR_MEMFD_CREATE,
|
|
||||||
"bpf": SNR_BPF,
|
|
||||||
"execveat": SNR_EXECVEAT,
|
|
||||||
"userfaultfd": SNR_USERFAULTFD,
|
|
||||||
"membarrier": SNR_MEMBARRIER,
|
|
||||||
"mlock2": SNR_MLOCK2,
|
|
||||||
"copy_file_range": SNR_COPY_FILE_RANGE,
|
|
||||||
"preadv2": SNR_PREADV2,
|
|
||||||
"pwritev2": SNR_PWRITEV2,
|
|
||||||
"pkey_mprotect": SNR_PKEY_MPROTECT,
|
|
||||||
"pkey_alloc": SNR_PKEY_ALLOC,
|
|
||||||
"pkey_free": SNR_PKEY_FREE,
|
|
||||||
"statx": SNR_STATX,
|
|
||||||
"io_pgetevents": SNR_IO_PGETEVENTS,
|
|
||||||
"rseq": SNR_RSEQ,
|
|
||||||
"kexec_file_load": SNR_KEXEC_FILE_LOAD,
|
|
||||||
"pidfd_send_signal": SNR_PIDFD_SEND_SIGNAL,
|
|
||||||
"io_uring_setup": SNR_IO_URING_SETUP,
|
|
||||||
"io_uring_enter": SNR_IO_URING_ENTER,
|
|
||||||
"io_uring_register": SNR_IO_URING_REGISTER,
|
|
||||||
"open_tree": SNR_OPEN_TREE,
|
|
||||||
"move_mount": SNR_MOVE_MOUNT,
|
|
||||||
"fsopen": SNR_FSOPEN,
|
|
||||||
"fsconfig": SNR_FSCONFIG,
|
|
||||||
"fsmount": SNR_FSMOUNT,
|
|
||||||
"fspick": SNR_FSPICK,
|
|
||||||
"pidfd_open": SNR_PIDFD_OPEN,
|
|
||||||
"clone3": SNR_CLONE3,
|
|
||||||
"close_range": SNR_CLOSE_RANGE,
|
|
||||||
"openat2": SNR_OPENAT2,
|
|
||||||
"pidfd_getfd": SNR_PIDFD_GETFD,
|
|
||||||
"faccessat2": SNR_FACCESSAT2,
|
|
||||||
"process_madvise": SNR_PROCESS_MADVISE,
|
|
||||||
"epoll_pwait2": SNR_EPOLL_PWAIT2,
|
|
||||||
"mount_setattr": SNR_MOUNT_SETATTR,
|
|
||||||
"quotactl_fd": SNR_QUOTACTL_FD,
|
|
||||||
"landlock_create_ruleset": SNR_LANDLOCK_CREATE_RULESET,
|
|
||||||
"landlock_add_rule": SNR_LANDLOCK_ADD_RULE,
|
|
||||||
"landlock_restrict_self": SNR_LANDLOCK_RESTRICT_SELF,
|
|
||||||
"memfd_secret": SNR_MEMFD_SECRET,
|
|
||||||
"process_mrelease": SNR_PROCESS_MRELEASE,
|
|
||||||
"futex_waitv": SNR_FUTEX_WAITV,
|
|
||||||
"set_mempolicy_home_node": SNR_SET_MEMPOLICY_HOME_NODE,
|
|
||||||
"cachestat": SNR_CACHESTAT,
|
|
||||||
"fchmodat2": SNR_FCHMODAT2,
|
|
||||||
"map_shadow_stack": SNR_MAP_SHADOW_STACK,
|
|
||||||
"futex_wake": SNR_FUTEX_WAKE,
|
|
||||||
"futex_wait": SNR_FUTEX_WAIT,
|
|
||||||
"futex_requeue": SNR_FUTEX_REQUEUE,
|
|
||||||
"statmount": SNR_STATMOUNT,
|
|
||||||
"listmount": SNR_LISTMOUNT,
|
|
||||||
"lsm_get_self_attr": SNR_LSM_GET_SELF_ATTR,
|
|
||||||
"lsm_set_self_attr": SNR_LSM_SET_SELF_ATTR,
|
|
||||||
"lsm_list_modules": SNR_LSM_LIST_MODULES,
|
|
||||||
"mseal": SNR_MSEAL,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_USERFAULTFD = 282
|
|
||||||
SYS_MEMBARRIER = 283
|
|
||||||
SYS_MLOCK2 = 284
|
|
||||||
SYS_COPY_FILE_RANGE = 285
|
|
||||||
SYS_PREADV2 = 286
|
|
||||||
SYS_PWRITEV2 = 287
|
|
||||||
SYS_PKEY_MPROTECT = 288
|
|
||||||
SYS_PKEY_ALLOC = 289
|
|
||||||
SYS_PKEY_FREE = 290
|
|
||||||
SYS_STATX = 291
|
|
||||||
SYS_IO_PGETEVENTS = 292
|
|
||||||
SYS_RSEQ = 293
|
|
||||||
SYS_KEXEC_FILE_LOAD = 294
|
|
||||||
SYS_PIDFD_SEND_SIGNAL = 424
|
|
||||||
SYS_IO_URING_SETUP = 425
|
|
||||||
SYS_IO_URING_ENTER = 426
|
|
||||||
SYS_IO_URING_REGISTER = 427
|
|
||||||
SYS_OPEN_TREE = 428
|
|
||||||
SYS_MOVE_MOUNT = 429
|
|
||||||
SYS_FSOPEN = 430
|
|
||||||
SYS_FSCONFIG = 431
|
|
||||||
SYS_FSMOUNT = 432
|
|
||||||
SYS_FSPICK = 433
|
|
||||||
SYS_PIDFD_OPEN = 434
|
|
||||||
SYS_CLONE3 = 435
|
|
||||||
SYS_CLOSE_RANGE = 436
|
|
||||||
SYS_OPENAT2 = 437
|
|
||||||
SYS_PIDFD_GETFD = 438
|
|
||||||
SYS_FACCESSAT2 = 439
|
|
||||||
SYS_PROCESS_MADVISE = 440
|
|
||||||
SYS_EPOLL_PWAIT2 = 441
|
|
||||||
SYS_MOUNT_SETATTR = 442
|
|
||||||
SYS_QUOTACTL_FD = 443
|
|
||||||
SYS_LANDLOCK_CREATE_RULESET = 444
|
|
||||||
SYS_LANDLOCK_ADD_RULE = 445
|
|
||||||
SYS_LANDLOCK_RESTRICT_SELF = 446
|
|
||||||
SYS_MEMFD_SECRET = 447
|
|
||||||
SYS_PROCESS_MRELEASE = 448
|
|
||||||
SYS_FUTEX_WAITV = 449
|
|
||||||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
|
||||||
SYS_CACHESTAT = 451
|
|
||||||
SYS_FCHMODAT2 = 452
|
|
||||||
SYS_MAP_SHADOW_STACK = 453
|
|
||||||
SYS_FUTEX_WAKE = 454
|
|
||||||
SYS_FUTEX_WAIT = 455
|
|
||||||
SYS_FUTEX_REQUEUE = 456
|
|
||||||
SYS_STATMOUNT = 457
|
|
||||||
SYS_LISTMOUNT = 458
|
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
|
||||||
SYS_LSM_LIST_MODULES = 461
|
|
||||||
SYS_MSEAL = 462
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_IO_SETUP ScmpSyscall = SYS_IO_SETUP
|
|
||||||
SNR_IO_DESTROY ScmpSyscall = SYS_IO_DESTROY
|
|
||||||
SNR_IO_SUBMIT ScmpSyscall = SYS_IO_SUBMIT
|
|
||||||
SNR_IO_CANCEL ScmpSyscall = SYS_IO_CANCEL
|
|
||||||
SNR_IO_GETEVENTS ScmpSyscall = SYS_IO_GETEVENTS
|
|
||||||
SNR_SETXATTR ScmpSyscall = SYS_SETXATTR
|
|
||||||
SNR_LSETXATTR ScmpSyscall = SYS_LSETXATTR
|
|
||||||
SNR_FSETXATTR ScmpSyscall = SYS_FSETXATTR
|
|
||||||
SNR_GETXATTR ScmpSyscall = SYS_GETXATTR
|
|
||||||
SNR_LGETXATTR ScmpSyscall = SYS_LGETXATTR
|
|
||||||
SNR_FGETXATTR ScmpSyscall = SYS_FGETXATTR
|
|
||||||
SNR_LISTXATTR ScmpSyscall = SYS_LISTXATTR
|
|
||||||
SNR_LLISTXATTR ScmpSyscall = SYS_LLISTXATTR
|
|
||||||
SNR_FLISTXATTR ScmpSyscall = SYS_FLISTXATTR
|
|
||||||
SNR_REMOVEXATTR ScmpSyscall = SYS_REMOVEXATTR
|
|
||||||
SNR_LREMOVEXATTR ScmpSyscall = SYS_LREMOVEXATTR
|
|
||||||
SNR_FREMOVEXATTR ScmpSyscall = SYS_FREMOVEXATTR
|
|
||||||
SNR_GETCWD ScmpSyscall = SYS_GETCWD
|
|
||||||
SNR_LOOKUP_DCOOKIE ScmpSyscall = SYS_LOOKUP_DCOOKIE
|
|
||||||
SNR_EVENTFD2 ScmpSyscall = SYS_EVENTFD2
|
|
||||||
SNR_EPOLL_CREATE1 ScmpSyscall = SYS_EPOLL_CREATE1
|
|
||||||
SNR_EPOLL_CTL ScmpSyscall = SYS_EPOLL_CTL
|
|
||||||
SNR_EPOLL_PWAIT ScmpSyscall = SYS_EPOLL_PWAIT
|
|
||||||
SNR_DUP ScmpSyscall = SYS_DUP
|
|
||||||
SNR_DUP3 ScmpSyscall = SYS_DUP3
|
|
||||||
SNR_FCNTL ScmpSyscall = SYS_FCNTL
|
|
||||||
SNR_INOTIFY_INIT1 ScmpSyscall = SYS_INOTIFY_INIT1
|
|
||||||
SNR_INOTIFY_ADD_WATCH ScmpSyscall = SYS_INOTIFY_ADD_WATCH
|
|
||||||
SNR_INOTIFY_RM_WATCH ScmpSyscall = SYS_INOTIFY_RM_WATCH
|
|
||||||
SNR_IOCTL ScmpSyscall = SYS_IOCTL
|
|
||||||
SNR_IOPRIO_SET ScmpSyscall = SYS_IOPRIO_SET
|
|
||||||
SNR_IOPRIO_GET ScmpSyscall = SYS_IOPRIO_GET
|
|
||||||
SNR_FLOCK ScmpSyscall = SYS_FLOCK
|
|
||||||
SNR_MKNODAT ScmpSyscall = SYS_MKNODAT
|
|
||||||
SNR_MKDIRAT ScmpSyscall = SYS_MKDIRAT
|
|
||||||
SNR_UNLINKAT ScmpSyscall = SYS_UNLINKAT
|
|
||||||
SNR_SYMLINKAT ScmpSyscall = SYS_SYMLINKAT
|
|
||||||
SNR_LINKAT ScmpSyscall = SYS_LINKAT
|
|
||||||
SNR_RENAMEAT ScmpSyscall = SYS_RENAMEAT
|
|
||||||
SNR_UMOUNT2 ScmpSyscall = SYS_UMOUNT2
|
|
||||||
SNR_MOUNT ScmpSyscall = SYS_MOUNT
|
|
||||||
SNR_PIVOT_ROOT ScmpSyscall = SYS_PIVOT_ROOT
|
|
||||||
SNR_NFSSERVCTL ScmpSyscall = SYS_NFSSERVCTL
|
|
||||||
SNR_STATFS ScmpSyscall = SYS_STATFS
|
|
||||||
SNR_FSTATFS ScmpSyscall = SYS_FSTATFS
|
|
||||||
SNR_TRUNCATE ScmpSyscall = SYS_TRUNCATE
|
|
||||||
SNR_FTRUNCATE ScmpSyscall = SYS_FTRUNCATE
|
|
||||||
SNR_FALLOCATE ScmpSyscall = SYS_FALLOCATE
|
|
||||||
SNR_FACCESSAT ScmpSyscall = SYS_FACCESSAT
|
|
||||||
SNR_CHDIR ScmpSyscall = SYS_CHDIR
|
|
||||||
SNR_FCHDIR ScmpSyscall = SYS_FCHDIR
|
|
||||||
SNR_CHROOT ScmpSyscall = SYS_CHROOT
|
|
||||||
SNR_FCHMOD ScmpSyscall = SYS_FCHMOD
|
|
||||||
SNR_FCHMODAT ScmpSyscall = SYS_FCHMODAT
|
|
||||||
SNR_FCHOWNAT ScmpSyscall = SYS_FCHOWNAT
|
|
||||||
SNR_FCHOWN ScmpSyscall = SYS_FCHOWN
|
|
||||||
SNR_OPENAT ScmpSyscall = SYS_OPENAT
|
|
||||||
SNR_CLOSE ScmpSyscall = SYS_CLOSE
|
|
||||||
SNR_VHANGUP ScmpSyscall = SYS_VHANGUP
|
|
||||||
SNR_PIPE2 ScmpSyscall = SYS_PIPE2
|
|
||||||
SNR_QUOTACTL ScmpSyscall = SYS_QUOTACTL
|
|
||||||
SNR_GETDENTS64 ScmpSyscall = SYS_GETDENTS64
|
|
||||||
SNR_LSEEK ScmpSyscall = SYS_LSEEK
|
|
||||||
SNR_READ ScmpSyscall = SYS_READ
|
|
||||||
SNR_WRITE ScmpSyscall = SYS_WRITE
|
|
||||||
SNR_READV ScmpSyscall = SYS_READV
|
|
||||||
SNR_WRITEV ScmpSyscall = SYS_WRITEV
|
|
||||||
SNR_PREAD64 ScmpSyscall = SYS_PREAD64
|
|
||||||
SNR_PWRITE64 ScmpSyscall = SYS_PWRITE64
|
|
||||||
SNR_PREADV ScmpSyscall = SYS_PREADV
|
|
||||||
SNR_PWRITEV ScmpSyscall = SYS_PWRITEV
|
|
||||||
SNR_SENDFILE ScmpSyscall = SYS_SENDFILE
|
|
||||||
SNR_PSELECT6 ScmpSyscall = SYS_PSELECT6
|
|
||||||
SNR_PPOLL ScmpSyscall = SYS_PPOLL
|
|
||||||
SNR_SIGNALFD4 ScmpSyscall = SYS_SIGNALFD4
|
|
||||||
SNR_VMSPLICE ScmpSyscall = SYS_VMSPLICE
|
|
||||||
SNR_SPLICE ScmpSyscall = SYS_SPLICE
|
|
||||||
SNR_TEE ScmpSyscall = SYS_TEE
|
|
||||||
SNR_READLINKAT ScmpSyscall = SYS_READLINKAT
|
|
||||||
SNR_NEWFSTATAT ScmpSyscall = SYS_NEWFSTATAT
|
|
||||||
SNR_FSTAT ScmpSyscall = SYS_FSTAT
|
|
||||||
SNR_SYNC ScmpSyscall = SYS_SYNC
|
|
||||||
SNR_FSYNC ScmpSyscall = SYS_FSYNC
|
|
||||||
SNR_FDATASYNC ScmpSyscall = SYS_FDATASYNC
|
|
||||||
SNR_SYNC_FILE_RANGE ScmpSyscall = SYS_SYNC_FILE_RANGE
|
|
||||||
SNR_TIMERFD_CREATE ScmpSyscall = SYS_TIMERFD_CREATE
|
|
||||||
SNR_TIMERFD_SETTIME ScmpSyscall = SYS_TIMERFD_SETTIME
|
|
||||||
SNR_TIMERFD_GETTIME ScmpSyscall = SYS_TIMERFD_GETTIME
|
|
||||||
SNR_UTIMENSAT ScmpSyscall = SYS_UTIMENSAT
|
|
||||||
SNR_ACCT ScmpSyscall = SYS_ACCT
|
|
||||||
SNR_CAPGET ScmpSyscall = SYS_CAPGET
|
|
||||||
SNR_CAPSET ScmpSyscall = SYS_CAPSET
|
|
||||||
SNR_PERSONALITY ScmpSyscall = SYS_PERSONALITY
|
|
||||||
SNR_EXIT ScmpSyscall = SYS_EXIT
|
|
||||||
SNR_EXIT_GROUP ScmpSyscall = SYS_EXIT_GROUP
|
|
||||||
SNR_WAITID ScmpSyscall = SYS_WAITID
|
|
||||||
SNR_SET_TID_ADDRESS ScmpSyscall = SYS_SET_TID_ADDRESS
|
|
||||||
SNR_UNSHARE ScmpSyscall = SYS_UNSHARE
|
|
||||||
SNR_FUTEX ScmpSyscall = SYS_FUTEX
|
|
||||||
SNR_SET_ROBUST_LIST ScmpSyscall = SYS_SET_ROBUST_LIST
|
|
||||||
SNR_GET_ROBUST_LIST ScmpSyscall = SYS_GET_ROBUST_LIST
|
|
||||||
SNR_NANOSLEEP ScmpSyscall = SYS_NANOSLEEP
|
|
||||||
SNR_GETITIMER ScmpSyscall = SYS_GETITIMER
|
|
||||||
SNR_SETITIMER ScmpSyscall = SYS_SETITIMER
|
|
||||||
SNR_KEXEC_LOAD ScmpSyscall = SYS_KEXEC_LOAD
|
|
||||||
SNR_INIT_MODULE ScmpSyscall = SYS_INIT_MODULE
|
|
||||||
SNR_DELETE_MODULE ScmpSyscall = SYS_DELETE_MODULE
|
|
||||||
SNR_TIMER_CREATE ScmpSyscall = SYS_TIMER_CREATE
|
|
||||||
SNR_TIMER_GETTIME ScmpSyscall = SYS_TIMER_GETTIME
|
|
||||||
SNR_TIMER_GETOVERRUN ScmpSyscall = SYS_TIMER_GETOVERRUN
|
|
||||||
SNR_TIMER_SETTIME ScmpSyscall = SYS_TIMER_SETTIME
|
|
||||||
SNR_TIMER_DELETE ScmpSyscall = SYS_TIMER_DELETE
|
|
||||||
SNR_CLOCK_SETTIME ScmpSyscall = SYS_CLOCK_SETTIME
|
|
||||||
SNR_CLOCK_GETTIME ScmpSyscall = SYS_CLOCK_GETTIME
|
|
||||||
SNR_CLOCK_GETRES ScmpSyscall = SYS_CLOCK_GETRES
|
|
||||||
SNR_CLOCK_NANOSLEEP ScmpSyscall = SYS_CLOCK_NANOSLEEP
|
|
||||||
SNR_SYSLOG ScmpSyscall = SYS_SYSLOG
|
|
||||||
SNR_PTRACE ScmpSyscall = SYS_PTRACE
|
|
||||||
SNR_SCHED_SETPARAM ScmpSyscall = SYS_SCHED_SETPARAM
|
|
||||||
SNR_SCHED_SETSCHEDULER ScmpSyscall = SYS_SCHED_SETSCHEDULER
|
|
||||||
SNR_SCHED_GETSCHEDULER ScmpSyscall = SYS_SCHED_GETSCHEDULER
|
|
||||||
SNR_SCHED_GETPARAM ScmpSyscall = SYS_SCHED_GETPARAM
|
|
||||||
SNR_SCHED_SETAFFINITY ScmpSyscall = SYS_SCHED_SETAFFINITY
|
|
||||||
SNR_SCHED_GETAFFINITY ScmpSyscall = SYS_SCHED_GETAFFINITY
|
|
||||||
SNR_SCHED_YIELD ScmpSyscall = SYS_SCHED_YIELD
|
|
||||||
SNR_SCHED_GET_PRIORITY_MAX ScmpSyscall = SYS_SCHED_GET_PRIORITY_MAX
|
|
||||||
SNR_SCHED_GET_PRIORITY_MIN ScmpSyscall = SYS_SCHED_GET_PRIORITY_MIN
|
|
||||||
SNR_SCHED_RR_GET_INTERVAL ScmpSyscall = SYS_SCHED_RR_GET_INTERVAL
|
|
||||||
SNR_RESTART_SYSCALL ScmpSyscall = SYS_RESTART_SYSCALL
|
|
||||||
SNR_KILL ScmpSyscall = SYS_KILL
|
|
||||||
SNR_TKILL ScmpSyscall = SYS_TKILL
|
|
||||||
SNR_TGKILL ScmpSyscall = SYS_TGKILL
|
|
||||||
SNR_SIGALTSTACK ScmpSyscall = SYS_SIGALTSTACK
|
|
||||||
SNR_RT_SIGSUSPEND ScmpSyscall = SYS_RT_SIGSUSPEND
|
|
||||||
SNR_RT_SIGACTION ScmpSyscall = SYS_RT_SIGACTION
|
|
||||||
SNR_RT_SIGPROCMASK ScmpSyscall = SYS_RT_SIGPROCMASK
|
|
||||||
SNR_RT_SIGPENDING ScmpSyscall = SYS_RT_SIGPENDING
|
|
||||||
SNR_RT_SIGTIMEDWAIT ScmpSyscall = SYS_RT_SIGTIMEDWAIT
|
|
||||||
SNR_RT_SIGQUEUEINFO ScmpSyscall = SYS_RT_SIGQUEUEINFO
|
|
||||||
SNR_RT_SIGRETURN ScmpSyscall = SYS_RT_SIGRETURN
|
|
||||||
SNR_SETPRIORITY ScmpSyscall = SYS_SETPRIORITY
|
|
||||||
SNR_GETPRIORITY ScmpSyscall = SYS_GETPRIORITY
|
|
||||||
SNR_REBOOT ScmpSyscall = SYS_REBOOT
|
|
||||||
SNR_SETREGID ScmpSyscall = SYS_SETREGID
|
|
||||||
SNR_SETGID ScmpSyscall = SYS_SETGID
|
|
||||||
SNR_SETREUID ScmpSyscall = SYS_SETREUID
|
|
||||||
SNR_SETUID ScmpSyscall = SYS_SETUID
|
|
||||||
SNR_SETRESUID ScmpSyscall = SYS_SETRESUID
|
|
||||||
SNR_GETRESUID ScmpSyscall = SYS_GETRESUID
|
|
||||||
SNR_SETRESGID ScmpSyscall = SYS_SETRESGID
|
|
||||||
SNR_GETRESGID ScmpSyscall = SYS_GETRESGID
|
|
||||||
SNR_SETFSUID ScmpSyscall = SYS_SETFSUID
|
|
||||||
SNR_SETFSGID ScmpSyscall = SYS_SETFSGID
|
|
||||||
SNR_TIMES ScmpSyscall = SYS_TIMES
|
|
||||||
SNR_SETPGID ScmpSyscall = SYS_SETPGID
|
|
||||||
SNR_GETPGID ScmpSyscall = SYS_GETPGID
|
|
||||||
SNR_GETSID ScmpSyscall = SYS_GETSID
|
|
||||||
SNR_SETSID ScmpSyscall = SYS_SETSID
|
|
||||||
SNR_GETGROUPS ScmpSyscall = SYS_GETGROUPS
|
|
||||||
SNR_SETGROUPS ScmpSyscall = SYS_SETGROUPS
|
|
||||||
SNR_UNAME ScmpSyscall = SYS_UNAME
|
|
||||||
SNR_SETHOSTNAME ScmpSyscall = SYS_SETHOSTNAME
|
|
||||||
SNR_SETDOMAINNAME ScmpSyscall = SYS_SETDOMAINNAME
|
|
||||||
SNR_GETRLIMIT ScmpSyscall = SYS_GETRLIMIT
|
|
||||||
SNR_SETRLIMIT ScmpSyscall = SYS_SETRLIMIT
|
|
||||||
SNR_GETRUSAGE ScmpSyscall = SYS_GETRUSAGE
|
|
||||||
SNR_UMASK ScmpSyscall = SYS_UMASK
|
|
||||||
SNR_PRCTL ScmpSyscall = SYS_PRCTL
|
|
||||||
SNR_GETCPU ScmpSyscall = SYS_GETCPU
|
|
||||||
SNR_GETTIMEOFDAY ScmpSyscall = SYS_GETTIMEOFDAY
|
|
||||||
SNR_SETTIMEOFDAY ScmpSyscall = SYS_SETTIMEOFDAY
|
|
||||||
SNR_ADJTIMEX ScmpSyscall = SYS_ADJTIMEX
|
|
||||||
SNR_GETPID ScmpSyscall = SYS_GETPID
|
|
||||||
SNR_GETPPID ScmpSyscall = SYS_GETPPID
|
|
||||||
SNR_GETUID ScmpSyscall = SYS_GETUID
|
|
||||||
SNR_GETEUID ScmpSyscall = SYS_GETEUID
|
|
||||||
SNR_GETGID ScmpSyscall = SYS_GETGID
|
|
||||||
SNR_GETEGID ScmpSyscall = SYS_GETEGID
|
|
||||||
SNR_GETTID ScmpSyscall = SYS_GETTID
|
|
||||||
SNR_SYSINFO ScmpSyscall = SYS_SYSINFO
|
|
||||||
SNR_MQ_OPEN ScmpSyscall = SYS_MQ_OPEN
|
|
||||||
SNR_MQ_UNLINK ScmpSyscall = SYS_MQ_UNLINK
|
|
||||||
SNR_MQ_TIMEDSEND ScmpSyscall = SYS_MQ_TIMEDSEND
|
|
||||||
SNR_MQ_TIMEDRECEIVE ScmpSyscall = SYS_MQ_TIMEDRECEIVE
|
|
||||||
SNR_MQ_NOTIFY ScmpSyscall = SYS_MQ_NOTIFY
|
|
||||||
SNR_MQ_GETSETATTR ScmpSyscall = SYS_MQ_GETSETATTR
|
|
||||||
SNR_MSGGET ScmpSyscall = SYS_MSGGET
|
|
||||||
SNR_MSGCTL ScmpSyscall = SYS_MSGCTL
|
|
||||||
SNR_MSGRCV ScmpSyscall = SYS_MSGRCV
|
|
||||||
SNR_MSGSND ScmpSyscall = SYS_MSGSND
|
|
||||||
SNR_SEMGET ScmpSyscall = SYS_SEMGET
|
|
||||||
SNR_SEMCTL ScmpSyscall = SYS_SEMCTL
|
|
||||||
SNR_SEMTIMEDOP ScmpSyscall = SYS_SEMTIMEDOP
|
|
||||||
SNR_SEMOP ScmpSyscall = SYS_SEMOP
|
|
||||||
SNR_SHMGET ScmpSyscall = SYS_SHMGET
|
|
||||||
SNR_SHMCTL ScmpSyscall = SYS_SHMCTL
|
|
||||||
SNR_SHMAT ScmpSyscall = SYS_SHMAT
|
|
||||||
SNR_SHMDT ScmpSyscall = SYS_SHMDT
|
|
||||||
SNR_SOCKET ScmpSyscall = SYS_SOCKET
|
|
||||||
SNR_SOCKETPAIR ScmpSyscall = SYS_SOCKETPAIR
|
|
||||||
SNR_BIND ScmpSyscall = SYS_BIND
|
|
||||||
SNR_LISTEN ScmpSyscall = SYS_LISTEN
|
|
||||||
SNR_ACCEPT ScmpSyscall = SYS_ACCEPT
|
|
||||||
SNR_CONNECT ScmpSyscall = SYS_CONNECT
|
|
||||||
SNR_GETSOCKNAME ScmpSyscall = SYS_GETSOCKNAME
|
|
||||||
SNR_GETPEERNAME ScmpSyscall = SYS_GETPEERNAME
|
|
||||||
SNR_SENDTO ScmpSyscall = SYS_SENDTO
|
|
||||||
SNR_RECVFROM ScmpSyscall = SYS_RECVFROM
|
|
||||||
SNR_SETSOCKOPT ScmpSyscall = SYS_SETSOCKOPT
|
|
||||||
SNR_GETSOCKOPT ScmpSyscall = SYS_GETSOCKOPT
|
|
||||||
SNR_SHUTDOWN ScmpSyscall = SYS_SHUTDOWN
|
|
||||||
SNR_SENDMSG ScmpSyscall = SYS_SENDMSG
|
|
||||||
SNR_RECVMSG ScmpSyscall = SYS_RECVMSG
|
|
||||||
SNR_READAHEAD ScmpSyscall = SYS_READAHEAD
|
|
||||||
SNR_BRK ScmpSyscall = SYS_BRK
|
|
||||||
SNR_MUNMAP ScmpSyscall = SYS_MUNMAP
|
|
||||||
SNR_MREMAP ScmpSyscall = SYS_MREMAP
|
|
||||||
SNR_ADD_KEY ScmpSyscall = SYS_ADD_KEY
|
|
||||||
SNR_REQUEST_KEY ScmpSyscall = SYS_REQUEST_KEY
|
|
||||||
SNR_KEYCTL ScmpSyscall = SYS_KEYCTL
|
|
||||||
SNR_CLONE ScmpSyscall = SYS_CLONE
|
|
||||||
SNR_EXECVE ScmpSyscall = SYS_EXECVE
|
|
||||||
SNR_MMAP ScmpSyscall = SYS_MMAP
|
|
||||||
SNR_FADVISE64 ScmpSyscall = SYS_FADVISE64
|
|
||||||
SNR_SWAPON ScmpSyscall = SYS_SWAPON
|
|
||||||
SNR_SWAPOFF ScmpSyscall = SYS_SWAPOFF
|
|
||||||
SNR_MPROTECT ScmpSyscall = SYS_MPROTECT
|
|
||||||
SNR_MSYNC ScmpSyscall = SYS_MSYNC
|
|
||||||
SNR_MLOCK ScmpSyscall = SYS_MLOCK
|
|
||||||
SNR_MUNLOCK ScmpSyscall = SYS_MUNLOCK
|
|
||||||
SNR_MLOCKALL ScmpSyscall = SYS_MLOCKALL
|
|
||||||
SNR_MUNLOCKALL ScmpSyscall = SYS_MUNLOCKALL
|
|
||||||
SNR_MINCORE ScmpSyscall = SYS_MINCORE
|
|
||||||
SNR_MADVISE ScmpSyscall = SYS_MADVISE
|
|
||||||
SNR_REMAP_FILE_PAGES ScmpSyscall = SYS_REMAP_FILE_PAGES
|
|
||||||
SNR_MBIND ScmpSyscall = SYS_MBIND
|
|
||||||
SNR_GET_MEMPOLICY ScmpSyscall = SYS_GET_MEMPOLICY
|
|
||||||
SNR_SET_MEMPOLICY ScmpSyscall = SYS_SET_MEMPOLICY
|
|
||||||
SNR_MIGRATE_PAGES ScmpSyscall = SYS_MIGRATE_PAGES
|
|
||||||
SNR_MOVE_PAGES ScmpSyscall = SYS_MOVE_PAGES
|
|
||||||
SNR_RT_TGSIGQUEUEINFO ScmpSyscall = SYS_RT_TGSIGQUEUEINFO
|
|
||||||
SNR_PERF_EVENT_OPEN ScmpSyscall = SYS_PERF_EVENT_OPEN
|
|
||||||
SNR_ACCEPT4 ScmpSyscall = SYS_ACCEPT4
|
|
||||||
SNR_RECVMMSG ScmpSyscall = SYS_RECVMMSG
|
|
||||||
SNR_WAIT4 ScmpSyscall = SYS_WAIT4
|
|
||||||
SNR_PRLIMIT64 ScmpSyscall = SYS_PRLIMIT64
|
|
||||||
SNR_FANOTIFY_INIT ScmpSyscall = SYS_FANOTIFY_INIT
|
|
||||||
SNR_FANOTIFY_MARK ScmpSyscall = SYS_FANOTIFY_MARK
|
|
||||||
SNR_NAME_TO_HANDLE_AT ScmpSyscall = SYS_NAME_TO_HANDLE_AT
|
|
||||||
SNR_OPEN_BY_HANDLE_AT ScmpSyscall = SYS_OPEN_BY_HANDLE_AT
|
|
||||||
SNR_CLOCK_ADJTIME ScmpSyscall = SYS_CLOCK_ADJTIME
|
|
||||||
SNR_SYNCFS ScmpSyscall = SYS_SYNCFS
|
|
||||||
SNR_SETNS ScmpSyscall = SYS_SETNS
|
|
||||||
SNR_SENDMMSG ScmpSyscall = SYS_SENDMMSG
|
|
||||||
SNR_PROCESS_VM_READV ScmpSyscall = SYS_PROCESS_VM_READV
|
|
||||||
SNR_PROCESS_VM_WRITEV ScmpSyscall = SYS_PROCESS_VM_WRITEV
|
|
||||||
SNR_KCMP ScmpSyscall = SYS_KCMP
|
|
||||||
SNR_FINIT_MODULE ScmpSyscall = SYS_FINIT_MODULE
|
|
||||||
SNR_SCHED_SETATTR ScmpSyscall = SYS_SCHED_SETATTR
|
|
||||||
SNR_SCHED_GETATTR ScmpSyscall = SYS_SCHED_GETATTR
|
|
||||||
SNR_RENAMEAT2 ScmpSyscall = SYS_RENAMEAT2
|
|
||||||
SNR_SECCOMP ScmpSyscall = SYS_SECCOMP
|
|
||||||
SNR_GETRANDOM ScmpSyscall = SYS_GETRANDOM
|
|
||||||
SNR_MEMFD_CREATE ScmpSyscall = SYS_MEMFD_CREATE
|
|
||||||
SNR_BPF ScmpSyscall = SYS_BPF
|
|
||||||
SNR_EXECVEAT ScmpSyscall = SYS_EXECVEAT
|
|
||||||
SNR_USERFAULTFD ScmpSyscall = SYS_USERFAULTFD
|
|
||||||
SNR_MEMBARRIER ScmpSyscall = SYS_MEMBARRIER
|
|
||||||
SNR_MLOCK2 ScmpSyscall = SYS_MLOCK2
|
|
||||||
SNR_COPY_FILE_RANGE ScmpSyscall = SYS_COPY_FILE_RANGE
|
|
||||||
SNR_PREADV2 ScmpSyscall = SYS_PREADV2
|
|
||||||
SNR_PWRITEV2 ScmpSyscall = SYS_PWRITEV2
|
|
||||||
SNR_PKEY_MPROTECT ScmpSyscall = SYS_PKEY_MPROTECT
|
|
||||||
SNR_PKEY_ALLOC ScmpSyscall = SYS_PKEY_ALLOC
|
|
||||||
SNR_PKEY_FREE ScmpSyscall = SYS_PKEY_FREE
|
|
||||||
SNR_STATX ScmpSyscall = SYS_STATX
|
|
||||||
SNR_IO_PGETEVENTS ScmpSyscall = SYS_IO_PGETEVENTS
|
|
||||||
SNR_RSEQ ScmpSyscall = SYS_RSEQ
|
|
||||||
SNR_KEXEC_FILE_LOAD ScmpSyscall = SYS_KEXEC_FILE_LOAD
|
|
||||||
SNR_PIDFD_SEND_SIGNAL ScmpSyscall = SYS_PIDFD_SEND_SIGNAL
|
|
||||||
SNR_IO_URING_SETUP ScmpSyscall = SYS_IO_URING_SETUP
|
|
||||||
SNR_IO_URING_ENTER ScmpSyscall = SYS_IO_URING_ENTER
|
|
||||||
SNR_IO_URING_REGISTER ScmpSyscall = SYS_IO_URING_REGISTER
|
|
||||||
SNR_OPEN_TREE ScmpSyscall = SYS_OPEN_TREE
|
|
||||||
SNR_MOVE_MOUNT ScmpSyscall = SYS_MOVE_MOUNT
|
|
||||||
SNR_FSOPEN ScmpSyscall = SYS_FSOPEN
|
|
||||||
SNR_FSCONFIG ScmpSyscall = SYS_FSCONFIG
|
|
||||||
SNR_FSMOUNT ScmpSyscall = SYS_FSMOUNT
|
|
||||||
SNR_FSPICK ScmpSyscall = SYS_FSPICK
|
|
||||||
SNR_PIDFD_OPEN ScmpSyscall = SYS_PIDFD_OPEN
|
|
||||||
SNR_CLONE3 ScmpSyscall = SYS_CLONE3
|
|
||||||
SNR_CLOSE_RANGE ScmpSyscall = SYS_CLOSE_RANGE
|
|
||||||
SNR_OPENAT2 ScmpSyscall = SYS_OPENAT2
|
|
||||||
SNR_PIDFD_GETFD ScmpSyscall = SYS_PIDFD_GETFD
|
|
||||||
SNR_FACCESSAT2 ScmpSyscall = SYS_FACCESSAT2
|
|
||||||
SNR_PROCESS_MADVISE ScmpSyscall = SYS_PROCESS_MADVISE
|
|
||||||
SNR_EPOLL_PWAIT2 ScmpSyscall = SYS_EPOLL_PWAIT2
|
|
||||||
SNR_MOUNT_SETATTR ScmpSyscall = SYS_MOUNT_SETATTR
|
|
||||||
SNR_QUOTACTL_FD ScmpSyscall = SYS_QUOTACTL_FD
|
|
||||||
SNR_LANDLOCK_CREATE_RULESET ScmpSyscall = SYS_LANDLOCK_CREATE_RULESET
|
|
||||||
SNR_LANDLOCK_ADD_RULE ScmpSyscall = SYS_LANDLOCK_ADD_RULE
|
|
||||||
SNR_LANDLOCK_RESTRICT_SELF ScmpSyscall = SYS_LANDLOCK_RESTRICT_SELF
|
|
||||||
SNR_MEMFD_SECRET ScmpSyscall = SYS_MEMFD_SECRET
|
|
||||||
SNR_PROCESS_MRELEASE ScmpSyscall = SYS_PROCESS_MRELEASE
|
|
||||||
SNR_FUTEX_WAITV ScmpSyscall = SYS_FUTEX_WAITV
|
|
||||||
SNR_SET_MEMPOLICY_HOME_NODE ScmpSyscall = SYS_SET_MEMPOLICY_HOME_NODE
|
|
||||||
SNR_CACHESTAT ScmpSyscall = SYS_CACHESTAT
|
|
||||||
SNR_FCHMODAT2 ScmpSyscall = SYS_FCHMODAT2
|
|
||||||
SNR_MAP_SHADOW_STACK ScmpSyscall = SYS_MAP_SHADOW_STACK
|
|
||||||
SNR_FUTEX_WAKE ScmpSyscall = SYS_FUTEX_WAKE
|
|
||||||
SNR_FUTEX_WAIT ScmpSyscall = SYS_FUTEX_WAIT
|
|
||||||
SNR_FUTEX_REQUEUE ScmpSyscall = SYS_FUTEX_REQUEUE
|
|
||||||
SNR_STATMOUNT ScmpSyscall = SYS_STATMOUNT
|
|
||||||
SNR_LISTMOUNT ScmpSyscall = SYS_LISTMOUNT
|
|
||||||
SNR_LSM_GET_SELF_ATTR ScmpSyscall = SYS_LSM_GET_SELF_ATTR
|
|
||||||
SNR_LSM_SET_SELF_ATTR ScmpSyscall = SYS_LSM_SET_SELF_ATTR
|
|
||||||
SNR_LSM_LIST_MODULES ScmpSyscall = SYS_LSM_LIST_MODULES
|
|
||||||
SNR_MSEAL ScmpSyscall = SYS_MSEAL
|
|
||||||
)
|
|
||||||
@@ -1,719 +0,0 @@
|
|||||||
// mksysnum_linux.pl /usr/include/riscv64-linux-gnu/asm/unistd.h
|
|
||||||
// Code generated by the command above; DO NOT EDIT.
|
|
||||||
|
|
||||||
package std
|
|
||||||
|
|
||||||
import . "syscall"
|
|
||||||
|
|
||||||
var syscallNum = map[string]ScmpSyscall{
|
|
||||||
"io_setup": SNR_IO_SETUP,
|
|
||||||
"io_destroy": SNR_IO_DESTROY,
|
|
||||||
"io_submit": SNR_IO_SUBMIT,
|
|
||||||
"io_cancel": SNR_IO_CANCEL,
|
|
||||||
"io_getevents": SNR_IO_GETEVENTS,
|
|
||||||
"setxattr": SNR_SETXATTR,
|
|
||||||
"lsetxattr": SNR_LSETXATTR,
|
|
||||||
"fsetxattr": SNR_FSETXATTR,
|
|
||||||
"getxattr": SNR_GETXATTR,
|
|
||||||
"lgetxattr": SNR_LGETXATTR,
|
|
||||||
"fgetxattr": SNR_FGETXATTR,
|
|
||||||
"listxattr": SNR_LISTXATTR,
|
|
||||||
"llistxattr": SNR_LLISTXATTR,
|
|
||||||
"flistxattr": SNR_FLISTXATTR,
|
|
||||||
"removexattr": SNR_REMOVEXATTR,
|
|
||||||
"lremovexattr": SNR_LREMOVEXATTR,
|
|
||||||
"fremovexattr": SNR_FREMOVEXATTR,
|
|
||||||
"getcwd": SNR_GETCWD,
|
|
||||||
"lookup_dcookie": SNR_LOOKUP_DCOOKIE,
|
|
||||||
"eventfd2": SNR_EVENTFD2,
|
|
||||||
"epoll_create1": SNR_EPOLL_CREATE1,
|
|
||||||
"epoll_ctl": SNR_EPOLL_CTL,
|
|
||||||
"epoll_pwait": SNR_EPOLL_PWAIT,
|
|
||||||
"dup": SNR_DUP,
|
|
||||||
"dup3": SNR_DUP3,
|
|
||||||
"fcntl": SNR_FCNTL,
|
|
||||||
"inotify_init1": SNR_INOTIFY_INIT1,
|
|
||||||
"inotify_add_watch": SNR_INOTIFY_ADD_WATCH,
|
|
||||||
"inotify_rm_watch": SNR_INOTIFY_RM_WATCH,
|
|
||||||
"ioctl": SNR_IOCTL,
|
|
||||||
"ioprio_set": SNR_IOPRIO_SET,
|
|
||||||
"ioprio_get": SNR_IOPRIO_GET,
|
|
||||||
"flock": SNR_FLOCK,
|
|
||||||
"mknodat": SNR_MKNODAT,
|
|
||||||
"mkdirat": SNR_MKDIRAT,
|
|
||||||
"unlinkat": SNR_UNLINKAT,
|
|
||||||
"symlinkat": SNR_SYMLINKAT,
|
|
||||||
"linkat": SNR_LINKAT,
|
|
||||||
"umount2": SNR_UMOUNT2,
|
|
||||||
"mount": SNR_MOUNT,
|
|
||||||
"pivot_root": SNR_PIVOT_ROOT,
|
|
||||||
"nfsservctl": SNR_NFSSERVCTL,
|
|
||||||
"statfs": SNR_STATFS,
|
|
||||||
"fstatfs": SNR_FSTATFS,
|
|
||||||
"truncate": SNR_TRUNCATE,
|
|
||||||
"ftruncate": SNR_FTRUNCATE,
|
|
||||||
"fallocate": SNR_FALLOCATE,
|
|
||||||
"faccessat": SNR_FACCESSAT,
|
|
||||||
"chdir": SNR_CHDIR,
|
|
||||||
"fchdir": SNR_FCHDIR,
|
|
||||||
"chroot": SNR_CHROOT,
|
|
||||||
"fchmod": SNR_FCHMOD,
|
|
||||||
"fchmodat": SNR_FCHMODAT,
|
|
||||||
"fchownat": SNR_FCHOWNAT,
|
|
||||||
"fchown": SNR_FCHOWN,
|
|
||||||
"openat": SNR_OPENAT,
|
|
||||||
"close": SNR_CLOSE,
|
|
||||||
"vhangup": SNR_VHANGUP,
|
|
||||||
"pipe2": SNR_PIPE2,
|
|
||||||
"quotactl": SNR_QUOTACTL,
|
|
||||||
"getdents64": SNR_GETDENTS64,
|
|
||||||
"lseek": SNR_LSEEK,
|
|
||||||
"read": SNR_READ,
|
|
||||||
"write": SNR_WRITE,
|
|
||||||
"readv": SNR_READV,
|
|
||||||
"writev": SNR_WRITEV,
|
|
||||||
"pread64": SNR_PREAD64,
|
|
||||||
"pwrite64": SNR_PWRITE64,
|
|
||||||
"preadv": SNR_PREADV,
|
|
||||||
"pwritev": SNR_PWRITEV,
|
|
||||||
"sendfile": SNR_SENDFILE,
|
|
||||||
"pselect6": SNR_PSELECT6,
|
|
||||||
"ppoll": SNR_PPOLL,
|
|
||||||
"signalfd4": SNR_SIGNALFD4,
|
|
||||||
"vmsplice": SNR_VMSPLICE,
|
|
||||||
"splice": SNR_SPLICE,
|
|
||||||
"tee": SNR_TEE,
|
|
||||||
"readlinkat": SNR_READLINKAT,
|
|
||||||
"newfstatat": SNR_NEWFSTATAT,
|
|
||||||
"fstat": SNR_FSTAT,
|
|
||||||
"sync": SNR_SYNC,
|
|
||||||
"fsync": SNR_FSYNC,
|
|
||||||
"fdatasync": SNR_FDATASYNC,
|
|
||||||
"sync_file_range": SNR_SYNC_FILE_RANGE,
|
|
||||||
"timerfd_create": SNR_TIMERFD_CREATE,
|
|
||||||
"timerfd_settime": SNR_TIMERFD_SETTIME,
|
|
||||||
"timerfd_gettime": SNR_TIMERFD_GETTIME,
|
|
||||||
"utimensat": SNR_UTIMENSAT,
|
|
||||||
"acct": SNR_ACCT,
|
|
||||||
"capget": SNR_CAPGET,
|
|
||||||
"capset": SNR_CAPSET,
|
|
||||||
"personality": SNR_PERSONALITY,
|
|
||||||
"exit": SNR_EXIT,
|
|
||||||
"exit_group": SNR_EXIT_GROUP,
|
|
||||||
"waitid": SNR_WAITID,
|
|
||||||
"set_tid_address": SNR_SET_TID_ADDRESS,
|
|
||||||
"unshare": SNR_UNSHARE,
|
|
||||||
"futex": SNR_FUTEX,
|
|
||||||
"set_robust_list": SNR_SET_ROBUST_LIST,
|
|
||||||
"get_robust_list": SNR_GET_ROBUST_LIST,
|
|
||||||
"nanosleep": SNR_NANOSLEEP,
|
|
||||||
"getitimer": SNR_GETITIMER,
|
|
||||||
"setitimer": SNR_SETITIMER,
|
|
||||||
"kexec_load": SNR_KEXEC_LOAD,
|
|
||||||
"init_module": SNR_INIT_MODULE,
|
|
||||||
"delete_module": SNR_DELETE_MODULE,
|
|
||||||
"timer_create": SNR_TIMER_CREATE,
|
|
||||||
"timer_gettime": SNR_TIMER_GETTIME,
|
|
||||||
"timer_getoverrun": SNR_TIMER_GETOVERRUN,
|
|
||||||
"timer_settime": SNR_TIMER_SETTIME,
|
|
||||||
"timer_delete": SNR_TIMER_DELETE,
|
|
||||||
"clock_settime": SNR_CLOCK_SETTIME,
|
|
||||||
"clock_gettime": SNR_CLOCK_GETTIME,
|
|
||||||
"clock_getres": SNR_CLOCK_GETRES,
|
|
||||||
"clock_nanosleep": SNR_CLOCK_NANOSLEEP,
|
|
||||||
"syslog": SNR_SYSLOG,
|
|
||||||
"ptrace": SNR_PTRACE,
|
|
||||||
"sched_setparam": SNR_SCHED_SETPARAM,
|
|
||||||
"sched_setscheduler": SNR_SCHED_SETSCHEDULER,
|
|
||||||
"sched_getscheduler": SNR_SCHED_GETSCHEDULER,
|
|
||||||
"sched_getparam": SNR_SCHED_GETPARAM,
|
|
||||||
"sched_setaffinity": SNR_SCHED_SETAFFINITY,
|
|
||||||
"sched_getaffinity": SNR_SCHED_GETAFFINITY,
|
|
||||||
"sched_yield": SNR_SCHED_YIELD,
|
|
||||||
"sched_get_priority_max": SNR_SCHED_GET_PRIORITY_MAX,
|
|
||||||
"sched_get_priority_min": SNR_SCHED_GET_PRIORITY_MIN,
|
|
||||||
"sched_rr_get_interval": SNR_SCHED_RR_GET_INTERVAL,
|
|
||||||
"restart_syscall": SNR_RESTART_SYSCALL,
|
|
||||||
"kill": SNR_KILL,
|
|
||||||
"tkill": SNR_TKILL,
|
|
||||||
"tgkill": SNR_TGKILL,
|
|
||||||
"sigaltstack": SNR_SIGALTSTACK,
|
|
||||||
"rt_sigsuspend": SNR_RT_SIGSUSPEND,
|
|
||||||
"rt_sigaction": SNR_RT_SIGACTION,
|
|
||||||
"rt_sigprocmask": SNR_RT_SIGPROCMASK,
|
|
||||||
"rt_sigpending": SNR_RT_SIGPENDING,
|
|
||||||
"rt_sigtimedwait": SNR_RT_SIGTIMEDWAIT,
|
|
||||||
"rt_sigqueueinfo": SNR_RT_SIGQUEUEINFO,
|
|
||||||
"rt_sigreturn": SNR_RT_SIGRETURN,
|
|
||||||
"setpriority": SNR_SETPRIORITY,
|
|
||||||
"getpriority": SNR_GETPRIORITY,
|
|
||||||
"reboot": SNR_REBOOT,
|
|
||||||
"setregid": SNR_SETREGID,
|
|
||||||
"setgid": SNR_SETGID,
|
|
||||||
"setreuid": SNR_SETREUID,
|
|
||||||
"setuid": SNR_SETUID,
|
|
||||||
"setresuid": SNR_SETRESUID,
|
|
||||||
"getresuid": SNR_GETRESUID,
|
|
||||||
"setresgid": SNR_SETRESGID,
|
|
||||||
"getresgid": SNR_GETRESGID,
|
|
||||||
"setfsuid": SNR_SETFSUID,
|
|
||||||
"setfsgid": SNR_SETFSGID,
|
|
||||||
"times": SNR_TIMES,
|
|
||||||
"setpgid": SNR_SETPGID,
|
|
||||||
"getpgid": SNR_GETPGID,
|
|
||||||
"getsid": SNR_GETSID,
|
|
||||||
"setsid": SNR_SETSID,
|
|
||||||
"getgroups": SNR_GETGROUPS,
|
|
||||||
"setgroups": SNR_SETGROUPS,
|
|
||||||
"uname": SNR_UNAME,
|
|
||||||
"sethostname": SNR_SETHOSTNAME,
|
|
||||||
"setdomainname": SNR_SETDOMAINNAME,
|
|
||||||
"getrlimit": SNR_GETRLIMIT,
|
|
||||||
"setrlimit": SNR_SETRLIMIT,
|
|
||||||
"getrusage": SNR_GETRUSAGE,
|
|
||||||
"umask": SNR_UMASK,
|
|
||||||
"prctl": SNR_PRCTL,
|
|
||||||
"getcpu": SNR_GETCPU,
|
|
||||||
"gettimeofday": SNR_GETTIMEOFDAY,
|
|
||||||
"settimeofday": SNR_SETTIMEOFDAY,
|
|
||||||
"adjtimex": SNR_ADJTIMEX,
|
|
||||||
"getpid": SNR_GETPID,
|
|
||||||
"getppid": SNR_GETPPID,
|
|
||||||
"getuid": SNR_GETUID,
|
|
||||||
"geteuid": SNR_GETEUID,
|
|
||||||
"getgid": SNR_GETGID,
|
|
||||||
"getegid": SNR_GETEGID,
|
|
||||||
"gettid": SNR_GETTID,
|
|
||||||
"sysinfo": SNR_SYSINFO,
|
|
||||||
"mq_open": SNR_MQ_OPEN,
|
|
||||||
"mq_unlink": SNR_MQ_UNLINK,
|
|
||||||
"mq_timedsend": SNR_MQ_TIMEDSEND,
|
|
||||||
"mq_timedreceive": SNR_MQ_TIMEDRECEIVE,
|
|
||||||
"mq_notify": SNR_MQ_NOTIFY,
|
|
||||||
"mq_getsetattr": SNR_MQ_GETSETATTR,
|
|
||||||
"msgget": SNR_MSGGET,
|
|
||||||
"msgctl": SNR_MSGCTL,
|
|
||||||
"msgrcv": SNR_MSGRCV,
|
|
||||||
"msgsnd": SNR_MSGSND,
|
|
||||||
"semget": SNR_SEMGET,
|
|
||||||
"semctl": SNR_SEMCTL,
|
|
||||||
"semtimedop": SNR_SEMTIMEDOP,
|
|
||||||
"semop": SNR_SEMOP,
|
|
||||||
"shmget": SNR_SHMGET,
|
|
||||||
"shmctl": SNR_SHMCTL,
|
|
||||||
"shmat": SNR_SHMAT,
|
|
||||||
"shmdt": SNR_SHMDT,
|
|
||||||
"socket": SNR_SOCKET,
|
|
||||||
"socketpair": SNR_SOCKETPAIR,
|
|
||||||
"bind": SNR_BIND,
|
|
||||||
"listen": SNR_LISTEN,
|
|
||||||
"accept": SNR_ACCEPT,
|
|
||||||
"connect": SNR_CONNECT,
|
|
||||||
"getsockname": SNR_GETSOCKNAME,
|
|
||||||
"getpeername": SNR_GETPEERNAME,
|
|
||||||
"sendto": SNR_SENDTO,
|
|
||||||
"recvfrom": SNR_RECVFROM,
|
|
||||||
"setsockopt": SNR_SETSOCKOPT,
|
|
||||||
"getsockopt": SNR_GETSOCKOPT,
|
|
||||||
"shutdown": SNR_SHUTDOWN,
|
|
||||||
"sendmsg": SNR_SENDMSG,
|
|
||||||
"recvmsg": SNR_RECVMSG,
|
|
||||||
"readahead": SNR_READAHEAD,
|
|
||||||
"brk": SNR_BRK,
|
|
||||||
"munmap": SNR_MUNMAP,
|
|
||||||
"mremap": SNR_MREMAP,
|
|
||||||
"add_key": SNR_ADD_KEY,
|
|
||||||
"request_key": SNR_REQUEST_KEY,
|
|
||||||
"keyctl": SNR_KEYCTL,
|
|
||||||
"clone": SNR_CLONE,
|
|
||||||
"execve": SNR_EXECVE,
|
|
||||||
"mmap": SNR_MMAP,
|
|
||||||
"fadvise64": SNR_FADVISE64,
|
|
||||||
"swapon": SNR_SWAPON,
|
|
||||||
"swapoff": SNR_SWAPOFF,
|
|
||||||
"mprotect": SNR_MPROTECT,
|
|
||||||
"msync": SNR_MSYNC,
|
|
||||||
"mlock": SNR_MLOCK,
|
|
||||||
"munlock": SNR_MUNLOCK,
|
|
||||||
"mlockall": SNR_MLOCKALL,
|
|
||||||
"munlockall": SNR_MUNLOCKALL,
|
|
||||||
"mincore": SNR_MINCORE,
|
|
||||||
"madvise": SNR_MADVISE,
|
|
||||||
"remap_file_pages": SNR_REMAP_FILE_PAGES,
|
|
||||||
"mbind": SNR_MBIND,
|
|
||||||
"get_mempolicy": SNR_GET_MEMPOLICY,
|
|
||||||
"set_mempolicy": SNR_SET_MEMPOLICY,
|
|
||||||
"migrate_pages": SNR_MIGRATE_PAGES,
|
|
||||||
"move_pages": SNR_MOVE_PAGES,
|
|
||||||
"rt_tgsigqueueinfo": SNR_RT_TGSIGQUEUEINFO,
|
|
||||||
"perf_event_open": SNR_PERF_EVENT_OPEN,
|
|
||||||
"accept4": SNR_ACCEPT4,
|
|
||||||
"recvmmsg": SNR_RECVMMSG,
|
|
||||||
"wait4": SNR_WAIT4,
|
|
||||||
"prlimit64": SNR_PRLIMIT64,
|
|
||||||
"fanotify_init": SNR_FANOTIFY_INIT,
|
|
||||||
"fanotify_mark": SNR_FANOTIFY_MARK,
|
|
||||||
"name_to_handle_at": SNR_NAME_TO_HANDLE_AT,
|
|
||||||
"open_by_handle_at": SNR_OPEN_BY_HANDLE_AT,
|
|
||||||
"clock_adjtime": SNR_CLOCK_ADJTIME,
|
|
||||||
"syncfs": SNR_SYNCFS,
|
|
||||||
"setns": SNR_SETNS,
|
|
||||||
"sendmmsg": SNR_SENDMMSG,
|
|
||||||
"process_vm_readv": SNR_PROCESS_VM_READV,
|
|
||||||
"process_vm_writev": SNR_PROCESS_VM_WRITEV,
|
|
||||||
"kcmp": SNR_KCMP,
|
|
||||||
"finit_module": SNR_FINIT_MODULE,
|
|
||||||
"sched_setattr": SNR_SCHED_SETATTR,
|
|
||||||
"sched_getattr": SNR_SCHED_GETATTR,
|
|
||||||
"renameat2": SNR_RENAMEAT2,
|
|
||||||
"seccomp": SNR_SECCOMP,
|
|
||||||
"getrandom": SNR_GETRANDOM,
|
|
||||||
"memfd_create": SNR_MEMFD_CREATE,
|
|
||||||
"bpf": SNR_BPF,
|
|
||||||
"execveat": SNR_EXECVEAT,
|
|
||||||
"userfaultfd": SNR_USERFAULTFD,
|
|
||||||
"membarrier": SNR_MEMBARRIER,
|
|
||||||
"mlock2": SNR_MLOCK2,
|
|
||||||
"copy_file_range": SNR_COPY_FILE_RANGE,
|
|
||||||
"preadv2": SNR_PREADV2,
|
|
||||||
"pwritev2": SNR_PWRITEV2,
|
|
||||||
"pkey_mprotect": SNR_PKEY_MPROTECT,
|
|
||||||
"pkey_alloc": SNR_PKEY_ALLOC,
|
|
||||||
"pkey_free": SNR_PKEY_FREE,
|
|
||||||
"statx": SNR_STATX,
|
|
||||||
"io_pgetevents": SNR_IO_PGETEVENTS,
|
|
||||||
"rseq": SNR_RSEQ,
|
|
||||||
"kexec_file_load": SNR_KEXEC_FILE_LOAD,
|
|
||||||
"pidfd_send_signal": SNR_PIDFD_SEND_SIGNAL,
|
|
||||||
"io_uring_setup": SNR_IO_URING_SETUP,
|
|
||||||
"io_uring_enter": SNR_IO_URING_ENTER,
|
|
||||||
"io_uring_register": SNR_IO_URING_REGISTER,
|
|
||||||
"open_tree": SNR_OPEN_TREE,
|
|
||||||
"move_mount": SNR_MOVE_MOUNT,
|
|
||||||
"fsopen": SNR_FSOPEN,
|
|
||||||
"fsconfig": SNR_FSCONFIG,
|
|
||||||
"fsmount": SNR_FSMOUNT,
|
|
||||||
"fspick": SNR_FSPICK,
|
|
||||||
"pidfd_open": SNR_PIDFD_OPEN,
|
|
||||||
"clone3": SNR_CLONE3,
|
|
||||||
"close_range": SNR_CLOSE_RANGE,
|
|
||||||
"openat2": SNR_OPENAT2,
|
|
||||||
"pidfd_getfd": SNR_PIDFD_GETFD,
|
|
||||||
"faccessat2": SNR_FACCESSAT2,
|
|
||||||
"process_madvise": SNR_PROCESS_MADVISE,
|
|
||||||
"epoll_pwait2": SNR_EPOLL_PWAIT2,
|
|
||||||
"mount_setattr": SNR_MOUNT_SETATTR,
|
|
||||||
"quotactl_fd": SNR_QUOTACTL_FD,
|
|
||||||
"landlock_create_ruleset": SNR_LANDLOCK_CREATE_RULESET,
|
|
||||||
"landlock_add_rule": SNR_LANDLOCK_ADD_RULE,
|
|
||||||
"landlock_restrict_self": SNR_LANDLOCK_RESTRICT_SELF,
|
|
||||||
"memfd_secret": SNR_MEMFD_SECRET,
|
|
||||||
"process_mrelease": SNR_PROCESS_MRELEASE,
|
|
||||||
"futex_waitv": SNR_FUTEX_WAITV,
|
|
||||||
"set_mempolicy_home_node": SNR_SET_MEMPOLICY_HOME_NODE,
|
|
||||||
"cachestat": SNR_CACHESTAT,
|
|
||||||
"fchmodat2": SNR_FCHMODAT2,
|
|
||||||
"map_shadow_stack": SNR_MAP_SHADOW_STACK,
|
|
||||||
"futex_wake": SNR_FUTEX_WAKE,
|
|
||||||
"futex_wait": SNR_FUTEX_WAIT,
|
|
||||||
"futex_requeue": SNR_FUTEX_REQUEUE,
|
|
||||||
"statmount": SNR_STATMOUNT,
|
|
||||||
"listmount": SNR_LISTMOUNT,
|
|
||||||
"lsm_get_self_attr": SNR_LSM_GET_SELF_ATTR,
|
|
||||||
"lsm_set_self_attr": SNR_LSM_SET_SELF_ATTR,
|
|
||||||
"lsm_list_modules": SNR_LSM_LIST_MODULES,
|
|
||||||
"mseal": SNR_MSEAL,
|
|
||||||
"setxattrat": SNR_SETXATTRAT,
|
|
||||||
"getxattrat": SNR_GETXATTRAT,
|
|
||||||
"listxattrat": SNR_LISTXATTRAT,
|
|
||||||
"removexattrat": SNR_REMOVEXATTRAT,
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_USERFAULTFD = 282
|
|
||||||
SYS_MEMBARRIER = 283
|
|
||||||
SYS_MLOCK2 = 284
|
|
||||||
SYS_COPY_FILE_RANGE = 285
|
|
||||||
SYS_PREADV2 = 286
|
|
||||||
SYS_PWRITEV2 = 287
|
|
||||||
SYS_PKEY_MPROTECT = 288
|
|
||||||
SYS_PKEY_ALLOC = 289
|
|
||||||
SYS_PKEY_FREE = 290
|
|
||||||
SYS_STATX = 291
|
|
||||||
SYS_IO_PGETEVENTS = 292
|
|
||||||
SYS_RSEQ = 293
|
|
||||||
SYS_KEXEC_FILE_LOAD = 294
|
|
||||||
SYS_PIDFD_SEND_SIGNAL = 424
|
|
||||||
SYS_IO_URING_SETUP = 425
|
|
||||||
SYS_IO_URING_ENTER = 426
|
|
||||||
SYS_IO_URING_REGISTER = 427
|
|
||||||
SYS_OPEN_TREE = 428
|
|
||||||
SYS_MOVE_MOUNT = 429
|
|
||||||
SYS_FSOPEN = 430
|
|
||||||
SYS_FSCONFIG = 431
|
|
||||||
SYS_FSMOUNT = 432
|
|
||||||
SYS_FSPICK = 433
|
|
||||||
SYS_PIDFD_OPEN = 434
|
|
||||||
SYS_CLONE3 = 435
|
|
||||||
SYS_CLOSE_RANGE = 436
|
|
||||||
SYS_OPENAT2 = 437
|
|
||||||
SYS_PIDFD_GETFD = 438
|
|
||||||
SYS_FACCESSAT2 = 439
|
|
||||||
SYS_PROCESS_MADVISE = 440
|
|
||||||
SYS_EPOLL_PWAIT2 = 441
|
|
||||||
SYS_MOUNT_SETATTR = 442
|
|
||||||
SYS_QUOTACTL_FD = 443
|
|
||||||
SYS_LANDLOCK_CREATE_RULESET = 444
|
|
||||||
SYS_LANDLOCK_ADD_RULE = 445
|
|
||||||
SYS_LANDLOCK_RESTRICT_SELF = 446
|
|
||||||
SYS_MEMFD_SECRET = 447
|
|
||||||
SYS_PROCESS_MRELEASE = 448
|
|
||||||
SYS_FUTEX_WAITV = 449
|
|
||||||
SYS_SET_MEMPOLICY_HOME_NODE = 450
|
|
||||||
SYS_CACHESTAT = 451
|
|
||||||
SYS_FCHMODAT2 = 452
|
|
||||||
SYS_MAP_SHADOW_STACK = 453
|
|
||||||
SYS_FUTEX_WAKE = 454
|
|
||||||
SYS_FUTEX_WAIT = 455
|
|
||||||
SYS_FUTEX_REQUEUE = 456
|
|
||||||
SYS_STATMOUNT = 457
|
|
||||||
SYS_LISTMOUNT = 458
|
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
|
||||||
SYS_LSM_LIST_MODULES = 461
|
|
||||||
SYS_MSEAL = 462
|
|
||||||
SYS_SETXATTRAT = 463
|
|
||||||
SYS_GETXATTRAT = 464
|
|
||||||
SYS_LISTXATTRAT = 465
|
|
||||||
SYS_REMOVEXATTRAT = 466
|
|
||||||
SYS_OPEN_TREE_ATTR = 467
|
|
||||||
SYS_FILE_GETATTR = 468
|
|
||||||
SYS_FILE_SETATTR = 469
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SNR_IO_SETUP ScmpSyscall = SYS_IO_SETUP
|
|
||||||
SNR_IO_DESTROY ScmpSyscall = SYS_IO_DESTROY
|
|
||||||
SNR_IO_SUBMIT ScmpSyscall = SYS_IO_SUBMIT
|
|
||||||
SNR_IO_CANCEL ScmpSyscall = SYS_IO_CANCEL
|
|
||||||
SNR_IO_GETEVENTS ScmpSyscall = SYS_IO_GETEVENTS
|
|
||||||
SNR_SETXATTR ScmpSyscall = SYS_SETXATTR
|
|
||||||
SNR_LSETXATTR ScmpSyscall = SYS_LSETXATTR
|
|
||||||
SNR_FSETXATTR ScmpSyscall = SYS_FSETXATTR
|
|
||||||
SNR_GETXATTR ScmpSyscall = SYS_GETXATTR
|
|
||||||
SNR_LGETXATTR ScmpSyscall = SYS_LGETXATTR
|
|
||||||
SNR_FGETXATTR ScmpSyscall = SYS_FGETXATTR
|
|
||||||
SNR_LISTXATTR ScmpSyscall = SYS_LISTXATTR
|
|
||||||
SNR_LLISTXATTR ScmpSyscall = SYS_LLISTXATTR
|
|
||||||
SNR_FLISTXATTR ScmpSyscall = SYS_FLISTXATTR
|
|
||||||
SNR_REMOVEXATTR ScmpSyscall = SYS_REMOVEXATTR
|
|
||||||
SNR_LREMOVEXATTR ScmpSyscall = SYS_LREMOVEXATTR
|
|
||||||
SNR_FREMOVEXATTR ScmpSyscall = SYS_FREMOVEXATTR
|
|
||||||
SNR_GETCWD ScmpSyscall = SYS_GETCWD
|
|
||||||
SNR_LOOKUP_DCOOKIE ScmpSyscall = SYS_LOOKUP_DCOOKIE
|
|
||||||
SNR_EVENTFD2 ScmpSyscall = SYS_EVENTFD2
|
|
||||||
SNR_EPOLL_CREATE1 ScmpSyscall = SYS_EPOLL_CREATE1
|
|
||||||
SNR_EPOLL_CTL ScmpSyscall = SYS_EPOLL_CTL
|
|
||||||
SNR_EPOLL_PWAIT ScmpSyscall = SYS_EPOLL_PWAIT
|
|
||||||
SNR_DUP ScmpSyscall = SYS_DUP
|
|
||||||
SNR_DUP3 ScmpSyscall = SYS_DUP3
|
|
||||||
SNR_FCNTL ScmpSyscall = SYS_FCNTL
|
|
||||||
SNR_INOTIFY_INIT1 ScmpSyscall = SYS_INOTIFY_INIT1
|
|
||||||
SNR_INOTIFY_ADD_WATCH ScmpSyscall = SYS_INOTIFY_ADD_WATCH
|
|
||||||
SNR_INOTIFY_RM_WATCH ScmpSyscall = SYS_INOTIFY_RM_WATCH
|
|
||||||
SNR_IOCTL ScmpSyscall = SYS_IOCTL
|
|
||||||
SNR_IOPRIO_SET ScmpSyscall = SYS_IOPRIO_SET
|
|
||||||
SNR_IOPRIO_GET ScmpSyscall = SYS_IOPRIO_GET
|
|
||||||
SNR_FLOCK ScmpSyscall = SYS_FLOCK
|
|
||||||
SNR_MKNODAT ScmpSyscall = SYS_MKNODAT
|
|
||||||
SNR_MKDIRAT ScmpSyscall = SYS_MKDIRAT
|
|
||||||
SNR_UNLINKAT ScmpSyscall = SYS_UNLINKAT
|
|
||||||
SNR_SYMLINKAT ScmpSyscall = SYS_SYMLINKAT
|
|
||||||
SNR_LINKAT ScmpSyscall = SYS_LINKAT
|
|
||||||
SNR_UMOUNT2 ScmpSyscall = SYS_UMOUNT2
|
|
||||||
SNR_MOUNT ScmpSyscall = SYS_MOUNT
|
|
||||||
SNR_PIVOT_ROOT ScmpSyscall = SYS_PIVOT_ROOT
|
|
||||||
SNR_NFSSERVCTL ScmpSyscall = SYS_NFSSERVCTL
|
|
||||||
SNR_STATFS ScmpSyscall = SYS_STATFS
|
|
||||||
SNR_FSTATFS ScmpSyscall = SYS_FSTATFS
|
|
||||||
SNR_TRUNCATE ScmpSyscall = SYS_TRUNCATE
|
|
||||||
SNR_FTRUNCATE ScmpSyscall = SYS_FTRUNCATE
|
|
||||||
SNR_FALLOCATE ScmpSyscall = SYS_FALLOCATE
|
|
||||||
SNR_FACCESSAT ScmpSyscall = SYS_FACCESSAT
|
|
||||||
SNR_CHDIR ScmpSyscall = SYS_CHDIR
|
|
||||||
SNR_FCHDIR ScmpSyscall = SYS_FCHDIR
|
|
||||||
SNR_CHROOT ScmpSyscall = SYS_CHROOT
|
|
||||||
SNR_FCHMOD ScmpSyscall = SYS_FCHMOD
|
|
||||||
SNR_FCHMODAT ScmpSyscall = SYS_FCHMODAT
|
|
||||||
SNR_FCHOWNAT ScmpSyscall = SYS_FCHOWNAT
|
|
||||||
SNR_FCHOWN ScmpSyscall = SYS_FCHOWN
|
|
||||||
SNR_OPENAT ScmpSyscall = SYS_OPENAT
|
|
||||||
SNR_CLOSE ScmpSyscall = SYS_CLOSE
|
|
||||||
SNR_VHANGUP ScmpSyscall = SYS_VHANGUP
|
|
||||||
SNR_PIPE2 ScmpSyscall = SYS_PIPE2
|
|
||||||
SNR_QUOTACTL ScmpSyscall = SYS_QUOTACTL
|
|
||||||
SNR_GETDENTS64 ScmpSyscall = SYS_GETDENTS64
|
|
||||||
SNR_LSEEK ScmpSyscall = SYS_LSEEK
|
|
||||||
SNR_READ ScmpSyscall = SYS_READ
|
|
||||||
SNR_WRITE ScmpSyscall = SYS_WRITE
|
|
||||||
SNR_READV ScmpSyscall = SYS_READV
|
|
||||||
SNR_WRITEV ScmpSyscall = SYS_WRITEV
|
|
||||||
SNR_PREAD64 ScmpSyscall = SYS_PREAD64
|
|
||||||
SNR_PWRITE64 ScmpSyscall = SYS_PWRITE64
|
|
||||||
SNR_PREADV ScmpSyscall = SYS_PREADV
|
|
||||||
SNR_PWRITEV ScmpSyscall = SYS_PWRITEV
|
|
||||||
SNR_SENDFILE ScmpSyscall = SYS_SENDFILE
|
|
||||||
SNR_PSELECT6 ScmpSyscall = SYS_PSELECT6
|
|
||||||
SNR_PPOLL ScmpSyscall = SYS_PPOLL
|
|
||||||
SNR_SIGNALFD4 ScmpSyscall = SYS_SIGNALFD4
|
|
||||||
SNR_VMSPLICE ScmpSyscall = SYS_VMSPLICE
|
|
||||||
SNR_SPLICE ScmpSyscall = SYS_SPLICE
|
|
||||||
SNR_TEE ScmpSyscall = SYS_TEE
|
|
||||||
SNR_READLINKAT ScmpSyscall = SYS_READLINKAT
|
|
||||||
SNR_NEWFSTATAT ScmpSyscall = SYS_NEWFSTATAT
|
|
||||||
SNR_FSTAT ScmpSyscall = SYS_FSTAT
|
|
||||||
SNR_SYNC ScmpSyscall = SYS_SYNC
|
|
||||||
SNR_FSYNC ScmpSyscall = SYS_FSYNC
|
|
||||||
SNR_FDATASYNC ScmpSyscall = SYS_FDATASYNC
|
|
||||||
SNR_SYNC_FILE_RANGE ScmpSyscall = SYS_SYNC_FILE_RANGE
|
|
||||||
SNR_TIMERFD_CREATE ScmpSyscall = SYS_TIMERFD_CREATE
|
|
||||||
SNR_TIMERFD_SETTIME ScmpSyscall = SYS_TIMERFD_SETTIME
|
|
||||||
SNR_TIMERFD_GETTIME ScmpSyscall = SYS_TIMERFD_GETTIME
|
|
||||||
SNR_UTIMENSAT ScmpSyscall = SYS_UTIMENSAT
|
|
||||||
SNR_ACCT ScmpSyscall = SYS_ACCT
|
|
||||||
SNR_CAPGET ScmpSyscall = SYS_CAPGET
|
|
||||||
SNR_CAPSET ScmpSyscall = SYS_CAPSET
|
|
||||||
SNR_PERSONALITY ScmpSyscall = SYS_PERSONALITY
|
|
||||||
SNR_EXIT ScmpSyscall = SYS_EXIT
|
|
||||||
SNR_EXIT_GROUP ScmpSyscall = SYS_EXIT_GROUP
|
|
||||||
SNR_WAITID ScmpSyscall = SYS_WAITID
|
|
||||||
SNR_SET_TID_ADDRESS ScmpSyscall = SYS_SET_TID_ADDRESS
|
|
||||||
SNR_UNSHARE ScmpSyscall = SYS_UNSHARE
|
|
||||||
SNR_FUTEX ScmpSyscall = SYS_FUTEX
|
|
||||||
SNR_SET_ROBUST_LIST ScmpSyscall = SYS_SET_ROBUST_LIST
|
|
||||||
SNR_GET_ROBUST_LIST ScmpSyscall = SYS_GET_ROBUST_LIST
|
|
||||||
SNR_NANOSLEEP ScmpSyscall = SYS_NANOSLEEP
|
|
||||||
SNR_GETITIMER ScmpSyscall = SYS_GETITIMER
|
|
||||||
SNR_SETITIMER ScmpSyscall = SYS_SETITIMER
|
|
||||||
SNR_KEXEC_LOAD ScmpSyscall = SYS_KEXEC_LOAD
|
|
||||||
SNR_INIT_MODULE ScmpSyscall = SYS_INIT_MODULE
|
|
||||||
SNR_DELETE_MODULE ScmpSyscall = SYS_DELETE_MODULE
|
|
||||||
SNR_TIMER_CREATE ScmpSyscall = SYS_TIMER_CREATE
|
|
||||||
SNR_TIMER_GETTIME ScmpSyscall = SYS_TIMER_GETTIME
|
|
||||||
SNR_TIMER_GETOVERRUN ScmpSyscall = SYS_TIMER_GETOVERRUN
|
|
||||||
SNR_TIMER_SETTIME ScmpSyscall = SYS_TIMER_SETTIME
|
|
||||||
SNR_TIMER_DELETE ScmpSyscall = SYS_TIMER_DELETE
|
|
||||||
SNR_CLOCK_SETTIME ScmpSyscall = SYS_CLOCK_SETTIME
|
|
||||||
SNR_CLOCK_GETTIME ScmpSyscall = SYS_CLOCK_GETTIME
|
|
||||||
SNR_CLOCK_GETRES ScmpSyscall = SYS_CLOCK_GETRES
|
|
||||||
SNR_CLOCK_NANOSLEEP ScmpSyscall = SYS_CLOCK_NANOSLEEP
|
|
||||||
SNR_SYSLOG ScmpSyscall = SYS_SYSLOG
|
|
||||||
SNR_PTRACE ScmpSyscall = SYS_PTRACE
|
|
||||||
SNR_SCHED_SETPARAM ScmpSyscall = SYS_SCHED_SETPARAM
|
|
||||||
SNR_SCHED_SETSCHEDULER ScmpSyscall = SYS_SCHED_SETSCHEDULER
|
|
||||||
SNR_SCHED_GETSCHEDULER ScmpSyscall = SYS_SCHED_GETSCHEDULER
|
|
||||||
SNR_SCHED_GETPARAM ScmpSyscall = SYS_SCHED_GETPARAM
|
|
||||||
SNR_SCHED_SETAFFINITY ScmpSyscall = SYS_SCHED_SETAFFINITY
|
|
||||||
SNR_SCHED_GETAFFINITY ScmpSyscall = SYS_SCHED_GETAFFINITY
|
|
||||||
SNR_SCHED_YIELD ScmpSyscall = SYS_SCHED_YIELD
|
|
||||||
SNR_SCHED_GET_PRIORITY_MAX ScmpSyscall = SYS_SCHED_GET_PRIORITY_MAX
|
|
||||||
SNR_SCHED_GET_PRIORITY_MIN ScmpSyscall = SYS_SCHED_GET_PRIORITY_MIN
|
|
||||||
SNR_SCHED_RR_GET_INTERVAL ScmpSyscall = SYS_SCHED_RR_GET_INTERVAL
|
|
||||||
SNR_RESTART_SYSCALL ScmpSyscall = SYS_RESTART_SYSCALL
|
|
||||||
SNR_KILL ScmpSyscall = SYS_KILL
|
|
||||||
SNR_TKILL ScmpSyscall = SYS_TKILL
|
|
||||||
SNR_TGKILL ScmpSyscall = SYS_TGKILL
|
|
||||||
SNR_SIGALTSTACK ScmpSyscall = SYS_SIGALTSTACK
|
|
||||||
SNR_RT_SIGSUSPEND ScmpSyscall = SYS_RT_SIGSUSPEND
|
|
||||||
SNR_RT_SIGACTION ScmpSyscall = SYS_RT_SIGACTION
|
|
||||||
SNR_RT_SIGPROCMASK ScmpSyscall = SYS_RT_SIGPROCMASK
|
|
||||||
SNR_RT_SIGPENDING ScmpSyscall = SYS_RT_SIGPENDING
|
|
||||||
SNR_RT_SIGTIMEDWAIT ScmpSyscall = SYS_RT_SIGTIMEDWAIT
|
|
||||||
SNR_RT_SIGQUEUEINFO ScmpSyscall = SYS_RT_SIGQUEUEINFO
|
|
||||||
SNR_RT_SIGRETURN ScmpSyscall = SYS_RT_SIGRETURN
|
|
||||||
SNR_SETPRIORITY ScmpSyscall = SYS_SETPRIORITY
|
|
||||||
SNR_GETPRIORITY ScmpSyscall = SYS_GETPRIORITY
|
|
||||||
SNR_REBOOT ScmpSyscall = SYS_REBOOT
|
|
||||||
SNR_SETREGID ScmpSyscall = SYS_SETREGID
|
|
||||||
SNR_SETGID ScmpSyscall = SYS_SETGID
|
|
||||||
SNR_SETREUID ScmpSyscall = SYS_SETREUID
|
|
||||||
SNR_SETUID ScmpSyscall = SYS_SETUID
|
|
||||||
SNR_SETRESUID ScmpSyscall = SYS_SETRESUID
|
|
||||||
SNR_GETRESUID ScmpSyscall = SYS_GETRESUID
|
|
||||||
SNR_SETRESGID ScmpSyscall = SYS_SETRESGID
|
|
||||||
SNR_GETRESGID ScmpSyscall = SYS_GETRESGID
|
|
||||||
SNR_SETFSUID ScmpSyscall = SYS_SETFSUID
|
|
||||||
SNR_SETFSGID ScmpSyscall = SYS_SETFSGID
|
|
||||||
SNR_TIMES ScmpSyscall = SYS_TIMES
|
|
||||||
SNR_SETPGID ScmpSyscall = SYS_SETPGID
|
|
||||||
SNR_GETPGID ScmpSyscall = SYS_GETPGID
|
|
||||||
SNR_GETSID ScmpSyscall = SYS_GETSID
|
|
||||||
SNR_SETSID ScmpSyscall = SYS_SETSID
|
|
||||||
SNR_GETGROUPS ScmpSyscall = SYS_GETGROUPS
|
|
||||||
SNR_SETGROUPS ScmpSyscall = SYS_SETGROUPS
|
|
||||||
SNR_UNAME ScmpSyscall = SYS_UNAME
|
|
||||||
SNR_SETHOSTNAME ScmpSyscall = SYS_SETHOSTNAME
|
|
||||||
SNR_SETDOMAINNAME ScmpSyscall = SYS_SETDOMAINNAME
|
|
||||||
SNR_GETRLIMIT ScmpSyscall = SYS_GETRLIMIT
|
|
||||||
SNR_SETRLIMIT ScmpSyscall = SYS_SETRLIMIT
|
|
||||||
SNR_GETRUSAGE ScmpSyscall = SYS_GETRUSAGE
|
|
||||||
SNR_UMASK ScmpSyscall = SYS_UMASK
|
|
||||||
SNR_PRCTL ScmpSyscall = SYS_PRCTL
|
|
||||||
SNR_GETCPU ScmpSyscall = SYS_GETCPU
|
|
||||||
SNR_GETTIMEOFDAY ScmpSyscall = SYS_GETTIMEOFDAY
|
|
||||||
SNR_SETTIMEOFDAY ScmpSyscall = SYS_SETTIMEOFDAY
|
|
||||||
SNR_ADJTIMEX ScmpSyscall = SYS_ADJTIMEX
|
|
||||||
SNR_GETPID ScmpSyscall = SYS_GETPID
|
|
||||||
SNR_GETPPID ScmpSyscall = SYS_GETPPID
|
|
||||||
SNR_GETUID ScmpSyscall = SYS_GETUID
|
|
||||||
SNR_GETEUID ScmpSyscall = SYS_GETEUID
|
|
||||||
SNR_GETGID ScmpSyscall = SYS_GETGID
|
|
||||||
SNR_GETEGID ScmpSyscall = SYS_GETEGID
|
|
||||||
SNR_GETTID ScmpSyscall = SYS_GETTID
|
|
||||||
SNR_SYSINFO ScmpSyscall = SYS_SYSINFO
|
|
||||||
SNR_MQ_OPEN ScmpSyscall = SYS_MQ_OPEN
|
|
||||||
SNR_MQ_UNLINK ScmpSyscall = SYS_MQ_UNLINK
|
|
||||||
SNR_MQ_TIMEDSEND ScmpSyscall = SYS_MQ_TIMEDSEND
|
|
||||||
SNR_MQ_TIMEDRECEIVE ScmpSyscall = SYS_MQ_TIMEDRECEIVE
|
|
||||||
SNR_MQ_NOTIFY ScmpSyscall = SYS_MQ_NOTIFY
|
|
||||||
SNR_MQ_GETSETATTR ScmpSyscall = SYS_MQ_GETSETATTR
|
|
||||||
SNR_MSGGET ScmpSyscall = SYS_MSGGET
|
|
||||||
SNR_MSGCTL ScmpSyscall = SYS_MSGCTL
|
|
||||||
SNR_MSGRCV ScmpSyscall = SYS_MSGRCV
|
|
||||||
SNR_MSGSND ScmpSyscall = SYS_MSGSND
|
|
||||||
SNR_SEMGET ScmpSyscall = SYS_SEMGET
|
|
||||||
SNR_SEMCTL ScmpSyscall = SYS_SEMCTL
|
|
||||||
SNR_SEMTIMEDOP ScmpSyscall = SYS_SEMTIMEDOP
|
|
||||||
SNR_SEMOP ScmpSyscall = SYS_SEMOP
|
|
||||||
SNR_SHMGET ScmpSyscall = SYS_SHMGET
|
|
||||||
SNR_SHMCTL ScmpSyscall = SYS_SHMCTL
|
|
||||||
SNR_SHMAT ScmpSyscall = SYS_SHMAT
|
|
||||||
SNR_SHMDT ScmpSyscall = SYS_SHMDT
|
|
||||||
SNR_SOCKET ScmpSyscall = SYS_SOCKET
|
|
||||||
SNR_SOCKETPAIR ScmpSyscall = SYS_SOCKETPAIR
|
|
||||||
SNR_BIND ScmpSyscall = SYS_BIND
|
|
||||||
SNR_LISTEN ScmpSyscall = SYS_LISTEN
|
|
||||||
SNR_ACCEPT ScmpSyscall = SYS_ACCEPT
|
|
||||||
SNR_CONNECT ScmpSyscall = SYS_CONNECT
|
|
||||||
SNR_GETSOCKNAME ScmpSyscall = SYS_GETSOCKNAME
|
|
||||||
SNR_GETPEERNAME ScmpSyscall = SYS_GETPEERNAME
|
|
||||||
SNR_SENDTO ScmpSyscall = SYS_SENDTO
|
|
||||||
SNR_RECVFROM ScmpSyscall = SYS_RECVFROM
|
|
||||||
SNR_SETSOCKOPT ScmpSyscall = SYS_SETSOCKOPT
|
|
||||||
SNR_GETSOCKOPT ScmpSyscall = SYS_GETSOCKOPT
|
|
||||||
SNR_SHUTDOWN ScmpSyscall = SYS_SHUTDOWN
|
|
||||||
SNR_SENDMSG ScmpSyscall = SYS_SENDMSG
|
|
||||||
SNR_RECVMSG ScmpSyscall = SYS_RECVMSG
|
|
||||||
SNR_READAHEAD ScmpSyscall = SYS_READAHEAD
|
|
||||||
SNR_BRK ScmpSyscall = SYS_BRK
|
|
||||||
SNR_MUNMAP ScmpSyscall = SYS_MUNMAP
|
|
||||||
SNR_MREMAP ScmpSyscall = SYS_MREMAP
|
|
||||||
SNR_ADD_KEY ScmpSyscall = SYS_ADD_KEY
|
|
||||||
SNR_REQUEST_KEY ScmpSyscall = SYS_REQUEST_KEY
|
|
||||||
SNR_KEYCTL ScmpSyscall = SYS_KEYCTL
|
|
||||||
SNR_CLONE ScmpSyscall = SYS_CLONE
|
|
||||||
SNR_EXECVE ScmpSyscall = SYS_EXECVE
|
|
||||||
SNR_MMAP ScmpSyscall = SYS_MMAP
|
|
||||||
SNR_FADVISE64 ScmpSyscall = SYS_FADVISE64
|
|
||||||
SNR_SWAPON ScmpSyscall = SYS_SWAPON
|
|
||||||
SNR_SWAPOFF ScmpSyscall = SYS_SWAPOFF
|
|
||||||
SNR_MPROTECT ScmpSyscall = SYS_MPROTECT
|
|
||||||
SNR_MSYNC ScmpSyscall = SYS_MSYNC
|
|
||||||
SNR_MLOCK ScmpSyscall = SYS_MLOCK
|
|
||||||
SNR_MUNLOCK ScmpSyscall = SYS_MUNLOCK
|
|
||||||
SNR_MLOCKALL ScmpSyscall = SYS_MLOCKALL
|
|
||||||
SNR_MUNLOCKALL ScmpSyscall = SYS_MUNLOCKALL
|
|
||||||
SNR_MINCORE ScmpSyscall = SYS_MINCORE
|
|
||||||
SNR_MADVISE ScmpSyscall = SYS_MADVISE
|
|
||||||
SNR_REMAP_FILE_PAGES ScmpSyscall = SYS_REMAP_FILE_PAGES
|
|
||||||
SNR_MBIND ScmpSyscall = SYS_MBIND
|
|
||||||
SNR_GET_MEMPOLICY ScmpSyscall = SYS_GET_MEMPOLICY
|
|
||||||
SNR_SET_MEMPOLICY ScmpSyscall = SYS_SET_MEMPOLICY
|
|
||||||
SNR_MIGRATE_PAGES ScmpSyscall = SYS_MIGRATE_PAGES
|
|
||||||
SNR_MOVE_PAGES ScmpSyscall = SYS_MOVE_PAGES
|
|
||||||
SNR_RT_TGSIGQUEUEINFO ScmpSyscall = SYS_RT_TGSIGQUEUEINFO
|
|
||||||
SNR_PERF_EVENT_OPEN ScmpSyscall = SYS_PERF_EVENT_OPEN
|
|
||||||
SNR_ACCEPT4 ScmpSyscall = SYS_ACCEPT4
|
|
||||||
SNR_RECVMMSG ScmpSyscall = SYS_RECVMMSG
|
|
||||||
SNR_WAIT4 ScmpSyscall = SYS_WAIT4
|
|
||||||
SNR_PRLIMIT64 ScmpSyscall = SYS_PRLIMIT64
|
|
||||||
SNR_FANOTIFY_INIT ScmpSyscall = SYS_FANOTIFY_INIT
|
|
||||||
SNR_FANOTIFY_MARK ScmpSyscall = SYS_FANOTIFY_MARK
|
|
||||||
SNR_NAME_TO_HANDLE_AT ScmpSyscall = SYS_NAME_TO_HANDLE_AT
|
|
||||||
SNR_OPEN_BY_HANDLE_AT ScmpSyscall = SYS_OPEN_BY_HANDLE_AT
|
|
||||||
SNR_CLOCK_ADJTIME ScmpSyscall = SYS_CLOCK_ADJTIME
|
|
||||||
SNR_SYNCFS ScmpSyscall = SYS_SYNCFS
|
|
||||||
SNR_SETNS ScmpSyscall = SYS_SETNS
|
|
||||||
SNR_SENDMMSG ScmpSyscall = SYS_SENDMMSG
|
|
||||||
SNR_PROCESS_VM_READV ScmpSyscall = SYS_PROCESS_VM_READV
|
|
||||||
SNR_PROCESS_VM_WRITEV ScmpSyscall = SYS_PROCESS_VM_WRITEV
|
|
||||||
SNR_KCMP ScmpSyscall = SYS_KCMP
|
|
||||||
SNR_FINIT_MODULE ScmpSyscall = SYS_FINIT_MODULE
|
|
||||||
SNR_SCHED_SETATTR ScmpSyscall = SYS_SCHED_SETATTR
|
|
||||||
SNR_SCHED_GETATTR ScmpSyscall = SYS_SCHED_GETATTR
|
|
||||||
SNR_RENAMEAT2 ScmpSyscall = SYS_RENAMEAT2
|
|
||||||
SNR_SECCOMP ScmpSyscall = SYS_SECCOMP
|
|
||||||
SNR_GETRANDOM ScmpSyscall = SYS_GETRANDOM
|
|
||||||
SNR_MEMFD_CREATE ScmpSyscall = SYS_MEMFD_CREATE
|
|
||||||
SNR_BPF ScmpSyscall = SYS_BPF
|
|
||||||
SNR_EXECVEAT ScmpSyscall = SYS_EXECVEAT
|
|
||||||
SNR_USERFAULTFD ScmpSyscall = SYS_USERFAULTFD
|
|
||||||
SNR_MEMBARRIER ScmpSyscall = SYS_MEMBARRIER
|
|
||||||
SNR_MLOCK2 ScmpSyscall = SYS_MLOCK2
|
|
||||||
SNR_COPY_FILE_RANGE ScmpSyscall = SYS_COPY_FILE_RANGE
|
|
||||||
SNR_PREADV2 ScmpSyscall = SYS_PREADV2
|
|
||||||
SNR_PWRITEV2 ScmpSyscall = SYS_PWRITEV2
|
|
||||||
SNR_PKEY_MPROTECT ScmpSyscall = SYS_PKEY_MPROTECT
|
|
||||||
SNR_PKEY_ALLOC ScmpSyscall = SYS_PKEY_ALLOC
|
|
||||||
SNR_PKEY_FREE ScmpSyscall = SYS_PKEY_FREE
|
|
||||||
SNR_STATX ScmpSyscall = SYS_STATX
|
|
||||||
SNR_IO_PGETEVENTS ScmpSyscall = SYS_IO_PGETEVENTS
|
|
||||||
SNR_RSEQ ScmpSyscall = SYS_RSEQ
|
|
||||||
SNR_KEXEC_FILE_LOAD ScmpSyscall = SYS_KEXEC_FILE_LOAD
|
|
||||||
SNR_PIDFD_SEND_SIGNAL ScmpSyscall = SYS_PIDFD_SEND_SIGNAL
|
|
||||||
SNR_IO_URING_SETUP ScmpSyscall = SYS_IO_URING_SETUP
|
|
||||||
SNR_IO_URING_ENTER ScmpSyscall = SYS_IO_URING_ENTER
|
|
||||||
SNR_IO_URING_REGISTER ScmpSyscall = SYS_IO_URING_REGISTER
|
|
||||||
SNR_OPEN_TREE ScmpSyscall = SYS_OPEN_TREE
|
|
||||||
SNR_MOVE_MOUNT ScmpSyscall = SYS_MOVE_MOUNT
|
|
||||||
SNR_FSOPEN ScmpSyscall = SYS_FSOPEN
|
|
||||||
SNR_FSCONFIG ScmpSyscall = SYS_FSCONFIG
|
|
||||||
SNR_FSMOUNT ScmpSyscall = SYS_FSMOUNT
|
|
||||||
SNR_FSPICK ScmpSyscall = SYS_FSPICK
|
|
||||||
SNR_PIDFD_OPEN ScmpSyscall = SYS_PIDFD_OPEN
|
|
||||||
SNR_CLONE3 ScmpSyscall = SYS_CLONE3
|
|
||||||
SNR_CLOSE_RANGE ScmpSyscall = SYS_CLOSE_RANGE
|
|
||||||
SNR_OPENAT2 ScmpSyscall = SYS_OPENAT2
|
|
||||||
SNR_PIDFD_GETFD ScmpSyscall = SYS_PIDFD_GETFD
|
|
||||||
SNR_FACCESSAT2 ScmpSyscall = SYS_FACCESSAT2
|
|
||||||
SNR_PROCESS_MADVISE ScmpSyscall = SYS_PROCESS_MADVISE
|
|
||||||
SNR_EPOLL_PWAIT2 ScmpSyscall = SYS_EPOLL_PWAIT2
|
|
||||||
SNR_MOUNT_SETATTR ScmpSyscall = SYS_MOUNT_SETATTR
|
|
||||||
SNR_QUOTACTL_FD ScmpSyscall = SYS_QUOTACTL_FD
|
|
||||||
SNR_LANDLOCK_CREATE_RULESET ScmpSyscall = SYS_LANDLOCK_CREATE_RULESET
|
|
||||||
SNR_LANDLOCK_ADD_RULE ScmpSyscall = SYS_LANDLOCK_ADD_RULE
|
|
||||||
SNR_LANDLOCK_RESTRICT_SELF ScmpSyscall = SYS_LANDLOCK_RESTRICT_SELF
|
|
||||||
SNR_MEMFD_SECRET ScmpSyscall = SYS_MEMFD_SECRET
|
|
||||||
SNR_PROCESS_MRELEASE ScmpSyscall = SYS_PROCESS_MRELEASE
|
|
||||||
SNR_FUTEX_WAITV ScmpSyscall = SYS_FUTEX_WAITV
|
|
||||||
SNR_SET_MEMPOLICY_HOME_NODE ScmpSyscall = SYS_SET_MEMPOLICY_HOME_NODE
|
|
||||||
SNR_CACHESTAT ScmpSyscall = SYS_CACHESTAT
|
|
||||||
SNR_FCHMODAT2 ScmpSyscall = SYS_FCHMODAT2
|
|
||||||
SNR_MAP_SHADOW_STACK ScmpSyscall = SYS_MAP_SHADOW_STACK
|
|
||||||
SNR_FUTEX_WAKE ScmpSyscall = SYS_FUTEX_WAKE
|
|
||||||
SNR_FUTEX_WAIT ScmpSyscall = SYS_FUTEX_WAIT
|
|
||||||
SNR_FUTEX_REQUEUE ScmpSyscall = SYS_FUTEX_REQUEUE
|
|
||||||
SNR_STATMOUNT ScmpSyscall = SYS_STATMOUNT
|
|
||||||
SNR_LISTMOUNT ScmpSyscall = SYS_LISTMOUNT
|
|
||||||
SNR_LSM_GET_SELF_ATTR ScmpSyscall = SYS_LSM_GET_SELF_ATTR
|
|
||||||
SNR_LSM_SET_SELF_ATTR ScmpSyscall = SYS_LSM_SET_SELF_ATTR
|
|
||||||
SNR_LSM_LIST_MODULES ScmpSyscall = SYS_LSM_LIST_MODULES
|
|
||||||
SNR_MSEAL ScmpSyscall = SYS_MSEAL
|
|
||||||
SNR_SETXATTRAT ScmpSyscall = SYS_SETXATTRAT
|
|
||||||
SNR_GETXATTRAT ScmpSyscall = SYS_GETXATTRAT
|
|
||||||
SNR_LISTXATTRAT ScmpSyscall = SYS_LISTXATTRAT
|
|
||||||
SNR_REMOVEXATTRAT ScmpSyscall = SYS_REMOVEXATTRAT
|
|
||||||
SNR_OPEN_TREE_ATTR ScmpSyscall = SYS_OPEN_TREE_ATTR
|
|
||||||
SNR_FILE_GETATTR ScmpSyscall = SYS_FILE_GETATTR
|
|
||||||
SNR_FILE_SETATTR ScmpSyscall = SYS_FILE_SETATTR
|
|
||||||
)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package std_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSyscallResolveName(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
for name, want := range std.Syscalls() {
|
|
||||||
t.Run(name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
if got, ok := std.SyscallResolveName(name); !ok || got != want {
|
|
||||||
t.Errorf("SyscallResolveName(%q) = %d, want %d", name, got, want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package std
|
|
||||||
|
|
||||||
type (
|
|
||||||
// Uint is equivalent to C.uint.
|
|
||||||
Uint uint32
|
|
||||||
// Int is equivalent to C.int.
|
|
||||||
Int int32
|
|
||||||
)
|
|
||||||
@@ -1,181 +1,21 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
. "syscall"
|
. "syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prctl manipulates various aspects of the behavior of the calling thread or process.
|
// setNoNewPrivs sets the calling thread's no_new_privs attribute.
|
||||||
func Prctl(op, arg2, arg3 uintptr) error {
|
func setNoNewPrivs() error {
|
||||||
r, _, errno := Syscall(SYS_PRCTL, op, arg2, arg3)
|
return ext.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0)
|
||||||
if r < 0 {
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPtracer allows processes to ptrace(2) the calling process.
|
|
||||||
func SetPtracer(pid uintptr) error { return Prctl(PR_SET_PTRACER, pid, 0) }
|
|
||||||
|
|
||||||
// linux/sched/coredump.h
|
|
||||||
const (
|
|
||||||
SUID_DUMP_DISABLE = iota
|
|
||||||
SUID_DUMP_USER
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetDumpable sets the "dumpable" attribute of the calling process.
|
|
||||||
func SetDumpable(dumpable uintptr) error { return Prctl(PR_SET_DUMPABLE, dumpable, 0) }
|
|
||||||
|
|
||||||
// SetNoNewPrivs sets the calling thread's no_new_privs attribute.
|
|
||||||
func SetNoNewPrivs() error { return Prctl(PR_SET_NO_NEW_PRIVS, 1, 0) }
|
|
||||||
|
|
||||||
// Isatty tests whether a file descriptor refers to a terminal.
|
|
||||||
func Isatty(fd int) bool {
|
|
||||||
var buf [8]byte
|
|
||||||
r, _, _ := Syscall(
|
|
||||||
SYS_IOCTL,
|
|
||||||
uintptr(fd),
|
|
||||||
TIOCGWINSZ,
|
|
||||||
uintptr(unsafe.Pointer(&buf[0])),
|
|
||||||
)
|
|
||||||
return r == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// SchedPolicy denotes a scheduling policy defined in include/uapi/linux/sched.h.
|
|
||||||
type SchedPolicy int
|
|
||||||
|
|
||||||
// include/uapi/linux/sched.h
|
|
||||||
const (
|
|
||||||
SCHED_NORMAL SchedPolicy = iota
|
|
||||||
SCHED_FIFO
|
|
||||||
SCHED_RR
|
|
||||||
SCHED_BATCH
|
|
||||||
_SCHED_ISO // SCHED_ISO: reserved but not implemented yet
|
|
||||||
SCHED_IDLE
|
|
||||||
SCHED_DEADLINE
|
|
||||||
SCHED_EXT
|
|
||||||
|
|
||||||
_SCHED_LAST SchedPolicy = iota - 1
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ encoding.TextMarshaler = _SCHED_LAST
|
|
||||||
var _ encoding.TextUnmarshaler = new(_SCHED_LAST)
|
|
||||||
|
|
||||||
// String returns a unique representation of policy, also used in encoding.
|
|
||||||
func (policy SchedPolicy) String() string {
|
|
||||||
switch policy {
|
|
||||||
case SCHED_NORMAL:
|
|
||||||
return ""
|
|
||||||
case SCHED_FIFO:
|
|
||||||
return "fifo"
|
|
||||||
case SCHED_RR:
|
|
||||||
return "rr"
|
|
||||||
case SCHED_BATCH:
|
|
||||||
return "batch"
|
|
||||||
case SCHED_IDLE:
|
|
||||||
return "idle"
|
|
||||||
case SCHED_DEADLINE:
|
|
||||||
return "deadline"
|
|
||||||
case SCHED_EXT:
|
|
||||||
return "ext"
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "invalid policy " + strconv.Itoa(int(policy))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalText performs bounds checking and returns the result of String.
|
|
||||||
func (policy SchedPolicy) MarshalText() ([]byte, error) {
|
|
||||||
if policy == _SCHED_ISO || policy < 0 || policy > _SCHED_LAST {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
return []byte(policy.String()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvalidSchedPolicyError is an invalid string representation of a [SchedPolicy].
|
|
||||||
type InvalidSchedPolicyError string
|
|
||||||
|
|
||||||
func (InvalidSchedPolicyError) Unwrap() error { return EINVAL }
|
|
||||||
func (e InvalidSchedPolicyError) Error() string {
|
|
||||||
return "invalid scheduling policy " + strconv.Quote(string(e))
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalText is the inverse of MarshalText.
|
|
||||||
func (policy *SchedPolicy) UnmarshalText(text []byte) error {
|
|
||||||
switch string(text) {
|
|
||||||
case "fifo":
|
|
||||||
*policy = SCHED_FIFO
|
|
||||||
case "rr":
|
|
||||||
*policy = SCHED_RR
|
|
||||||
case "batch":
|
|
||||||
*policy = SCHED_BATCH
|
|
||||||
case "idle":
|
|
||||||
*policy = SCHED_IDLE
|
|
||||||
case "deadline":
|
|
||||||
*policy = SCHED_DEADLINE
|
|
||||||
case "ext":
|
|
||||||
*policy = SCHED_EXT
|
|
||||||
|
|
||||||
case "":
|
|
||||||
*policy = 0
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return InvalidSchedPolicyError(text)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// for sched_get_priority_max and sched_get_priority_min
|
|
||||||
var (
|
|
||||||
schedPriority [_SCHED_LAST + 1][2]std.Int
|
|
||||||
schedPriorityErr [_SCHED_LAST + 1][2]error
|
|
||||||
schedPriorityOnce [_SCHED_LAST + 1][2]sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetPriorityMax returns the maximum priority value that can be used with the
|
|
||||||
// scheduling algorithm identified by policy.
|
|
||||||
func (policy SchedPolicy) GetPriorityMax() (std.Int, error) {
|
|
||||||
schedPriorityOnce[policy][0].Do(func() {
|
|
||||||
priority, _, errno := Syscall(
|
|
||||||
SYS_SCHED_GET_PRIORITY_MAX,
|
|
||||||
uintptr(policy),
|
|
||||||
0, 0,
|
|
||||||
)
|
|
||||||
schedPriority[policy][0] = std.Int(priority)
|
|
||||||
if schedPriority[policy][0] < 0 {
|
|
||||||
schedPriorityErr[policy][0] = errno
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return schedPriority[policy][0], schedPriorityErr[policy][0]
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPriorityMin returns the minimum priority value that can be used with the
|
|
||||||
// scheduling algorithm identified by policy.
|
|
||||||
func (policy SchedPolicy) GetPriorityMin() (std.Int, error) {
|
|
||||||
schedPriorityOnce[policy][1].Do(func() {
|
|
||||||
priority, _, errno := Syscall(
|
|
||||||
SYS_SCHED_GET_PRIORITY_MIN,
|
|
||||||
uintptr(policy),
|
|
||||||
0, 0,
|
|
||||||
)
|
|
||||||
schedPriority[policy][1] = std.Int(priority)
|
|
||||||
if schedPriority[policy][1] < 0 {
|
|
||||||
schedPriorityErr[policy][1] = errno
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return schedPriority[policy][1], schedPriorityErr[policy][1]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// schedParam is equivalent to struct sched_param from include/linux/sched.h.
|
// schedParam is equivalent to struct sched_param from include/linux/sched.h.
|
||||||
type schedParam struct {
|
type schedParam struct {
|
||||||
// sched_priority
|
// sched_priority
|
||||||
priority std.Int
|
priority ext.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
// schedSetscheduler sets both the scheduling policy and parameters for the
|
// schedSetscheduler sets both the scheduling policy and parameters for the
|
||||||
@@ -191,30 +31,14 @@ type schedParam struct {
|
|||||||
// this if you do not have something similar in place!
|
// this if you do not have something similar in place!
|
||||||
//
|
//
|
||||||
// [very subtle to use correctly]: https://www.openwall.com/lists/musl/2016/03/01/4
|
// [very subtle to use correctly]: https://www.openwall.com/lists/musl/2016/03/01/4
|
||||||
func schedSetscheduler(tid int, policy SchedPolicy, param *schedParam) error {
|
func schedSetscheduler(tid int, policy ext.SchedPolicy, param *schedParam) error {
|
||||||
if r, _, errno := Syscall(
|
if _, _, errno := Syscall(
|
||||||
SYS_SCHED_SETSCHEDULER,
|
SYS_SCHED_SETSCHEDULER,
|
||||||
uintptr(tid),
|
uintptr(tid),
|
||||||
uintptr(policy),
|
uintptr(policy),
|
||||||
uintptr(unsafe.Pointer(param)),
|
uintptr(unsafe.Pointer(param)),
|
||||||
); r < 0 {
|
); errno != 0 {
|
||||||
return errno
|
return errno
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IgnoringEINTR makes a function call and repeats it if it returns an
|
|
||||||
// EINTR error. This appears to be required even though we install all
|
|
||||||
// signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846.
|
|
||||||
// Also #20400 and #36644 are issues in which a signal handler is
|
|
||||||
// installed without setting SA_RESTART. None of these are the common case,
|
|
||||||
// but there are enough of them that it seems that we can't avoid
|
|
||||||
// an EINTR loop.
|
|
||||||
func IgnoringEINTR(fn func() error) error {
|
|
||||||
for {
|
|
||||||
err := fn()
|
|
||||||
if err != EINTR {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
11
container/syscall_close_range.go
Normal file
11
container/syscall_close_range.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
//go:build close_range
|
||||||
|
|
||||||
|
package container
|
||||||
|
|
||||||
|
import "hakurei.app/ext"
|
||||||
|
|
||||||
|
// doCloseOnExec implements ensureCloseOnExec by calling CloseRange with
|
||||||
|
// CLOSE_RANGE_CLOEXEC.
|
||||||
|
func doCloseOnExec() error {
|
||||||
|
return ext.CloseRange(0, ext.MaxUint, ext.CLOSE_RANGE_CLOEXEC)
|
||||||
|
}
|
||||||
28
container/syscall_range_proc.go
Normal file
28
container/syscall_range_proc.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
//go:build !close_range
|
||||||
|
|
||||||
|
package container
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"hakurei.app/fhs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// doCloseOnExec implements ensureCloseOnExec by ranging over proc_pid_fd(5).
|
||||||
|
func doCloseOnExec() error {
|
||||||
|
entries, err := os.ReadDir(fhs.ProcSelf + "fd/")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var fd int
|
||||||
|
for _, ent := range entries {
|
||||||
|
if fd, err = strconv.Atoi(ent.Name()); err != nil {
|
||||||
|
return err // not reached
|
||||||
|
}
|
||||||
|
syscall.CloseOnExec(fd)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"hakurei.app/container/fhs"
|
"hakurei.app/fhs"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
1
dist/hsurc.default
vendored
1
dist/hsurc.default
vendored
@@ -1 +0,0 @@
|
|||||||
1000 0
|
|
||||||
12
dist/install.sh
vendored
12
dist/install.sh
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
cd "$(dirname -- "$0")" || exit 1
|
|
||||||
|
|
||||||
install -vDm0755 "bin/hakurei" "${DESTDIR}/usr/bin/hakurei"
|
|
||||||
install -vDm0755 "bin/sharefs" "${DESTDIR}/usr/bin/sharefs"
|
|
||||||
|
|
||||||
install -vDm4511 "bin/hsu" "${DESTDIR}/usr/bin/hsu"
|
|
||||||
if [ ! -f "${DESTDIR}/etc/hsurc" ]; then
|
|
||||||
install -vDm0400 "hsurc.default" "${DESTDIR}/etc/hsurc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
install -vDm0644 "comp/_hakurei" "${DESTDIR}/usr/share/zsh/site-functions/_hakurei"
|
|
||||||
31
dist/release.sh
vendored
31
dist/release.sh
vendored
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh -e
|
|
||||||
cd "$(dirname -- "$0")/.."
|
|
||||||
VERSION="${HAKUREI_VERSION:-untagged}"
|
|
||||||
pname="hakurei-${VERSION}-$(go env GOARCH)"
|
|
||||||
out="${DESTDIR:-dist}/${pname}"
|
|
||||||
|
|
||||||
echo '# Preparing distribution files.'
|
|
||||||
mkdir -p "${out}"
|
|
||||||
cp -v "README.md" "dist/hsurc.default" "dist/install.sh" "${out}"
|
|
||||||
cp -rv "dist/comp" "${out}"
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo '# Building hakurei.'
|
|
||||||
go generate ./...
|
|
||||||
go build -trimpath -v -o "${out}/bin/" -ldflags "-s -w
|
|
||||||
-buildid= -linkmode external -extldflags=-static
|
|
||||||
-X hakurei.app/internal/info.buildVersion=${VERSION}
|
|
||||||
-X hakurei.app/internal/info.hakureiPath=/usr/bin/hakurei
|
|
||||||
-X hakurei.app/internal/info.hsuPath=/usr/bin/hsu
|
|
||||||
-X main.hakureiPath=/usr/bin/hakurei" ./...
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo '# Testing hakurei.'
|
|
||||||
go test -ldflags='-buildid= -linkmode external -extldflags=-static' ./...
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo '# Creating distribution.'
|
|
||||||
rm -f "${out}.tar.gz" && tar -C "${out}/.." -vczf "${out}.tar.gz" "${pname}"
|
|
||||||
rm -rf "${out}"
|
|
||||||
(cd "${out}/.." && sha512sum "${pname}.tar.gz" > "${pname}.tar.gz.sha512")
|
|
||||||
echo
|
|
||||||
85
ext/ext.go
Normal file
85
ext/ext.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// Package ext provides wrappers around nonportable system interfaces.
|
||||||
|
package ext
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"iter"
|
||||||
|
"math"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// checked in container/seccomp
|
||||||
|
type (
|
||||||
|
// Uint is equivalent to C.uint.
|
||||||
|
Uint = uint32
|
||||||
|
// Int is equivalent to C.int.
|
||||||
|
Int = int32
|
||||||
|
)
|
||||||
|
|
||||||
|
// Integer limit values.
|
||||||
|
const (
|
||||||
|
MaxUint = math.MaxUint32
|
||||||
|
MaxInt = math.MaxInt32
|
||||||
|
)
|
||||||
|
|
||||||
|
// SyscallNum represents an architecture-specific, Linux syscall number.
|
||||||
|
type SyscallNum Int
|
||||||
|
|
||||||
|
// Syscalls returns an iterator over all wired syscalls.
|
||||||
|
func Syscalls() iter.Seq2[string, SyscallNum] {
|
||||||
|
return func(yield func(string, SyscallNum) bool) {
|
||||||
|
for name, num := range syscallNum {
|
||||||
|
if !yield(name, num) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for name, num := range syscallNumExtra {
|
||||||
|
if !yield(name, num) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyscallResolveName resolves a syscall number from its string representation.
|
||||||
|
func SyscallResolveName(name string) (num SyscallNum, ok bool) {
|
||||||
|
if num, ok = syscallNum[name]; ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
num, ok = syscallNumExtra[name]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON resolves the name of [Syscall] and encodes it as a [json] string.
|
||||||
|
// If such a name does not exist, the syscall number is encoded instead.
|
||||||
|
func (num *SyscallNum) MarshalJSON() ([]byte, error) {
|
||||||
|
n := *num
|
||||||
|
for name, cur := range Syscalls() {
|
||||||
|
if cur == n {
|
||||||
|
return json.Marshal(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json.Marshal(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyscallNameError is returned when trying to unmarshal an invalid syscall name into [ScmpSyscall].
|
||||||
|
type SyscallNameError string
|
||||||
|
|
||||||
|
func (e SyscallNameError) Error() string {
|
||||||
|
return "invalid syscall name " + strconv.Quote(string(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON looks up the syscall number corresponding to name encoded in data
|
||||||
|
// by calling [SyscallResolveName].
|
||||||
|
func (num *SyscallNum) UnmarshalJSON(data []byte) error {
|
||||||
|
var name string
|
||||||
|
if err := json.Unmarshal(data, &name); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if n, ok := SyscallResolveName(name); !ok {
|
||||||
|
return SyscallNameError(name)
|
||||||
|
} else {
|
||||||
|
*num = n
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package std_test
|
package ext_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -7,39 +7,39 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/container/std"
|
"hakurei.app/ext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestScmpSyscall(t *testing.T) {
|
func TestSyscall(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
data string
|
data string
|
||||||
want std.ScmpSyscall
|
want ext.SyscallNum
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{"epoll_create1", `"epoll_create1"`, std.SNR_EPOLL_CREATE1, nil},
|
{"epoll_create1", `"epoll_create1"`, ext.SNR_EPOLL_CREATE1, nil},
|
||||||
{"clone3", `"clone3"`, std.SNR_CLONE3, nil},
|
{"clone3", `"clone3"`, ext.SNR_CLONE3, nil},
|
||||||
|
|
||||||
{"oob", `-2147483647`, -math.MaxInt32,
|
{"oob", `-2147483647`, -math.MaxInt32,
|
||||||
&json.UnmarshalTypeError{Value: "number", Type: reflect.TypeFor[string](), Offset: 11}},
|
&json.UnmarshalTypeError{Value: "number", Type: reflect.TypeFor[string](), Offset: 11}},
|
||||||
{"name", `"nonexistent_syscall"`, -math.MaxInt32,
|
{"name", `"nonexistent_syscall"`, -math.MaxInt32,
|
||||||
std.SyscallNameError("nonexistent_syscall")},
|
ext.SyscallNameError("nonexistent_syscall")},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("decode", func(t *testing.T) {
|
t.Run("decode", func(t *testing.T) {
|
||||||
var got std.ScmpSyscall
|
var got ext.SyscallNum
|
||||||
if err := json.Unmarshal([]byte(tc.data), &got); !reflect.DeepEqual(err, tc.err) {
|
if err := json.Unmarshal([]byte(tc.data), &got); !reflect.DeepEqual(err, tc.err) {
|
||||||
t.Fatalf("Unmarshal: error = %#v, want %#v", err, tc.err)
|
t.Fatalf("Unmarshal: error = %#v, want %#v", err, tc.err)
|
||||||
} else if err == nil && got != tc.want {
|
} else if err == nil && got != tc.want {
|
||||||
t.Errorf("Unmarshal: %v, want %v", got, tc.want)
|
t.Errorf("Unmarshal: %v, want %v", got, tc.want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if errors.As(tc.err, new(std.SyscallNameError)) {
|
if errors.As(tc.err, new(ext.SyscallNameError)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +55,22 @@ func TestScmpSyscall(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("error", func(t *testing.T) {
|
t.Run("error", func(t *testing.T) {
|
||||||
const want = `invalid syscall name "\x00"`
|
const want = `invalid syscall name "\x00"`
|
||||||
if got := std.SyscallNameError("\x00").Error(); got != want {
|
if got := ext.SyscallNameError("\x00").Error(); got != want {
|
||||||
t.Fatalf("Error: %q, want %q", got, want)
|
t.Fatalf("Error: %q, want %q", got, want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSyscallResolveName(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
for name, want := range ext.Syscalls() {
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if got, ok := ext.SyscallResolveName(name); !ok || got != want {
|
||||||
|
t.Errorf("SyscallResolveName(%q) = %d, want %d", name, got, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,11 +19,11 @@ print <<EOF;
|
|||||||
// $command
|
// $command
|
||||||
// Code generated by the command above; DO NOT EDIT.
|
// Code generated by the command above; DO NOT EDIT.
|
||||||
|
|
||||||
package std
|
package ext
|
||||||
|
|
||||||
import . "syscall"
|
import . "syscall"
|
||||||
|
|
||||||
var syscallNum = map[string]ScmpSyscall{
|
var syscallNum = map[string]SyscallNum{
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
my $offset = 0;
|
my $offset = 0;
|
||||||
@@ -45,7 +45,7 @@ sub fmt {
|
|||||||
print " \"$name\": SNR_$name_upper,\n";
|
print " \"$name\": SNR_$name_upper,\n";
|
||||||
}
|
}
|
||||||
elsif($state == 1){
|
elsif($state == 1){
|
||||||
print " SNR_$name_upper ScmpSyscall = SYS_$name_upper\n";
|
print " SNR_$name_upper SyscallNum = SYS_$name_upper\n";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return;
|
return;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated from include/seccomp-syscalls.h; DO NOT EDIT.
|
// Code generated from include/seccomp-syscalls.h; DO NOT EDIT.
|
||||||
|
|
||||||
package std
|
package ext
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pseudo syscall definitions
|
* pseudo syscall definitions
|
||||||
207
ext/syscall.go
Normal file
207
ext/syscall.go
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
package ext
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Prctl manipulates various aspects of the behavior of the calling thread or process.
|
||||||
|
func Prctl(op, arg2, arg3 uintptr) error {
|
||||||
|
r, _, errno := syscall.Syscall(syscall.SYS_PRCTL, op, arg2, arg3)
|
||||||
|
if r < 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPtracer allows processes to ptrace(2) the calling process.
|
||||||
|
func SetPtracer(pid uintptr) error {
|
||||||
|
return Prctl(syscall.PR_SET_PTRACER, pid, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// linux/sched/coredump.h
|
||||||
|
const (
|
||||||
|
SUID_DUMP_DISABLE = iota
|
||||||
|
SUID_DUMP_USER
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetDumpable sets the "dumpable" attribute of the calling process.
|
||||||
|
func SetDumpable(dumpable uintptr) error {
|
||||||
|
return Prctl(syscall.PR_SET_DUMPABLE, dumpable, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Isatty tests whether a file descriptor refers to a terminal.
|
||||||
|
func Isatty(fd int) bool {
|
||||||
|
var buf [8]byte
|
||||||
|
r, _, _ := syscall.Syscall(
|
||||||
|
syscall.SYS_IOCTL,
|
||||||
|
uintptr(fd),
|
||||||
|
syscall.TIOCGWINSZ,
|
||||||
|
uintptr(unsafe.Pointer(&buf[0])),
|
||||||
|
)
|
||||||
|
return r == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// IgnoringEINTR makes a function call and repeats it if it returns an
|
||||||
|
// EINTR error. This appears to be required even though we install all
|
||||||
|
// signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846.
|
||||||
|
// Also #20400 and #36644 are issues in which a signal handler is
|
||||||
|
// installed without setting SA_RESTART. None of these are the common case,
|
||||||
|
// but there are enough of them that it seems that we can't avoid
|
||||||
|
// an EINTR loop.
|
||||||
|
func IgnoringEINTR(fn func() error) error {
|
||||||
|
for {
|
||||||
|
err := fn()
|
||||||
|
if err != syscall.EINTR {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// include/uapi/linux/close_range.h
|
||||||
|
const (
|
||||||
|
CLOSE_RANGE_UNSHARE = 1 << (iota + 1)
|
||||||
|
CLOSE_RANGE_CLOEXEC
|
||||||
|
)
|
||||||
|
|
||||||
|
// CloseRange close all file descriptors in a given range.
|
||||||
|
func CloseRange(first, last Uint, flags Int) error {
|
||||||
|
_, _, errno := syscall.Syscall(
|
||||||
|
SYS_CLOSE_RANGE,
|
||||||
|
uintptr(first),
|
||||||
|
uintptr(last),
|
||||||
|
uintptr(flags),
|
||||||
|
)
|
||||||
|
if errno != 0 {
|
||||||
|
return errno
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedPolicy denotes a scheduling policy defined in include/uapi/linux/sched.h.
|
||||||
|
type SchedPolicy int
|
||||||
|
|
||||||
|
// include/uapi/linux/sched.h
|
||||||
|
const (
|
||||||
|
SCHED_NORMAL SchedPolicy = iota
|
||||||
|
SCHED_FIFO
|
||||||
|
SCHED_RR
|
||||||
|
SCHED_BATCH
|
||||||
|
_SCHED_ISO // SCHED_ISO: reserved but not implemented yet
|
||||||
|
SCHED_IDLE
|
||||||
|
SCHED_DEADLINE
|
||||||
|
SCHED_EXT
|
||||||
|
|
||||||
|
SCHED_LAST SchedPolicy = iota - 1
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ encoding.TextMarshaler = SCHED_LAST
|
||||||
|
var _ encoding.TextUnmarshaler = new(SCHED_LAST)
|
||||||
|
|
||||||
|
// String returns a unique representation of policy, also used in encoding.
|
||||||
|
func (policy SchedPolicy) String() string {
|
||||||
|
switch policy {
|
||||||
|
case SCHED_NORMAL:
|
||||||
|
return ""
|
||||||
|
case SCHED_FIFO:
|
||||||
|
return "fifo"
|
||||||
|
case SCHED_RR:
|
||||||
|
return "rr"
|
||||||
|
case SCHED_BATCH:
|
||||||
|
return "batch"
|
||||||
|
case SCHED_IDLE:
|
||||||
|
return "idle"
|
||||||
|
case SCHED_DEADLINE:
|
||||||
|
return "deadline"
|
||||||
|
case SCHED_EXT:
|
||||||
|
return "ext"
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "invalid policy " + strconv.Itoa(int(policy))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText performs bounds checking and returns the result of String.
|
||||||
|
func (policy SchedPolicy) MarshalText() ([]byte, error) {
|
||||||
|
if policy == _SCHED_ISO || policy < 0 || policy > SCHED_LAST {
|
||||||
|
return nil, syscall.EINVAL
|
||||||
|
}
|
||||||
|
return []byte(policy.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidSchedPolicyError is an invalid string representation of a [SchedPolicy].
|
||||||
|
type InvalidSchedPolicyError string
|
||||||
|
|
||||||
|
func (InvalidSchedPolicyError) Unwrap() error { return syscall.EINVAL }
|
||||||
|
func (e InvalidSchedPolicyError) Error() string {
|
||||||
|
return "invalid scheduling policy " + strconv.Quote(string(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText is the inverse of MarshalText.
|
||||||
|
func (policy *SchedPolicy) UnmarshalText(text []byte) error {
|
||||||
|
switch string(text) {
|
||||||
|
case "fifo":
|
||||||
|
*policy = SCHED_FIFO
|
||||||
|
case "rr":
|
||||||
|
*policy = SCHED_RR
|
||||||
|
case "batch":
|
||||||
|
*policy = SCHED_BATCH
|
||||||
|
case "idle":
|
||||||
|
*policy = SCHED_IDLE
|
||||||
|
case "deadline":
|
||||||
|
*policy = SCHED_DEADLINE
|
||||||
|
case "ext":
|
||||||
|
*policy = SCHED_EXT
|
||||||
|
|
||||||
|
case "":
|
||||||
|
*policy = 0
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return InvalidSchedPolicyError(text)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sched_get_priority_max and sched_get_priority_min
|
||||||
|
var (
|
||||||
|
schedPriority [SCHED_LAST + 1][2]Int
|
||||||
|
schedPriorityErr [SCHED_LAST + 1][2]error
|
||||||
|
schedPriorityOnce [SCHED_LAST + 1][2]sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetPriorityMax returns the maximum priority value that can be used with the
|
||||||
|
// scheduling algorithm identified by policy.
|
||||||
|
func (policy SchedPolicy) GetPriorityMax() (Int, error) {
|
||||||
|
schedPriorityOnce[policy][0].Do(func() {
|
||||||
|
priority, _, errno := syscall.Syscall(
|
||||||
|
syscall.SYS_SCHED_GET_PRIORITY_MAX,
|
||||||
|
uintptr(policy),
|
||||||
|
0, 0,
|
||||||
|
)
|
||||||
|
schedPriority[policy][0] = Int(priority)
|
||||||
|
if errno != 0 {
|
||||||
|
schedPriorityErr[policy][0] = errno
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return schedPriority[policy][0], schedPriorityErr[policy][0]
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPriorityMin returns the minimum priority value that can be used with the
|
||||||
|
// scheduling algorithm identified by policy.
|
||||||
|
func (policy SchedPolicy) GetPriorityMin() (Int, error) {
|
||||||
|
schedPriorityOnce[policy][1].Do(func() {
|
||||||
|
priority, _, errno := syscall.Syscall(
|
||||||
|
syscall.SYS_SCHED_GET_PRIORITY_MIN,
|
||||||
|
uintptr(policy),
|
||||||
|
0, 0,
|
||||||
|
)
|
||||||
|
schedPriority[policy][1] = Int(priority)
|
||||||
|
if errno != 0 {
|
||||||
|
schedPriorityErr[policy][1] = errno
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return schedPriority[policy][1], schedPriorityErr[policy][1]
|
||||||
|
}
|
||||||
13
ext/syscall_extra_linux_386.go
Normal file
13
ext/syscall_extra_linux_386.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package ext
|
||||||
|
|
||||||
|
var syscallNumExtra = map[string]SyscallNum{
|
||||||
|
"kexec_file_load": SNR_KEXEC_FILE_LOAD,
|
||||||
|
"subpage_prot": SNR_SUBPAGE_PROT,
|
||||||
|
"switch_endian": SNR_SWITCH_ENDIAN,
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
SNR_KEXEC_FILE_LOAD SyscallNum = __PNR_kexec_file_load
|
||||||
|
SNR_SUBPAGE_PROT SyscallNum = __PNR_subpage_prot
|
||||||
|
SNR_SWITCH_ENDIAN SyscallNum = __PNR_switch_endian
|
||||||
|
)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user