Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp329797pxk; Thu, 24 Sep 2020 06:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyohH7TINmBM3zbmJLjsmdAALAKjmFr7MCwweTRlGKTf+U93q7NFkydNu1sidc9fgV+fFY/ X-Received: by 2002:a17:906:9941:: with SMTP id zm1mr1115362ejb.288.1600955116293; Thu, 24 Sep 2020 06:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600955116; cv=none; d=google.com; s=arc-20160816; b=wmBOHbOguZxmzwsIzwpMazjy0AClCwUiz/Gu9z0bm3dkFI6h01ghXsR7IMy+JWezvr h18kz2bELEParCv5UqVNDLsYn1fez6sVUrnhUNfO48UYWVFUZUMmbxZYteKjbrc3e+iV OCR3BPcb+DFC8EQwhmYHRyYNmsnLn7ChWGiluOJ1sOL/wgfpRa4QEuSbpHgNUQTdnQbx oOYbETwuq8dHj21CBrqtvrLLX6dGV7kQ3USkJjbDHernRO2VQnGWJjdDuWva7DW2+N8U 8TJU/XNi8tFLMghKNCyYRu5mIjCOiNPyswPdybRGLGZHRTEYB6CVXEDkp7TpK8lxEWFr cq0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=cDrHVTOD+iSWXelVapd6LAkJ7VfbRManFz9vUWJEqwc=; b=YHeuKvXLoMFB2nv2jCQTi2Q1WBeSLxMjyaZcd46eyaGq0yViwsIPJtsc3mjtHnxx43 cESYbmYn7DB061XnUa84u9xvi4NNg+JOxvQ8nqMG5j7HPcNAaAvvqPvps/5oV1XcliDZ VAoFtSn3PirzcqaxYi4oOdQdaKC3lRcy8mhjWSqSH2KFGCa7S+tkcCM74/CKKwrEBmQW 0xYDFhXhmWqo0tAbVCyX89BC2IeaG9MbYWnAji6iN3UjxpoPSg0r6ZXBvBj4fkHhKLkA yfwh2IkQLTZaHIaXLw4C6MHKGG/OMZVydyITebdkeu5q/BFSg5NvyT2g1j2NKmsWFTS6 QLpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=KCxqPAVE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si2169779edq.449.2020.09.24.06.44.52; Thu, 24 Sep 2020 06:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=KCxqPAVE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgIXNlJ (ORCPT + 99 others); Thu, 24 Sep 2020 09:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728122AbgIXNk6 (ORCPT ); Thu, 24 Sep 2020 09:40:58 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8492EC0613D4 for ; Thu, 24 Sep 2020 06:40:58 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id z17so3919484lfi.12 for ; Thu, 24 Sep 2020 06:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cDrHVTOD+iSWXelVapd6LAkJ7VfbRManFz9vUWJEqwc=; b=KCxqPAVEUh0NN2sRqfB2Er3kRv3k3VxWZOlCy1TnuFltpouAeT9UrqF3gbDCWNhLso Q4gthE2otk3e6NybEISvLpG5ofuUJ4TsMDfT/fjZlK00Lj8I+w0dolYj3GdjwFPq6Ih8 CvX8q1UtLGea0tijaEcOFvSd32Yq46wp4o0mI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cDrHVTOD+iSWXelVapd6LAkJ7VfbRManFz9vUWJEqwc=; b=YPEcPvm4QfIQe31bqPV3hSQZolNeq4cKCEWfFRB5+odIQ6EONaLjr4VujpY4l4Qas8 N2k/9af4qcilL6BituTsq2MCpk/bS1zEsFmKbwYP0F9Yb//8vXFUhhXaupeMiDBbWn79 Y6bUQWHtTbbLfENxdDm+apRRdzi8sbDQjapb1toAZdz8OB0rZTCj9k5oXgSaM+431mg7 wtN7EqjUTRHopofwBc/KmBm5xSu0d1deGvGFngfNbaFaW3QiFBbTEmhaw9D0pWQShyAH aY07uuXK7rNwzExEfwGIHR0pjJoNzJfD/H3LMlkzkTe/6WOIvvAB+2oxm+rpoEWnnG+t zMQw== X-Gm-Message-State: AOAM532QJK4wR5iMe7Kl6zrYgS+iSvRjPO0UPqHOb2JiQ0TVZTXXSkqP WlK20apI81dw2+MsxWW8eb6iPigkQ2ayyXmyzu8= X-Received: by 2002:a19:6b17:: with SMTP id d23mr362374lfa.190.1600954856089; Thu, 24 Sep 2020 06:40:56 -0700 (PDT) Received: from [172.16.11.132] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id s20sm2085680lfs.135.2020.09.24.06.40.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2020 06:40:55 -0700 (PDT) Subject: Re: [PATCH v1 0/6] seccomp: Implement constant action bitmaps To: Kees Cook , YiFei Zhu Cc: Jann Horn , Christian Brauner , Tycho Andersen , Andy Lutomirski , Will Drewry , Andrea Arcangeli , Giuseppe Scrivano , Tobin Feldman-Fitzthum , Dimitrios Skarlatos , Valentin Rothberg , Hubertus Franke , Jack Chen , Josep Torrellas , Tianyin Xu , bpf@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200923232923.3142503-1-keescook@chromium.org> From: Rasmus Villemoes Message-ID: <43039bb6-9d9f-b347-fa92-ea34ccc21d3d@rasmusvillemoes.dk> Date: Thu, 24 Sep 2020 15:40:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200923232923.3142503-1-keescook@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/09/2020 01.29, Kees Cook wrote: > rfc: https://lore.kernel.org/lkml/20200616074934.1600036-1-keescook@chromium.org/ > alternative: https://lore.kernel.org/containers/cover.1600661418.git.yifeifz2@illinois.edu/ > v1: > - rebase to for-next/seccomp > - finish X86_X32 support for both pinning and bitmaps > - replace TLB magic with Jann's emulator > - add JSET insn > > TODO: > - add ALU|AND insn > - significantly more testing > > Hi, > > This is a refresh of my earlier constant action bitmap series. It looks > like the RFC was missed on the container list, so I've CCed it now. :) > I'd like to work from this series, as it handles the multi-architecture > stuff. So, I agree with Jann's point that the only thing that matters is that always-allowed syscalls are indeed allowed fast. But one thing I'm wondering about and I haven't seen addressed anywhere: Why build the bitmap on the kernel side (with all the complexity of having to emulate the filter for all syscalls)? Why can't userspace just hand the kernel "here's a new filter: the syscalls in this bitmap are always allowed noquestionsasked, for the rest, run this bpf". Sure, that might require a new syscall or extending seccomp(2) somewhat, but isn't that a _lot_ simpler? It would probably also mean that the bpf we do get handed is a lot smaller. Userspace might need to pass a couple of bitmaps, one for each relevant arch, but you get the overall idea. I'm also a bit worried about the performance of doing that emulation; that's constant extra overhead for, say, launching a docker container. Regardless of how the kernel's bitmap gets created, something like + if (nr < NR_syscalls) { + if (test_bit(nr, bitmaps->allow)) { + *filter_ret = SECCOMP_RET_ALLOW; + return true; + } probably wants some nospec protection somewhere to avoid the irony of seccomp() being used actively by bad guys. Rasmus