Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2241484rdb; Mon, 9 Oct 2023 19:02:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPIqmhbaP8KQxihJikN3KR6f5Dxm5u/jjSgR5WLFWIYvGst6Sp3v1QP4aiI0kQl8pzDH6h X-Received: by 2002:a17:90b:4a0c:b0:274:b4ce:7049 with SMTP id kk12-20020a17090b4a0c00b00274b4ce7049mr13620799pjb.34.1696903344544; Mon, 09 Oct 2023 19:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696903344; cv=none; d=google.com; s=arc-20160816; b=tQcUuqoX2JmvzdIvzanpdVoveDwYSyDpwLp1HCnojY+mvGENtS8qCkVEV3PFnYqtbC rxwhaZXdF/9Jozl+0gE5gvkRyI7yKWKIo5ptJn4J4ZHHEvBX4lcHowa5hFfUdAQYlFAz uMjYP67hPGJ248f6QwK3ZcPzhrzg1Ry906D31p/Lgr9gJhS6Jkzdv7HXp8TZFeyCVkLt HxXodxrZbhFpM7IGkRM+1scFqjchoTc3i2W2W1iVIqTFj0VpvOScZx7uSugkNPtD1CWz eFLJ7Qmn/3BaQoksz/+bCYn7AVaUObrm/NMkam0qzKVLxrf3rQHf/dnLAUJzgZAFoNIK vO0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=G34afWHNOwhQkHaOWVEojteMJQhFNbq7vLyYhiQh4xE=; fh=UUVBB6hdZtgkdevQaSWXrPPcR6FiQNJo3IQxWCli3s0=; b=x/LYaWEO/l0olpWqUJFJ/Sn1RLqi8gw2RgccMJP3A9Zjzv7Jp6f9T8sNBsvlPIZo/E wCMCXhrKwRMJxpskjiW1Mty/8evRQ0Vvu2+8eRSAf1iLeMK9+KQBYRfP191Q4Mhzx+V0 Yl6F9jpT1BEHcHwaxfUfgu24u4Kt3d1JUi62ijjMRNVnyTnY6vSuYmeQ9nRC0kvxIFbS 8F27/o3D2lJarldiHmendTcpGt9TOHmKJGNvw1SUGZsU0y093Qiuo6MB/W0nzWNE5NyS upVAAoX0G+86ggn88bJBQZKuLnRaGs6wFBwJ1LRBXvTc9nEZdSmxlmlXfc/9oR8xxJkO atkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CVRjKNZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id lx14-20020a17090b4b0e00b0027383ac5ebcsi7569745pjb.130.2023.10.09.19.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 19:02:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CVRjKNZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C5E3381EA5C1; Mon, 9 Oct 2023 19:02:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441799AbjJJCCQ (ORCPT + 99 others); Mon, 9 Oct 2023 22:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233869AbjJJCCP (ORCPT ); Mon, 9 Oct 2023 22:02:15 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6CD9D; Mon, 9 Oct 2023 19:02:14 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68fb85afef4so3812885b3a.1; Mon, 09 Oct 2023 19:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696903333; x=1697508133; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=G34afWHNOwhQkHaOWVEojteMJQhFNbq7vLyYhiQh4xE=; b=CVRjKNZ40Z1DY4uH95SaiNsZoKX/R7BIDfW9kEISjVMC7i5Rx9FlDRtGpKV3NafkGx yzxAQmOxsSb7D0qX1v59bVX9+AUSUiCC7UnNvU/cfcEVzb1nioFU8ZHmlGrLgZD0EG5q D6zhZv0z5LUi6Bs02FYpMx+D5LHBCMFj6FKg5LNMpa89CclCokgsBsNOTzPx3mKr0Qtm EYJWN/M+r3Laep660XFvtP1y40j7jCvvuHwvbUrEK4JZMlgMd25BdG/pRUU4g7gIokPc HnlRSmqTupCyJGoCwcd0RvkEbTPNcKS+xEoMf+fyOG8CJO26jRxPYpZt8cE4z8g7rQDK NNcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696903333; x=1697508133; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G34afWHNOwhQkHaOWVEojteMJQhFNbq7vLyYhiQh4xE=; b=pQOnD4GBU3zeY9uJSzB+XxKsw8XKMqyA7UD5Cvne6XplecE4anhMNDC4agifwNxrmd Xvjcr3eZtddB1t1cT5NvOaPHC8spMyva6TBpG0o5HhlrGWxANCJh2dzPXWkdyjubkOuK 50e/Yz693RwfuyC4xWaS5kYvE8W3088Lp7dIzM7BJ6AgXG9MSdRj1OqFE78AA1EK+H8W TnEwKmv0n33MY4k5qnSr8NhCAzZIrWkviRG2THvJoWxGADVlG+TTB9OU8f33GZJywuu4 uKcz0WoFrrj8Q02rb0s1E7yAaF21+rZmH3AKyXuYpEDJoEXjAJZxPmzdaZ909iki81QB pafg== X-Gm-Message-State: AOJu0YxR6OyXIAplm0MHEz82aKa4O8aM1PHhy6om7ZHAl6tx+uHqlGYS VI+kf9EI/bfDr+oEd18fFCt9p3xowWR+2g== X-Received: by 2002:a05:6a00:1410:b0:693:3c11:4293 with SMTP id l16-20020a056a00141000b006933c114293mr15147453pfu.14.1696903333272; Mon, 09 Oct 2023 19:02:13 -0700 (PDT) Received: from ubuntu.. ([43.132.98.112]) by smtp.googlemail.com with ESMTPSA id t28-20020aa7939c000000b0068a46cd4120sm7044809pfe.199.2023.10.09.19.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 19:02:12 -0700 (PDT) From: Hengqi Chen 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 0/4] seccomp: Make seccomp filter reusable Date: Mon, 9 Oct 2023 12:40:42 +0000 Message-Id: <20231009124046.74710-1-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=3.8 required=5.0 tests=DATE_IN_PAST_12_24,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 19:02:21 -0700 (PDT) X-Spam-Level: *** 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-hengqi.chen@gmail.com/ 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