Skip to content

seccomp: Make seccomp filter reusable

Hengqi Chen linux-kselftest lkml oe-lkp 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 0 repliesNew
  2. v25 patches 2 repliesSuperseded
  3. v14 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Stick to cBPF, don't interfere with bpffs

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3seccomp: Introduce SECCOMP_LOAD_FILTER operationinclude/uapi/linux/seccomp.h kernel/seccomp.c+35 -00 replies
2/3seccomp: Introduce new flag SECCOMP_FILTER_FLAG_FILTER_FDinclude/linux/seccomp.h include/uapi/linux/seccomp.h kernel/seccomp.c+45 -40 replies
3/3selftests/seccomp: Test seccomp filter load and attachtools/testing/selftests/seccomp/seccomp_bpf.c+71 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/3] seccomp: Make seccomp filter reusable

This patchset introduces a new operation and a new flag to split the SECCOMP_SET_MODE_FILTER process into two steps:
load filter and attach filter. Thus we can reuse the filter.

The new SECCOMP_LOAD_FILTER loads the filter and returns a fd which can be reused for different processes via UDS. With this new operation, we can eliminate a hot path of JITing BPF program (the filter) where we apply the same seccomp filter to thousands of micro VMs on a bare metal instance.

The new flag SECCOMP_FILTER_FLAG_FILTER_FD is used to attach a filter which is loaded via SECCOMP_LOAD_FILTER and represented by a seccomp filter fd.

Change logs:
v2 -> v3:
- Stick to cBPF, don't interfere with bpffs

v1 -> v2:
- Add a flag to attach filter from fd
- Update selftests

RFC -> v1:
- Addressed comments from Kees
- Reuse filter copy/create code (patch 1)
- Add a selftest (patch 4)

Hengqi Chen (3):
seccomp: Introduce SECCOMP_LOAD_FILTER operation
seccomp: Introduce new flag SECCOMP_FILTER_FLAG_FILTER_FD selftests/seccomp: Test seccomp filter load and attach

 include/linux/seccomp.h                       |  3 +-
 include/uapi/linux/seccomp.h                  |  3 +
 kernel/seccomp.c                              | 78 ++++++++++++++++++-
 tools/testing/selftests/seccomp/seccomp_bpf.c | 71 +++++++++++++++++
 4 files changed, 151 insertions(+), 4 deletions(-)

--
2.34.1