Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
interfaces: simplify snap-confine by just loading pre-generated bpf code #3431
66a94a3
9bbcd97
e8c1799
a2e13bd
56896a0
ba48d7b
4d021ae
e8e0514
ba3888d
bb29170
b58a542
771dae9
fa573e9
5bf5540
dde305b
b1d6a1f
e5eb777
3fd764e
4442dab
dcf4611
c9b3dfc
76f1db4
847f892
ceef4a8
62e4c2b
396258d
7a6750f
77a6c0e
d0c76d2
f03a8ae
5dafe3f
0a36dcd
86ea145
bf85a1a
2949819
6f14922
6905b97
8536f7e
47ae906
70a714c
1ccce45
e3f2e9f
c260fda
a32a91d
1e462f6
dcfae66
4931f6e
91da609
123b438
0da9d0e
c97916b
1605b1e
b9c5004
205c52a
dfa81cb
7a5c354
6428412
faf20a5
3bd5a6a
5a72a9c
b259b03
dbdef16
e51e40c
665828a
978520f
0adfade
6a4311a
90a7f0e
f64670a
ff91f82
2be69cf
2d80225
5811a94
bc7f69d
f415a23
4046034
1e0260b
aad59d6
7367842
edb92ec
ec1d9ca
fc3d8af
99f6d2c
8ff0621
2189800
6ab9f32
8cf544a
0c7f5fa
02fba6f
26b2591
1d04d77
a135a71
dde3e76
3b35996
02a6d3f
start porting sh based snap-confine tests to the new seccomp-bpf world
- Loading branch information...
| @@ -191,7 +191,15 @@ func (s *snapSeccompSuite) TestCompile(c *C) { | ||
| // with arg1 and name resolving | ||
| {"ioctl - TIOCSTI", "ioctl;native;0,TIOCSTI", main.SeccompRetAllow}, | ||
mvo5
Collaborator
|
||
| + {"ioctl - TIOCSTI", "ioctl;native;0,99", main.SeccompRetKill}, | ||
| {"ioctl - !TIOCSTI", "ioctl;native;0,TIOCSTI", main.SeccompRetKill}, | ||
| + | ||
| + // test_bad_seccomp_filter_args_clone | ||
| + {"setns - CLONE_NEWNET", "setns;native;0,99", main.SeccompRetKill}, | ||
| + {"setns - CLONE_NEWNET", "setns;native;0,CLONE_NEWNET", main.SeccompRetAllow}, | ||
| + // test_bad_seccomp_filter_args_mknod | ||
| + {"mknod - |S_IFIFO", "mknod;native;0,S_IFIFO", main.SeccompRetAllow}, | ||
| + {"mknod - |S_IFIFO", "mknod;native;0,99", main.SeccompRetKill}, | ||
| } { | ||
| outPath := filepath.Join(c.MkDir(), "bpf") | ||
| err := main.Compile([]byte(t.seccompWhitelist), outPath) | ||
| @@ -214,3 +222,26 @@ func (s *snapSeccompSuite) TestCompile(c *C) { | ||
| } | ||
| } | ||
| + | ||
| +func (s *snapSeccompSuite) TestCompileBadInput(c *C) { | ||
| + for _, t := range []struct { | ||
| + inp string | ||
| + errMsg string | ||
| + }{ | ||
| + // test_bad_seccomp_filter_args_clone (various typos in input) | ||
| + {"setns - CLONE_NEWNE", `cannot parse line: cannot parse token "CLONE_NEWNE" \(line "setns - CLONE_NEWNE"\)`}, | ||
| + {"setns - CLONE_NEWNETT", `cannot parse line: cannot parse token "CLONE_NEWNETT" \(line "setns - CLONE_NEWNETT"\)`}, | ||
| + {"setns - CL0NE_NEWNET", `cannot parse line: cannot parse token "CL0NE_NEWNET" \(line "setns - CL0NE_NEWNET"\)`}, | ||
| + // test_bad_seccomp_filter_args_mknod (various typos in input) | ||
| + {"mknod - |S_IFIF", `cannot parse line: cannot parse token "S_IFIF" \(line "mknod - |S_IFIF"\)`}, | ||
| + {"mknod - |S_IFIFOO", `cannot parse line: cannot parse token "S_IFIFOO" \(line "mknod - |S_IFIFOO"\)`}, | ||
| + {"mknod - |S_!FIFO", `cannot parse line: cannot parse token "S_IFIFO" \(line "mknod - |S_!FIFO"\)`}, | ||
| + // test_bad_seccomp_filter_args | ||
| + {"mbind - - - - - - 7", `cannot parse line: too many tokens \(6\) in line.*`}, | ||
| + {"mbind 1 2 3 4 5 6 7", `cannot parse line: too many tokens \(6\) in line.*`}, | ||
| + } { | ||
| + outPath := filepath.Join(c.MkDir(), "bpf") | ||
| + err := main.Compile([]byte(t.inp), outPath) | ||
| + c.Check(err, ErrorMatches, t.errMsg, Commentf("%q errors in unexpected ways, got: %q expected %q", t.inp, err, t.errMsg)) | ||
| + } | ||
| +} | ||
| @@ -0,0 +1,15 @@ | ||
| +summary: Port of the snap-confine integration tests | ||
jdstrand
Contributor
|
||
| + | ||
| +restore: | | ||
| + rm -f tmpl | ||
| + | ||
| +execute: | | ||
| + # test_bad_seccomp_filter_args_clone | ||
| + for i in 'CLONE_NEWNE' 'CLONE_NETNETT' 'CL0NE_NEWNET' ; do | ||
| + printf "Test bad seccomp arg filtering (setns - %s)" "$i" | ||
| + echo "setns - $i" >> tmpl | ||
| + if /usr/lib/snapd/snap-seccomp compile tmpl tmpl.bpf; then | ||
| + echo "snap-seccomp should have failed to compile this" | ||
| + exit 1 | ||
| + fi | ||
| + done | ||
jdstrand
Contributor
|
||
I also find it confusing that for "ioctl - TIOCSTI" we expect "ioctl;native;0,TIOCSTI" because the first argument should be unspecified, not 0. Ie, for the bpfs we are simulating, what is the difference between these: