Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3096395pxu; Sat, 10 Oct 2020 19:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ9R27o2EpuGViMT5OrWQvUfNKfgqZr2F9yOUi9wgPttZxoeTV8GUWRXmJT0+R+e7L5tKt X-Received: by 2002:a17:906:1a19:: with SMTP id i25mr4796058ejf.323.1602384567442; Sat, 10 Oct 2020 19:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602384567; cv=none; d=google.com; s=arc-20160816; b=ckUqpEWKvcLfop4KdeM9BA8SFcIY0WhjYnRH8m+0ULufWnG9ujDfE63V+Za1eAbk+Y PzLE9pgxtE/5E4gOZ7/ffScy54k3TPHN8ZZVKmm1i31j8XekvKFkH3EnLm8SF3fiWaim zaSSHzhsAO11JLHXY4rU+ZpKZk8p865xhL5K2tDGMQwVHCCraaDKayO2q0RyApDTpwTO FqINvK/d4aD6lyeQdSHtjvpebUhUChhltZBDiimgftJbK0fVYfDij9MgqDbcYRtDAzo/ IP68syBhAnOP2nH1FQAzqtrOr7hVcBwpTbtuO987W9uw/wDTkx92Gn0PzrNsaxpG5AZB dBdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=n8tMNPlt+WgOGWxVqUdEpRLjgaATmbfqGWdnlUKGm2w=; b=HJSHr/qQJhKdeptWQymcYqdGKOIznN9wcWmly24x1VaG/4CSUl3D6jw11bp0ih7cjw Rc3jDji1aPuENjdOv65017ae0DtSULLMiwM9tC5HHf/DtDLyobFRrbKTquufh8gQxRar tg1l3V9YCr96lGeGzl0yifk6UGLB0JWyWi+RQYoxKml4PPC2ip07wwf9bFJtUPwx+FI7 uvyOt45VYctPlk7Gb+qXiyUANxmPi7qY/V8IqfeN+xG6pAT3O+4pZc2XAfy4hptJ0Kzl hbn/1c2LIm3HSWZ8pIk96S5kotipyt1ngMFpp48YlTJ1zl9bqWu8XovUui9M9hd9dqtS 25ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iKYPQpxj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si6596463ejk.83.2020.10.10.19.49.03; Sat, 10 Oct 2020 19:49:27 -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=@chromium.org header.s=google header.b=iKYPQpxj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbgJIXOv (ORCPT + 99 others); Fri, 9 Oct 2020 19:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbgJIXOv (ORCPT ); Fri, 9 Oct 2020 19:14:51 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22902C0613D5 for ; Fri, 9 Oct 2020 16:14:51 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id o9so5190024plx.10 for ; Fri, 09 Oct 2020 16:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=n8tMNPlt+WgOGWxVqUdEpRLjgaATmbfqGWdnlUKGm2w=; b=iKYPQpxjWQDkWz+DPQGsFwsINVhn1zUNJnEVfUJUHTj6OrT2UeyVf1jFWu2VGG0Sd/ Q6eQgdzwWjj1nWOw0JUlCIXxYd/FtVriQRsOUwCsaFdBcNkPKi+2pbMPFtUj75Sr/tRe 8j88AH6f6bdBDPc15Bfpy6/ADirbyIrXuuiWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=n8tMNPlt+WgOGWxVqUdEpRLjgaATmbfqGWdnlUKGm2w=; b=LQiqI28/U5Lf75EwNHNUanmfcX9VIsVIM5v9mcbIRZVSaXEkldoSS/gYhOrR7yefUZ fWedFu5jRRBNtl+1jjKZR5co/LWTJJRhNzCSQLh4vuET4lBgFDfY0RRgTh7FSpp7yCOi ZnQdbYsTleKAMiUYeGUeJCsN+TnBIrjcz249EGfF5zyB3bG6vuJK6qrcIjr3KneQpIgw njHOQoHtJUoyisvdnBWwXpQTWEXRK1TheH9cznx4dT41xBSomNAgbT9tZfOZ+/4emoBd wkIWgHE4RqQziet+i1aaZbTBxq8pJ4hqvtPCh1q8WAd35AZtcB/HHiQsDfa94xiJ35yF yINg== X-Gm-Message-State: AOAM5326sflBNtnM9arES0kdatAR+iVLDJftGQQtNafkM+qQtl1598lT 7cNdNg58uWHmTAcqqIWNYNMr3A== X-Received: by 2002:a17:902:8bc4:b029:d2:8cec:1fae with SMTP id r4-20020a1709028bc4b02900d28cec1faemr14566468plo.23.1602285290468; Fri, 09 Oct 2020 16:14:50 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g4sm12323939pgh.65.2020.10.09.16.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 16:14:49 -0700 (PDT) Date: Fri, 9 Oct 2020 16:14:48 -0700 From: Kees Cook To: YiFei Zhu Cc: containers@lists.linux-foundation.org, YiFei Zhu , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksa Sarai , Andrea Arcangeli , Andy Lutomirski , David Laight , Dimitrios Skarlatos , Giuseppe Scrivano , Hubertus Franke , Jack Chen , Jann Horn , Josep Torrellas , Tianyin Xu , Tobin Feldman-Fitzthum , Tycho Andersen , Valentin Rothberg , Will Drewry Subject: Re: [PATCH v4 seccomp 5/5] seccomp/cache: Report cache data through /proc/pid/seccomp_cache Message-ID: <202010091613.B671C86@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 09, 2020 at 12:14:33PM -0500, YiFei Zhu wrote: > From: YiFei Zhu > > Currently the kernel does not provide an infrastructure to translate > architecture numbers to a human-readable name. Translating syscall > numbers to syscall names is possible through FTRACE_SYSCALL > infrastructure but it does not provide support for compat syscalls. > > This will create a file for each PID as /proc/pid/seccomp_cache. > The file will be empty when no seccomp filters are loaded, or be > in the format of: > > where ALLOW means the cache is guaranteed to allow the syscall, > and filter means the cache will pass the syscall to the BPF filter. > > For the docker default profile on x86_64 it looks like: > x86_64 0 ALLOW > x86_64 1 ALLOW > x86_64 2 ALLOW > x86_64 3 ALLOW > [...] > x86_64 132 ALLOW > x86_64 133 ALLOW > x86_64 134 FILTER > x86_64 135 FILTER > x86_64 136 FILTER > x86_64 137 ALLOW > x86_64 138 ALLOW > x86_64 139 FILTER > x86_64 140 ALLOW > x86_64 141 ALLOW > [...] > > This file is guarded by CONFIG_SECCOMP_CACHE_DEBUG with a default > of N because I think certain users of seccomp might not want the > application to know which syscalls are definitely usable. For > the same reason, it is also guarded by CAP_SYS_ADMIN. > > Suggested-by: Jann Horn > Link: https://lore.kernel.org/lkml/CAG48ez3Ofqp4crXGksLmZY6=fGrF_tWyUCg7PBkAetvbbOPeOA@mail.gmail.com/ > Signed-off-by: YiFei Zhu > --- > arch/Kconfig | 24 ++++++++++++++ > arch/x86/Kconfig | 1 + > arch/x86/include/asm/seccomp.h | 3 ++ > fs/proc/base.c | 6 ++++ > include/linux/seccomp.h | 5 +++ > kernel/seccomp.c | 59 ++++++++++++++++++++++++++++++++++ > 6 files changed, 98 insertions(+) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 21a3675a7a3a..85239a974f04 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -471,6 +471,15 @@ config HAVE_ARCH_SECCOMP_FILTER > results in the system call being skipped immediately. > - seccomp syscall wired up > > +config HAVE_ARCH_SECCOMP_CACHE > + bool > + help > + An arch should select this symbol if it provides all of these things: > + - all the requirements for HAVE_ARCH_SECCOMP_FILTER > + - SECCOMP_ARCH_NATIVE > + - SECCOMP_ARCH_NATIVE_NR > + - SECCOMP_ARCH_NATIVE_NAME > + > [...] > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 1ab22869a765..1a807f89ac77 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -150,6 +150,7 @@ config X86 > select HAVE_ARCH_COMPAT_MMAP_BASES if MMU && COMPAT > select HAVE_ARCH_PREL32_RELOCATIONS > select HAVE_ARCH_SECCOMP_FILTER > + select HAVE_ARCH_SECCOMP_CACHE > select HAVE_ARCH_THREAD_STRUCT_WHITELIST > select HAVE_ARCH_STACKLEAK > select HAVE_ARCH_TRACEHOOK HAVE_ARCH_SECCOMP_CACHE isn't used any more. I think this was left over from before. -- Kees Cook