All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hengqi Chen <hengqi.chen@gmail.com>
To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Cc: keescook@chromium.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, luto@amacapital.net, wad@chromium.org,
	alexyonghe@tencent.com, hengqi.chen@gmail.com
Subject: [PATCH v2 0/5] seccomp: Make seccomp filter reusable
Date: Sun, 15 Oct 2023 23:29:48 +0000	[thread overview]
Message-ID: <20231015232953.84836-1-hengqi.chen@gmail.com> (raw)

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 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 new flag SECCOMP_FILTER_FLAG_BPF_PROG_FD is used to attach
a filter which is loaded via SECCOMP_LOAD_FILTER and represented
by a seccomp bpf prog fd. The fd is either returned from
SECCOMP_LOAD_FILTER or obtained from bpffs using bpf syscall.

Change logs:
  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 (5):
  seccomp: Refactor filter copy/create for reuse
  seccomp, bpf: Introduce SECCOMP_LOAD_FILTER operation
  seccomp: Introduce new flag SECCOMP_FILTER_FLAG_BPF_PROG_FD
  selftests/seccomp: Test seccomp filter load and attach
  selftests/bpf: Skip BPF_PROG_TYPE_SECCOMP-related tests

 include/linux/seccomp.h                       |   3 +-
 include/uapi/linux/bpf.h                      |   1 +
 include/uapi/linux/seccomp.h                  |   3 +
 kernel/seccomp.c                              | 170 +++++++++++++++---
 tools/include/uapi/linux/bpf.h                |   1 +
 .../selftests/bpf/prog_tests/libbpf_probes.c  |   3 +-
 .../selftests/bpf/prog_tests/libbpf_str.c     |   3 +
 tools/testing/selftests/seccomp/seccomp_bpf.c |  44 +++++
 8 files changed, 197 insertions(+), 31 deletions(-)

-- 
2.34.1


             reply	other threads:[~2023-10-16  1:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-15 23:29 Hengqi Chen [this message]
2023-10-15 23:29 ` [PATCH v2 1/5] seccomp: Refactor filter copy/create for reuse Hengqi Chen
2023-10-15 23:29 ` [PATCH v2 2/5] seccomp, bpf: Introduce SECCOMP_LOAD_FILTER operation Hengqi Chen
2023-10-16 12:44   ` Daniel Borkmann
2023-10-23  4:17     ` Hengqi Chen
2023-10-22 23:42   ` kernel test robot
2023-10-15 23:29 ` [PATCH v2 3/5] seccomp: Introduce new flag SECCOMP_FILTER_FLAG_BPF_PROG_FD Hengqi Chen
2023-10-15 23:29 ` [PATCH v2 4/5] selftests/seccomp: Test seccomp filter load and attach Hengqi Chen
2023-10-15 23:29 ` [PATCH v2 5/5] selftests/bpf: Skip BPF_PROG_TYPE_SECCOMP-related tests Hengqi Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231015232953.84836-1-hengqi.chen@gmail.com \
    --to=hengqi.chen@gmail.com \
    --cc=alexyonghe@tencent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=wad@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.