]> git.proxmox.com Git - mirror_libseccomp.git/log
mirror_libseccomp.git
4 years agobuild: ship seccomp-syscalls.h master
Stéphane Graber [Tue, 8 Oct 2019 19:24:10 +0000 (15:24 -0400)]
build: ship seccomp-syscalls.h

Without this, anything which includes "seccomp.h" will fail when using a build version of libseccomp.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: tweaked the subject line]
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agoapi: stop defining __NR_x values for syscalls that don't exist
Paul Moore [Sun, 29 Sep 2019 19:55:53 +0000 (15:55 -0400)]
api: stop defining __NR_x values for syscalls that don't exist

Historically libseccomp has created a __NR_x definition for every
syscall it supports, even those that aren't valid for a given ABI.
While this seemed like a good idea at the time, it turned out to have
some unwanted and nasty side effects.  This patch finally corrects
this problem.

The basic approach is quite simple: move the SCMP_SYS() macro to use
__SNR_x values instead of __NR_x values.  The unfortunate side effect
of this change is that instead of just worrying about #defines for the
__PNR_x values we now have to have a __SNR_x define for *every*
syscall.  The good news is that after this patch that should only be
a few new syscalls every year - a very manageable task.

Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agopython: fix error in pydoc
Jonah Petri [Thu, 12 Oct 2017 15:57:27 +0000 (11:57 -0400)]
python: fix error in pydoc

Fix the pydoc example so it's runnable.

Signed-off-by: Jonah Petri <jonah@petri.us>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: fix subject line (add prefix)]
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agodoc: ship the SECURITY.md file
Paul Moore [Mon, 22 Jul 2019 20:07:57 +0000 (16:07 -0400)]
doc: ship the SECURITY.md file

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agopython: install the python extension to the root package dir
Felix Geyer [Mon, 15 Jul 2019 19:12:05 +0000 (21:12 +0200)]
python: install the python extension to the root package dir

Commit 8ad3638ea9023c3948976dfadebd1554380a31c9 effectively added libseccomp/
to the install path of the python extension.
This changed the import module name from "seccomp" to "libseccomp.seccomp",
breaking existing users.

Revert the install path like it was before 2.4.0

Signed-off-by: Felix Geyer <debfx@fobos.de>
[PM: tweaked the subject line]
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agodoc: new process docs and various updates
Paul Moore [Tue, 2 Jul 2019 19:42:02 +0000 (15:42 -0400)]
doc: new process docs and various updates

A number of updates mainly focused on paving the way for multiple
maintainers and making better use of the GitHub vulnerability
reporting tools.

Signed-off-by: Paul Moore <paul@paul-moore.com>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoarch: add support for io-uring related system calls in kernel 5.1
Stephen Coleman [Sat, 22 Jun 2019 07:51:39 +0000 (15:51 +0800)]
arch: add support for io-uring related system calls in kernel 5.1

Signed-off-by: Stephen Coleman <omegacoleman@gmail.com>
Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: added the "arch:" subj prefix]
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agotests: add notification tests
Paul Moore [Thu, 2 May 2019 23:29:59 +0000 (19:29 -0400)]
tests: add notification tests

Some of this was taken from Tycho's original patch.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agopython: update the python bindings to support notifications
Paul Moore [Fri, 3 May 2019 02:06:54 +0000 (22:06 -0400)]
python: update the python bindings to support notifications

Here is the desciption from the main commit:

  "Kernel 5.0 includes the new user notification return code. Here's
   all the infrastructure to handle that.

   The idea behind the user notification return code is that the
   filter stops the syscall, and forwards it to a "listener fd" that
   is created when installing a filter. Then then some userspace task
   can listen and process events accordingly by taking some (or no)
   action in userspace, and then returning a value from the command."

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agoapi: make TSYNC and NOTIFY mutually exclusive
Paul Moore [Thu, 2 May 2019 23:29:59 +0000 (19:29 -0400)]
api: make TSYNC and NOTIFY mutually exclusive

The kernel explicitly disallows setting both TSYNC and NEW_LISTENER
at the same time, so catch this and block it in libseccomp.

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agoapi: implement user notification in libseccomp
Paul Moore [Thu, 2 May 2019 23:29:59 +0000 (19:29 -0400)]
api: implement user notification in libseccomp

This patch is heavily based on an earlier patchset by Tycho
Andersen.  I took Tycho's patch and incorporated the requested changes
from the review, fixed some corner case bugs, and simplified the API
a bit.

Kernel 5.0 includes the new user notification return code. Here's all the
infrastructure to handle that.

The idea behind the user notification return code is that the filter stops
the syscall, and forwards it to a "listener fd" that is created when
installing a filter. Then then some userspace task can listen and process
events accordingly by taking some (or no) action in userspace, and then
returning a value from the command.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agopython: use Cython language "3str"
Paul Moore [Wed, 1 May 2019 23:29:24 +0000 (19:29 -0400)]
python: use Cython language "3str"

Set the Cython language level to "3str" which is described in the
Cython 0.29 changelog:

 "A new language level name 3str was added that mostly corresponds to
  language level 3, but keeps unprefixed string literals as type ‘str’
  in both Py2 and Py3, and the builtin ‘str’ type unchanged. This will
  become the default in the next Cython release and is meant to help
  user code a) transition more easily to this new default and
  b) migrate to Python 3 source code semantics without making support
  for Python 2.x difficult."

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agodb: properly reset the attribute state in db_col_reset()
Paul Moore [Tue, 30 Apr 2019 20:33:06 +0000 (16:33 -0400)]
db: properly reset the attribute state in db_col_reset()

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agotests: fix a error message typo in 13-basic-attrs.py
Paul Moore [Tue, 30 Apr 2019 17:21:32 +0000 (13:21 -0400)]
tests: fix a error message typo in 13-basic-attrs.py

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agoapi: rename SCMP_FLTATR_SPEC_ALLOW to SCMP_FLTATR_CTL_SSB
Paul Moore [Tue, 30 Apr 2019 00:02:36 +0000 (20:02 -0400)]
api: rename SCMP_FLTATR_SPEC_ALLOW to SCMP_FLTATR_CTL_SSB

Signed-off-by: Paul Moore <paul@paul-moore.com>
4 years agoapi: add support for the SPEC_ALLOW flag
Tycho Andersen [Tue, 5 Mar 2019 17:20:24 +0000 (10:20 -0700)]
api: add support for the SPEC_ALLOW flag

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agosystem.h: add defines for USER_NOTIF bits
Tycho Andersen [Wed, 6 Feb 2019 21:07:03 +0000 (14:07 -0700)]
system.h: add defines for USER_NOTIF bits

The USER_NOTIF patch added several new structures, a new return code, a new
seccomp command and a new flag. Let's define all of those.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
[PM: some minor style tweaks via ./tools/check-syntax]
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodocs: create a doc/admin directory and move RELEASE_PROCESS.md into it
Paul Moore [Wed, 17 Apr 2019 21:15:29 +0000 (17:15 -0400)]
docs: create a doc/admin directory and move RELEASE_PROCESS.md into it

The idea is that any administrative/process docs should go in doc/admin.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodocs: minor changes to the RELEASE_PROCESS.md
Paul Moore [Wed, 17 Apr 2019 21:10:16 +0000 (17:10 -0400)]
docs: minor changes to the RELEASE_PROCESS.md

Fix some examples and add a note about deprecating older, unsupported
releases.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoall: update the CHANGELOG and version for v2.4.1
Paul Moore [Wed, 17 Apr 2019 16:14:26 +0000 (12:14 -0400)]
all: update the CHANGELOG and version for v2.4.1

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: only run test 50 on x86_64
Paul Moore [Wed, 17 Apr 2019 20:36:57 +0000 (16:36 -0400)]
tests: only run test 50 on x86_64

Because of the way libseccomp handles non-native arch translations we
can't use arbitrary syscalls, e.g. 1000; we need to use syscalls that
are defined in the libseccomp syscall tables.  Unfortunately, changing
the syscalls from 1000/1001 to a defined syscall appears to break the
test so let's just limit it to x86_64 for now.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: Add 50-sim-hash_collision test
Tom Hromatka [Wed, 10 Apr 2019 21:00:18 +0000 (15:00 -0600)]
tests: Add 50-sim-hash_collision test

libseccomp utilizes a hash table to manage BPF blocks.  It
currently employs MurmurHash3 where the key is the hashed values
of the BPF instruction blocks, the accumulator start, and the
accumulator end.  This test was added because of a mishandled
hash collision reported by Tor in GitHub issue #148.
* https://github.com/seccomp/libseccomp/issues/148

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agobpf: add accumulator state to the instruction block hash
Tom Hromatka [Thu, 11 Apr 2019 18:43:06 +0000 (12:43 -0600)]
bpf: add accumulator state to the instruction block hash

This addresses a problem where dissimilar instruction blocks were
improperly hashed to the same value because we were not taking into
account the accumulator state.

See the GitHub issue below for more information:
 * https://github.com/seccomp/libseccomp/issues/148

Reported-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoall: update the CHANGELOG and version for v2.4.0
Paul Moore [Thu, 14 Mar 2019 16:55:59 +0000 (12:55 -0400)]
all: update the CHANGELOG and version for v2.4.0

Signed-off-by: Paul Moore <paul@paul-moore.com>
(imported from commit 4d64011741375bb1a4ba7d71905ca37b97885083)

5 years agotests: add LT tests to 43-sim-a2_order
Paul Moore [Thu, 7 Mar 2019 15:49:40 +0000 (10:49 -0500)]
tests: add LT tests to 43-sim-a2_order

We want to be able to test proper ordering for both LT and GT
comparisons.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: add 48-sim-64b_comparisons
Paul Moore [Thu, 7 Mar 2019 15:49:40 +0000 (10:49 -0500)]
tests: add 48-sim-64b_comparisons

Based on some initial tests from Jann Horn.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: update 38-basic-pfc_coverage
Paul Moore [Thu, 7 Mar 2019 15:49:40 +0000 (10:49 -0500)]
tests: update 38-basic-pfc_coverage

Based on the recent 64-bit argument comparison fixes, we need to
update test 38-basic-pfc_coverage.

A special thanks to Jann Horn for bringing this problem to our
attention.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agobpf: pass the correct accumulator state to the next level
Paul Moore [Thu, 7 Mar 2019 15:49:40 +0000 (10:49 -0500)]
bpf: pass the correct accumulator state to the next level

We were mistakenly passing the wrong accumulator state (the state at
the start of the instruction block, not at the end) which was causing
us to generate unnecessary load instructions.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodb: fix 64-bit argument comparisons
Paul Moore [Thu, 7 Mar 2019 15:49:40 +0000 (10:49 -0500)]
db: fix 64-bit argument comparisons

Our approach to doing 64-bit comparisons using 32-bit operators was
just plain wrong, leading to a number of potential problems with
filters that used the LT, GT, LE, or GE operators.  This patch fixes
this problem and a few other related issues that came to light in
the course of fixing the core problem.

A special thanks to Jann Horn for bringing this problem to our
attention.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodoc: update the CREDITS file
Paul Moore [Tue, 12 Mar 2019 22:10:13 +0000 (18:10 -0400)]
doc: update the CREDITS file

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: fix some issues found by coverity
Paul Moore [Tue, 12 Mar 2019 15:54:22 +0000 (11:54 -0400)]
tests: fix some issues found by coverity

None of these are major, and they are all part of the tests, but we
should fix them regardless.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agosystem: fixup some cosmetic macro alignment issues
Paul Moore [Thu, 7 Mar 2019 15:45:27 +0000 (10:45 -0500)]
system: fixup some cosmetic macro alignment issues

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agosystem: add LOG action to seccomp.h
Tycho Andersen [Wed, 6 Feb 2019 21:00:03 +0000 (14:00 -0700)]
system: add LOG action to seccomp.h

This return code was added in 4.14, so let's reflect that here.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
[PM: cleanup up some duplication with the existing SECCOMP_RET_LOG code]
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agosystem: update defines to match upstream
Tycho Andersen [Wed, 6 Feb 2019 20:58:08 +0000 (13:58 -0700)]
system: update defines to match upstream

The kernel switched their defines to be more expressive like this, so let's
do the same. That will make it easy in future patches to copy and paste
definitions from the kernel :)

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodb: bail on a prune operation if both trees have a prefix
Paul Moore [Mon, 4 Mar 2019 23:46:41 +0000 (18:46 -0500)]
db: bail on a prune operation if both trees have a prefix

If both trees have prefixes that don't match, bail on the prune
operation.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: make use of the new 32-bit test filters
Paul Moore [Mon, 4 Mar 2019 23:12:04 +0000 (18:12 -0500)]
tests: make use of the new 32-bit test filters

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: add support for 32-bit and 64-bit test filtering
Paul Moore [Mon, 4 Mar 2019 23:11:45 +0000 (18:11 -0500)]
tests: add support for 32-bit and 64-bit test filtering

Add "[+]all_32" and "[+]all_64" which work the same as the
little and big endian test filters.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: disable a number of tests on the x32 arch
root [Mon, 4 Mar 2019 21:17:50 +0000 (16:17 -0500)]
tests: disable a number of tests on the x32 arch

Unfortunately a number of our automated tests fail because of the
x32 syscall bit, making low numbered syscalls invalid.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: add 48-sim-32b_args to the .gitignore file
Paul Moore [Mon, 4 Mar 2019 20:01:04 +0000 (15:01 -0500)]
tests: add 48-sim-32b_args to the .gitignore file

We forgot to do this earlier, fix it.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: fix a number of problems with the tests on a 32-bit x86 system
root [Fri, 1 Mar 2019 22:01:23 +0000 (17:01 -0500)]
tests: fix a number of problems with the tests on a 32-bit x86 system

Verified on a 32-bit x86 Ubuntu 16.04.6 system.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agostyle: fix a 80-char line width issue
Paul Moore [Fri, 1 Mar 2019 22:03:08 +0000 (17:03 -0500)]
style: fix a 80-char line width issue

I had made this fix earlier when applying a patch, but forgot to
update the patch.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoapi: provide 32-bit friendly argument comparison macros
Paul Moore [Tue, 15 Jan 2019 03:33:44 +0000 (22:33 -0500)]
api: provide 32-bit friendly argument comparison macros

We have a longstanding issue with 32-bit to 64-bit sign extension
inadvertently resulting in bogus syscall argument extensions. This
patch introduces a new set of argument comparison macros which
limit the argument values to 32-bit values so that we don't run into
problems with sign extension.

We use the macro overloading proposed by Roman at
https://kecher.net/overloading-macros/ to retain the feature of these
macros being usable as static initializers.

Thanks to @jdstrand on GitHub for reporting the problem.

Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
5 years agoarch: update the syscalls for Linux v5.0-rc5
Tom Hromatka [Fri, 8 Feb 2019 17:14:09 +0000 (10:14 -0700)]
arch: update the syscalls for Linux v5.0-rc5

Key changes include:
* Added __NR_statx, __NR_io_pgetevents, and __NR_rseq syscalls
  to seccomp.h.in
* mips architecture now generates some of its syscall header
  files.  Added logic to arch-syscall-validate to create these
  headers
* ppc architecture now uses a syscall.tbl
* s390 now uses a syscall.tbl

This addresses GitHub issue #136

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodb: Return -EDOM on endian mismatch during arch add
Tom Hromatka [Tue, 5 Feb 2019 22:27:45 +0000 (15:27 -0700)]
db: Return -EDOM on endian mismatch during arch add

This commit clarifies the error code when seccomp_arch_add() or
seccomp_merge() fails due to an endian mismatch.  Previously,
libseccomp would return -EEXIST if the new architecture's
endianness did not match.

This addresses GitHub Issue #86 - BUG: seccomp_arch_add() returns
-EEXISTS on endian mismatch

Reported-by: Michael Vogt <michael.vogt@gmail.com>
Suggested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotools: update the .gitignore
Paul Moore [Thu, 7 Feb 2019 23:47:03 +0000 (18:47 -0500)]
tools: update the .gitignore

I forgot to add scmp_api_level to the .gitignore file.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodb: fix a leak found by clang
Paul Moore [Tue, 5 Feb 2019 21:06:10 +0000 (16:06 -0500)]
db: fix a leak found by clang

Fix a leak found by clang where we were not cleaning up properly in
the error path.

    CC       libseccomp_la-db.lo
  db.c:2020:2: warning: Potential leak of memory pointed to by 'rule_s'
          _db_snap_release(snap);
          ^~~~~~~~~~~~~~~~

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotravis: update to ubuntu 16.04 (xenial)
Paul Moore [Tue, 5 Feb 2019 20:36:05 +0000 (15:36 -0500)]
travis: update to ubuntu 16.04 (xenial)

We are currently testing under Ubuntu 14.XX with Travis CI, it's time
to update to a more recent version of Ubuntu.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoapi: renumber the pseudo syscall for subpage_prot()
Paul Moore [Sat, 22 Sep 2018 19:18:12 +0000 (15:18 -0400)]
api: renumber the pseudo syscall for subpage_prot()

Unfortunately the pseduo syscall number for subpage_prot() was
already in use by spu_run() so renumber it to a free pseduo syscall
number.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: add an API level check to the live tests
Paul Moore [Sat, 22 Sep 2018 18:28:27 +0000 (14:28 -0400)]
tests: add an API level check to the live tests

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotools: add a new tool to detect the current API level
Paul Moore [Sat, 22 Sep 2018 18:15:33 +0000 (14:15 -0400)]
tools: add a new tool to detect the current API level

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: add openat() to the syscall whitelist in test 44
Paul Moore [Wed, 19 Sep 2018 21:17:31 +0000 (17:17 -0400)]
tests: add openat() to the syscall whitelist in test 44

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotests: Add tests for SECCOMP_RET_KILL_PROCESS
Tom Hromatka [Wed, 19 Sep 2018 15:32:41 +0000 (09:32 -0600)]
tests: Add tests for SECCOMP_RET_KILL_PROCESS

This addresses GitHub Issue #96 - RFE: add support for
SECCOMP_RET_KILL_PROCESS

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoapi: Add support for SCMP_ACT_KILL_PROCESS
Tom Hromatka [Wed, 19 Sep 2018 15:26:25 +0000 (09:26 -0600)]
api: Add support for SCMP_ACT_KILL_PROCESS

This patch adds support for killing the entire process via
the SCMP_ACT_KILL_PROCESS action.  To maintain backward
compatibility, SCMP_ACT_KILL defaults to SCMP_ACT_KILL_THREAD.
Support for KILL_PROCESS was added into the Linux kernel in
v4.14.

This addresses GitHub Issue #96 - RFE: add support for
SECCOMP_RET_KILL_PROCESS

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: minor comment tweak in seccomp.h.in]
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agopfc: fix PFC export hang on prioritized syscall with no rules (GH issue #117)
Tom Hromatka [Tue, 15 May 2018 13:56:56 +0000 (07:56 -0600)]
pfc: fix PFC export hang on prioritized syscall with no rules (GH issue #117)

github user @varqox reported that generating PFC will hang if the
libseccomp filter contains a syscalle with a priority but no rule
set.  The root cause is the while() loop in gen_pfc.c that walks
through the filter's syscalls.  It  wasn't properly advancing
through the list when p_iter was invalid.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: fix a comment in the test]
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agopython: fix operands in MASKED_EQ documentation
Felix Abecassis [Fri, 1 Jun 2018 22:48:45 +0000 (15:48 -0700)]
python: fix operands in MASKED_EQ documentation

Fixes: https://github.com/seccomp/libseccomp/issues/119
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
[PM: used full URL in the fixes line]
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agobuild: enable distcheck'ing for the python code
Paul Moore [Thu, 10 May 2018 23:25:34 +0000 (19:25 -0400)]
build: enable distcheck'ing for the python code

I'm not particularly proud of the seccomp.pyx hack, but it works, and
enabling the python bindings during the distcheck is definitely the
"Greater Good".

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodocs: add the RELEASE_PROCESS.md file to the list of distributed files
Paul Moore [Thu, 10 May 2018 23:22:01 +0000 (19:22 -0400)]
docs: add the RELEASE_PROCESS.md file to the list of distributed files

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodoc: add git tag signing to the release process
Paul Moore [Thu, 10 May 2018 22:57:09 +0000 (18:57 -0400)]
doc: add git tag signing to the release process

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodocs: mention the GitHub milestones in the release process documentation
Paul Moore [Thu, 10 May 2018 22:50:55 +0000 (18:50 -0400)]
docs: mention the GitHub milestones in the release process documentation

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodb: convert the db_chain_* macros to functions
Paul Moore [Thu, 10 May 2018 16:57:11 +0000 (12:57 -0400)]
db: convert the db_chain_* macros to functions

In addition to converting the db_chain_* macros to functions, we also
move them into db.c and eliminate the unused macros/functions.

This change was originally suggested by Tom Hromatka
<tom.hromatka@oracle.com>.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotravis: move from the bundled python to python "nightly" (3.7)
Paul Moore [Thu, 10 May 2018 21:44:07 +0000 (17:44 -0400)]
travis: move from the bundled python to python "nightly" (3.7)

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agotravis: move the code coverage testing to the "after_success" stage
Paul Moore [Thu, 10 May 2018 20:59:49 +0000 (16:59 -0400)]
travis: move the code coverage testing to the "after_success" stage

For an as yet unknown reason we keep seeing build failures due to the
code coverage tests despite there not being any noticeable failures.
Move the gcov testing to "after_success" so that failures won't mark
the build as failing.

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoall: fixup all the file permissions
Paul Moore [Thu, 10 May 2018 17:51:08 +0000 (13:51 -0400)]
all: fixup all the file permissions

Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agoapi: seccomp_api_get() doesn't need to be marked as const
Paul Moore [Thu, 10 May 2018 16:31:57 +0000 (12:31 -0400)]
api: seccomp_api_get() doesn't need to be marked as const

Reported-by: Marek <deadbeef@popcount.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
5 years agodoc: update the list of architectures in scmp_sys_resolver.1
James Cowgill [Thu, 22 Mar 2018 11:53:38 +0000 (11:53 +0000)]
doc: update the list of architectures in scmp_sys_resolver.1

Signed-off-by: James Cowgill <jcowgill@jcowgill.uk>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: add tests for db_chain_lt()
Tom Hromatka [Thu, 5 Apr 2018 21:39:21 +0000 (17:39 -0400)]
tests: add tests for db_chain_lt()

Add a test to improve the test coverage for db_chain_lt().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: stripped the conversion from a macro to function, kept the test]
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: added tests for the A2 ordering bug (GH issue #112)
Tom Hromatka [Thu, 5 Apr 2018 18:57:24 +0000 (14:57 -0400)]
tests: added tests for the A2 ordering bug (GH issue #112)

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: subject line tweaks]
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodb: applied pcmoore's gist for GH issue #112
Tom Hromatka [Thu, 5 Apr 2018 18:57:23 +0000 (14:57 -0400)]
db: applied pcmoore's gist for GH issue #112

Note that as cited in the gist, this commit is not ready to be
committed yet.  Specifically:

* investigate _db_tree_prune(), that likely needs some logic (lt/gt)
  flipping to compensate for the changes in _db_tree_add()
* run the full regression test to ensure we aren't accidentally breaking
  anything
* separate patch to add this test case to the regression tests
* separate patch to clear up the macros in src/db.h, see db_chain_lt() as
  an example

Full gist is here:
https://gist.github.com/pcmoore/f644341a85c6ad7131a26f68f99e3fc6

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
[PM: subject line tweak, testing has proven this commit is OK and necessary
     to restore proper db ordering, also fix the 'make check-syntax' errors]
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodocs: add the supported ABIs to the README
Paul Moore [Tue, 13 Mar 2018 20:48:23 +0000 (16:48 -0400)]
docs: add the supported ABIs to the README

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agobuild: add a "help" make target for the top level Makefile
Paul Moore [Thu, 25 Jan 2018 12:31:13 +0000 (07:31 -0500)]
build: add a "help" make target for the top level Makefile

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodocs: add golang bindings pointer to README.md
Paul Moore [Thu, 25 Jan 2018 11:39:40 +0000 (06:39 -0500)]
docs: add golang bindings pointer to README.md

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodoc: convert the travis badge to use shields.io
Paul Moore [Thu, 18 Jan 2018 04:21:34 +0000 (23:21 -0500)]
doc: convert the travis badge to use shields.io

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodoc: update the coveralls badge to use shields.io
Paul Moore [Thu, 18 Jan 2018 04:16:13 +0000 (23:16 -0500)]
doc: update the coveralls badge to use shields.io

This is a workaround for the coveralls stale cache problem.

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: update the python tests
Paul Moore [Thu, 18 Jan 2018 03:05:18 +0000 (22:05 -0500)]
tests: update the python tests

Commit ce3dda9a1747 ("all: massive src/db.c rework") failed to update the
python tests to match the native/C tests; this patch fixes that oversight.

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoall: massive src/db.c rework
Paul Moore [Wed, 17 Jan 2018 22:49:46 +0000 (17:49 -0500)]
all: massive src/db.c rework

First, and most importantly, let me state that this is perhaps the worst
possible example of a patch I can think of, and if anyone tries to submit
a PR/patch like this one I will reject it almost immediately.  I'm only
merging this because 1) this patch escalated quickly, 2) splitting it would
require a disproportionate amount of time, and 3) this effort had blocked
other work for too long ... and, well, I'm the maintainer.  Consider this
a bit of "maintainer privilege" if you will.

This patch started simply enough: the goal was to add/augment some tests to
help increase the libseccomp test coverage.  Unfortunately, this particular
test improvement uncovered a rather tricky bug which escalated quite quickly
and soon involved a major rework of how we build the filter tree in src/db.c.
This rework brought about changes throughout the repository, including the
transaction and ABI specific code.

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: add some advanced syscall argument chain tests via 40-sim-adv_chains
Paul Moore [Tue, 21 Mar 2017 19:23:17 +0000 (15:23 -0400)]
tests: add some advanced syscall argument chain tests via 40-sim-adv_chains

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodb: make sure the tree branches end in actions
Paul Moore [Tue, 21 Mar 2017 19:16:00 +0000 (15:16 -0400)]
db: make sure the tree branches end in actions

When we remove a node from the tree we need to make sure it is
replaced with the appropriate action.

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agobpf: remove some dead code in _bpf_append_blk()
Paul Moore [Thu, 2 Mar 2017 23:10:38 +0000 (18:10 -0500)]
bpf: remove some dead code in _bpf_append_blk()

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: add a test to check for syscall priority function on non-native ABIs
Paul Moore [Thu, 2 Mar 2017 15:21:53 +0000 (10:21 -0500)]
tests: add a test to check for syscall priority function on non-native ABIs

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: exercise removing multiple ABIs from a filter
Paul Moore [Wed, 1 Mar 2017 23:00:53 +0000 (18:00 -0500)]
tests: exercise removing multiple ABIs from a filter

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: test for invalid filter attributes
Paul Moore [Wed, 1 Mar 2017 22:34:50 +0000 (17:34 -0500)]
tests: test for invalid filter attributes

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agodoc: update the CHANGELOG and CREDITS for v2.3.3
Paul Moore [Wed, 10 Jan 2018 22:46:56 +0000 (17:46 -0500)]
doc: update the CHANGELOG and CREDITS for v2.3.3

Signed-off-by: Paul Moore <paul@paul-moore.com>
(imported from commit 1186e148c136f6d40483d51bd46eeaa33ca118ee)

6 years agotests: fix the live Python tests
Paul Moore [Wed, 10 Jan 2018 20:57:52 +0000 (15:57 -0500)]
tests: fix the live Python tests

Add the sigaltstack(2) syscall to the list of allowed syscalls; tested
against Python v3.6.4.

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoarch: update the syscalls for Linux v4.15-rc7
Paul Moore [Wed, 10 Jan 2018 17:16:28 +0000 (12:16 -0500)]
arch: update the syscalls for Linux v4.15-rc7

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoarch: add the statx syscall
Tobias Klauser [Fri, 20 Oct 2017 07:39:40 +0000 (09:39 +0200)]
arch: add the statx syscall

Fixes #88

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
[PM: fixed the incorrect x32 definition]
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: add test for SCMP_ACT_LOG of all syscalls
Tyler Hicks [Wed, 18 Oct 2017 06:16:57 +0000 (06:16 +0000)]
tests: add test for SCMP_ACT_LOG of all syscalls

Test SCMP_ACT_LOG as the default action which all syscalls trigger.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: add SCMP_ACT_LOG test to 06-sim-actions
Tyler Hicks [Wed, 18 Oct 2017 06:16:57 +0000 (06:16 +0000)]
tests: add SCMP_ACT_LOG test to 06-sim-actions

Extend the 06-sim-actions set of tests to include tests for
SCMP_ACT_LOG. The CTL_KCHECKACTS global attribute must be set to prevent
test errors when running under an old kernel that doesn't support
SECCOMP_RET_LOG.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: test suite infrastructure changes for SCMP_ACT_LOG
Tyler Hicks [Wed, 18 Oct 2017 06:16:56 +0000 (06:16 +0000)]
tests: test suite infrastructure changes for SCMP_ACT_LOG

The basics needed to handle tests that use the new SCMP_ACT_LOG
action.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoall: add support for new log action
Tyler Hicks [Wed, 18 Oct 2017 06:16:55 +0000 (06:16 +0000)]
all: add support for new log action

Extend libseccomp to support SECCOMP_RET_LOG, which is intended to
log the syscall before allowing it.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agosystem: runtime check if an action is supported by the kernel
Tyler Hicks [Wed, 18 Oct 2017 06:16:54 +0000 (06:16 +0000)]
system: runtime check if an action is supported by the kernel

As new actions are added to the kernel, libseccomp needs a way to
verify that an action is not only valid but also supported by the
current kernel at runtime. The only way to do this is by using the
SECCOMP_GET_ACTION_AVAIL operation which was added to seccomp(2) in
kernel version 4.14.

This check is not enabled for existing actions supported by libseccomp
since those actions were present in kernels at the inception of
libseccomp.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoall: add support for new log filter flag
Tyler Hicks [Wed, 18 Oct 2017 06:16:52 +0000 (06:16 +0000)]
all: add support for new log filter flag

Extend libseccomp to support SECCOMP_FILTER_FLAG_LOG, which is intended
to cause log events for all actions taken by a filter except for
SCMP_ACT_ALLOW actions. This is done via a new filter attribute called
SCMP_FLTATR_CTL_LOG that is off by default.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agosystem: runtime check if a filter flag is supported by the kernel
Tyler Hicks [Wed, 18 Oct 2017 06:16:47 +0000 (06:16 +0000)]
system: runtime check if a filter flag is supported by the kernel

As new filter flags are added to the kernel, libseccomp needs a way to
verify that a filter flag is not only valid but also supported by the
current kernel at runtime. A good way of doing that is by attempting to
enter filter mode, with the flag bit(s) in question set, and a NULL
pointer for the args parameter of seccomp(2). EFAULT indicates that the
flag is valid and EINVAL indicates that the flag is invalid. This patch
errs on the side of caution and treats any errno, besides EFAULT, as
indicating that the flag is invalid.

This check should be safe to use for the existing
SECCOMP_FILTER_FLAG_TSYNC flag so this patch enables the check for that
flag.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agopython: Expose API level functionality
Tyler Hicks [Tue, 10 Oct 2017 05:01:57 +0000 (05:01 +0000)]
python: Expose API level functionality

Allow Python applications to get and set the API level using global
functions.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: Improve seccomp_api_set() test coverage
Tyler Hicks [Mon, 9 Oct 2017 04:55:15 +0000 (04:55 +0000)]
tests: Improve seccomp_api_set() test coverage

Test setting all of the valid API levels and then test an invalid API
level to ensure that seccomp_api_set() fails.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoman: fix typo in seccomp_merge.3
Tobias Klauser [Thu, 19 Oct 2017 13:25:44 +0000 (15:25 +0200)]
man: fix typo in seccomp_merge.3

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoapi: Handle all possible return values when checking flag support
Tyler Hicks [Tue, 10 Oct 2017 15:41:06 +0000 (15:41 +0000)]
api: Handle all possible return values when checking flag support

When calling sys_chk_seccomp_flag(), ensure that a negative return value
is not incorrectly assumed to imply support of the flag.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agosystem: Add missing param to sys_chk_seccomp_flag() comment
Tyler Hicks [Mon, 9 Oct 2017 04:43:29 +0000 (04:43 +0000)]
system: Add missing param to sys_chk_seccomp_flag() comment

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agotests: Add new API level test binary to gitignore
Tyler Hicks [Mon, 9 Oct 2017 04:40:06 +0000 (04:40 +0000)]
tests: Add new API level test binary to gitignore

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agoapi: create an API level construct as part of the supported API
Paul Moore [Thu, 21 Sep 2017 14:27:38 +0000 (10:27 -0400)]
api: create an API level construct as part of the supported API

This patch adds the concept of "API levels" which are a way of
indicating what functionality is supported at runtime.  There are two
new API functions added, as explained by the manpage:

 "The seccomp_api_get() function returns an integer representing the
  functionality ("API level") provided by the current running kernel.
  It is important to note that while seccomp_api_get() can be called
  multiple times, the kernel is only probed the first time to see
  what functionality is supported, all following calls to
  seccomp_api_get() return a cached value.

  The seccomp_api_set() function allows callers to force the API
  level to the provided value; however, this is almost always a bad
  idea and use of this function is strongly discouraged."

Signed-off-by: Paul Moore <paul@paul-moore.com>
6 years agobuild: fix Travis CI build/test failures
Paul Moore [Wed, 13 Sep 2017 17:17:42 +0000 (13:17 -0400)]
build: fix Travis CI build/test failures

Signed-off-by: Paul Moore <paul@paul-moore.com>