implement errno action logging in seccomp for strict mode with snaps
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Fix Released
|
Medium
|
Tyler Hicks | ||
linux (Ubuntu) |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Xenial |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Zesty |
Fix Released
|
Undecided
|
Tyler Hicks | ||
Artful |
Fix Released
|
Undecided
|
Tyler Hicks |
Bug Description
A requirement for snappy is that security sandbox violations against policy are logged. In this manner learning tools can be written to parse the logs, etc and make developing on snappy easier.
The current default seccomp action, in strict mode. is to kill the snap's thread that violated the policy but this is unfriendly to the developer and to the user. The desired action is to block the illegal system call and return an error with errno set to EPERM. However, seccomp does not emit log events when it takes that action. Seccomp should be updated to emit log events when taking the SECCOMP_RET_ERRNO action and then snappy can switch to the using that action when blocking illegal system calls.
[Impact]
Snapd needs a way to log SECCOMP_RET_ERRNO seccomp actions in order to have a more friendly strict mode. Such functionality has been merged upstream into 4.14-rc2.
No libseccomp changes are needed at this time since snap-confine loads the BPF filter directly into the kernel without using libseccomp.
[Test Case]
Running the libseccomp "live" tests will exercise the kernel's seccomp enforcement and help to help catch any regressions. Note that on Artful, there's an existing test failure (20-live-
$ sudo apt build-dep -y libseccomp
$ sudo apt install -y cython
$ apt source libseccomp
$ cd libseccomp-*
$ autoreconf -ivf && ./configure --enable-python && make check-build
$ (cd tests && ./regression -T live)
All tests should pass on zesty (12 tests) and xenial (10 tests). On artful, you'll see one pre-existing failure:
...
Test 20-live-
...
Regression Test Summary
tests run: 12
tests skipped: 0
tests passed: 11
tests failed: 1
tests errored: 0
=======
-------
Running the seccomp kernel selftests is also a great to exercise seccomp and the kernel patch set proposed for the SRU includes additional seccomp selftests. To build, enter into the root of the kernel source tree and build the seccomp test binary:
$ make -C tools/testing/
Now you can execute tools/testing/
-------
Now we can run a single test to verify that SECCOMP_RET_ERRNO is logged when the application opts into it. First, verify that "errno" is listed in the actions_logged sysctl:
$ cat /proc/sys/
kill trap errno trace log
Now, build and run the test program:
$ gcc -o lp1721676-
$ ./lp1721676-
SUCCESS: getpid() failed as expected: Operation not permitted
It should have generated a message like this in /var/log/syslog:
kernel: [79338.804966] audit: type=1326 audit(150725922
Disable errno logging in the sysctl:
$ echo kill trap trace log | sudo tee /proc/sys/
kill trap trace log
Rerun the test program and ensure that nothing was logged this time.
[Regression Potential]
The kernel patches received a lot of review between Kees and some others interested in improved seccomp logging. I authored the patches and feel comfortable/
CVE References
Changed in linux (Ubuntu Xenial): | |
status: | New → In Progress |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in linux (Ubuntu Zesty): | |
status: | New → In Progress |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in linux (Ubuntu Artful): | |
status: | New → Fix Released |
assignee: | nobody → Tyler Hicks (tyhicks) |
description: | updated |
description: | updated |
Changed in linux (Ubuntu Xenial): | |
status: | In Progress → Fix Committed |
Changed in linux (Ubuntu Zesty): | |
status: | In Progress → Fix Committed |
The kernel patches for this feature have already been released in an Artful kernel (4.12.0-13.14).