|
|
Log in / Subscribe / Register

seccomp: Make seccomp filter reusable

From:  Hengqi Chen <hengqi.chen-AT-gmail.com>
To:  linux-kernel-AT-vger.kernel.org, bpf-AT-vger.kernel.org
Subject:  [PATCH 0/4] seccomp: Make seccomp filter reusable
Date:  Mon, 09 Oct 2023 12:40:42 +0000
Message-ID:  <20231009124046.74710-1-hengqi.chen@gmail.com>
Cc:  keescook-AT-chromium.org, ast-AT-kernel.org, daniel-AT-iogearbox.net, andrii-AT-kernel.org, luto-AT-amacapital.net, wad-AT-chromium.org, alexyonghe-AT-tencent.com, hengqi.chen-AT-gmail.com
Archive-link:  Article

This patchset introduces two new operations which essentially
splits the SECCOMP_SET_MODE_FILTER process into two steps:
SECCOMP_LOAD_FILTER and SECCOMP_ATTACH_FILTER.

The SECCOMP_LOAD_FILTER loads the filter and returns a fd
which can be pinned to bpffs. This extends the lifetime of the
filter and thus can be reused by different processes.
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 SECCOMP_ATTACH_FILTER is used to attach a loaded filter.
The filter is represented by a fd which is either returned
from SECCOMP_LOAD_FILTER or obtained from bpffs using bpf syscall.

Changes from RFC ([0]):
  - Addressed comments from Kees
  - Reuse filter copy/create code (patch 1)
  - Add a selftest (patch 4)

  [0]: https://lore.kernel.org/all/20231003083836.100706-1-hengq...

Hengqi Chen (4):
  seccomp: Refactor filter copy/create for reuse
  seccomp, bpf: Introduce SECCOMP_LOAD_FILTER operation
  seccomp: Introduce SECCOMP_ATTACH_FILTER operation
  selftests/seccomp: Test SECCOMP_LOAD_FILTER and SECCOMP_ATTACH_FILTER

 include/uapi/linux/bpf.h                      |   1 +
 include/uapi/linux/seccomp.h                  |   2 +
 kernel/seccomp.c                              | 184 +++++++++++++++---
 tools/testing/selftests/seccomp/seccomp_bpf.c |  20 ++
 4 files changed, 180 insertions(+), 27 deletions(-)

-- 
2.34.1



Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds