Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp13559rdg; Wed, 11 Oct 2023 18:48:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKSA/N8nfuduUh54T/4gcNfD6mFWkUmKeNdAgLh62P2tuNGBVPXwD6fgK/9syAKm2EBN2H X-Received: by 2002:a05:6a20:1596:b0:15c:7223:7bb1 with SMTP id h22-20020a056a20159600b0015c72237bb1mr28584384pzj.20.1697075325390; Wed, 11 Oct 2023 18:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697075325; cv=none; d=google.com; s=arc-20160816; b=0Unw9iew/f1sttPFcoDwY7KCjUgCJZPIxB9ByGKvGpanLRCbtqreBXChuDzGo5Zkmk nYRHg2eydr85dHSiU7xgNFVGbSl7/HvZF2B24bfl9FxaGm8/foIlDVeeAzmsAtsGFKED A6tgg/izEfB46g59ImVU+S9mAzsGN1dXwlCscsr4E6MZc6G1QU0Nu3zeh4VB4stxeLBr TNRP08MNO38nAQapZ3In6taO+HJxkT13p6AwjxJaUwN1sK4scIGV4zRVyPiATBuut958 R1xo3qoFf9isy0VMwiwyd2qGCIYMp/JriObgXWsfI/KUuQ+3hPw1EMQH4Fb1jy9Sv42w j9RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nchUXm+rbX4arDXAqlMb8BZfBxWIRFIQATpxfSNMMH8=; fh=tJ2UZ0tcKCt35O21cSZih4D2BIwoe8mtH3s2s3GlJM0=; b=rmbgSUW8V6eakwDerhiASdajjaJ8og22jgOjzq8r1MNg0O8vmV7TBRYbscYOGzIvMe ZscMJkbeCfe8HT0dkEVUQasaf2Na6Yep10FRPxf2JwDUC5XlxjE1H7RFg7EyIeXcdjRP tphlqZGxOGW7+q2Tuh6DnJkkSXNHgOiFHmdfg6aBITWZGEy8aDZJTq5UyslH1c+d68CS 82R9URw0HpvRuFPbvTx2OkP+8JNuqvXJo1u2xnawLdMpjVEy9n178eLBYIOLdkCYy9dt CYaujejtX3polHmlJ/CWqmX9vz694pnC3CH/Kl/hDZ6IZHeF60AOq26Ej0n5HcDMvWxC mJGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Bfaqsih6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f3-20020a170902ce8300b001c3a05b0b67si1095949plg.566.2023.10.11.18.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 18:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Bfaqsih6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 47D2080787F0; Wed, 11 Oct 2023 18:48:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbjJLBsi (ORCPT + 99 others); Wed, 11 Oct 2023 21:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233269AbjJLBsg (ORCPT ); Wed, 11 Oct 2023 21:48:36 -0400 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 857FAA9; Wed, 11 Oct 2023 18:48:34 -0700 (PDT) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1e10ba12fd3so255339fac.1; Wed, 11 Oct 2023 18:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697075314; x=1697680114; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nchUXm+rbX4arDXAqlMb8BZfBxWIRFIQATpxfSNMMH8=; b=Bfaqsih6AcyhJ7cEEnaxGaA3sEQOhi8hMKfq+eCauNZmzTH8l5jCoF4atOio91QONp dusc8RX9ualqXOoXvWMEJ0BAZ1/tEoP1iydJWx5MbAq7K7m85zI/qK+BNr2rDqEotUPH NgLSEUkTJvUJ/l58dYutBXBzbk36Gi2ucL2RE+RtNb9RSnoeK8xVicSt4ehF6vamIt12 1x/480ozIxnyc1+0lckAx+m6LJqGhJjVhIlyPpSHx8CLu4u3OhlwWEAgIcpdkRgrtnYs az5uTw1pjGAYxTgOGD0W9pMLZE7o4Vkn2FyYGQDQ1IytogZjH+7UNCUCz33zxoBaI0mk ysFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697075314; x=1697680114; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nchUXm+rbX4arDXAqlMb8BZfBxWIRFIQATpxfSNMMH8=; b=vawRcSmx1NXFCA9bNrs9AsiicIe7DZZTwKM0Ay6VlIoejBCN+b+kuXilUYQy7hV9LI XWkTLSaCAtdWeXo+fuzlMQ5ulbjAYc0ANI4Yxtly84ew88gJrFsMzizI5iCT8HPV1pKP qbeVWgbJHu37wU1KwU1wO2WuO4++Lv6ZlW8EOo0b54YBWg5x/21xNQyG5Res0rsW4cl0 ziEpGo/FLHCpcQSlpRaUa9UaNEW2cPFwljxyBFgwDpFY55sr2Jfp0hk8+JGqHjQL/1v8 ESZG0H6TJl7gx87HGURdvtbvI+5E+Q1TzpqLWkYr5zWv/04DHay5/0hkdms4k7aaH5Of G1iA== X-Gm-Message-State: AOJu0YxJ9CApn5T7MLH5C91AzpSYb9En75ltUjhB8aVz27S3147kx5s5 R2rupz1F/5lcjhM6Q42NQMlG8rJvvfOmaFNnXOY= X-Received: by 2002:a05:6870:4628:b0:1c8:b870:4e62 with SMTP id z40-20020a056870462800b001c8b8704e62mr23717663oao.52.1697075313755; Wed, 11 Oct 2023 18:48:33 -0700 (PDT) MIME-Version: 1.0 References: <20231009124046.74710-1-hengqi.chen@gmail.com> <20231009124046.74710-3-hengqi.chen@gmail.com> <202310101722.B6D6E6CEC@keescook> In-Reply-To: <202310101722.B6D6E6CEC@keescook> From: Hengqi Chen Date: Thu, 12 Oct 2023 09:48:22 +0800 Message-ID: Subject: Re: [PATCH 2/4] seccomp, bpf: Introduce SECCOMP_LOAD_FILTER operation To: Kees Cook Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, luto@amacapital.net, wad@chromium.org, alexyonghe@tencent.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.0 required=5.0 tests=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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 18:48:43 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 8:24=E2=80=AFAM Kees Cook w= rote: > > On Mon, Oct 09, 2023 at 12:40:44PM +0000, Hengqi Chen wrote: > > This patch adds a new operation named SECCOMP_LOAD_FILTER. > > It accepts the same arguments as SECCOMP_SET_MODE_FILTER > > but only performs the loading process. If succeed, return a > > new fd associated with the JITed BPF program (the filter). > > The filter can then be pinned to bpffs using the returned > > fd and reused for different processes. To distinguish the > > filter from other BPF progs, BPF_PROG_TYPE_SECCOMP is added. > > > > Signed-off-by: Hengqi Chen > > This part looks okay, I think. I need to spend some more time looking at > the BPF side. I want to make sure it is only possible to build a > BPF_PROG_TYPE_SECCOMP prog by going through seccomp. I want to make sure > we can never side-load some kind of unexpected program into seccomp, > etc. Since BPF_PROG_TYPE_SECCOMP is part of UAPI, is this controllable > through the bpf() syscall? > Currently, it failed at find_prog_type() since we don't register the prog type to BPF. > One thought I had, though, is I wonder if flags are needed to be > included with the fd? I'll ponder this a bit more... > bpf_prog_new_fd() already set O_RDWR and O_CLOEXEC. > -- > Kees Cook