From patchwork Fri Jul 18 22:32:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 4588131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E10B19F1D6 for ; Fri, 18 Jul 2014 22:34:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B2EC20160 for ; Fri, 18 Jul 2014 22:34:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EE7D2010C for ; Fri, 18 Jul 2014 22:34:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8Ghw-00056Z-E6; Fri, 18 Jul 2014 22:32:52 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X8Ght-0004yl-PG for linux-arm-kernel@lists.infradead.org; Fri, 18 Jul 2014 22:32:50 +0000 Received: by mail-pa0-f46.google.com with SMTP id lj1so6246532pab.33 for ; Fri, 18 Jul 2014 15:32:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EaJnqVjwsKq2SIMr8Jg1Vllx0lnBouK3/5FMaDQ3kdY=; b=iwTFQq6NDASNkcAD8vE7UJCF7EfHjeNBQkswK7MXOr/koGx5qLAUeSzMGhVWXlVUNl ytSaOz6FN5IQlBZPLRAyHecK90xLe3cLE8O6qQNAGpbnmjxGnmdkyCupBLDnljmfErQu L6yswZYsDufXLJedBOFD6eYAvz86P4isqDbcDqFU3cAEfL6+rCZYNpkg0N6cayJPqXMs oQ7AD29eNVso7fWJR8aMd2ZdV55rBzFnGu8nailMvvDnI+fH3mbN056jxZhwvrepdUqF w9QCxO3Q7HjOMvpPWt6rsMMkOrt11Rksvv+hPGSbueVbY58vVMH4lQZH+0FqQ95SRsV4 npug== X-Gm-Message-State: ALoCoQltpuW1P4/jY9GsGK+E07QxtcwhUKmPkcVz0X4Q0Uh2q25z5brqlvC3V+lHr1q3i8vmlVF4 X-Received: by 10.66.182.132 with SMTP id ee4mr8773600pac.64.1405722748140; Fri, 18 Jul 2014 15:32:28 -0700 (PDT) Received: from localhost (50-76-60-73-ip-static.hfc.comcastbusiness.net. [50.76.60.73]) by mx.google.com with ESMTPSA id ry10sm27422663pab.38.2014.07.18.15.32.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 15:32:26 -0700 (PDT) From: Andy Lutomirski To: linux-kernel@vger.kernel.org, Kees Cook , Will Drewry Subject: [PATCH v2 8/7] seccomp: Document two-phase seccomp and arch-provided seccomp_data Date: Fri, 18 Jul 2014 15:32:00 -0700 Message-Id: <0a79fe55572054ac3b533548481ad1d2b6104eb6.1405722642.git.luto@amacapital.net> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140718_153249_848134_11B99744 X-CRM114-Status: GOOD ( 11.53 ) X-Spam-Score: -0.7 (/) Cc: linux-arch@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, Oleg Nesterov , Andy Lutomirski , linux-security-module@vger.kernel.org, hpa@zytor.com, linux-arm-kernel@lists.infradead.org, Alexei Starovoitov X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The description of how arches should implement seccomp filters was still strictly correct, but it failed to describe the newly available optimizations. Signed-off-by: Andy Lutomirski --- I lost this somehow. Here it as an an extra patch. If I end up sending a v3, I'll fold it in. arch/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 0eae9df..05d7a8a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -323,6 +323,17 @@ config HAVE_ARCH_SECCOMP_FILTER results in the system call being skipped immediately. - seccomp syscall wired up + For best performance, an arch should use seccomp_phase1 and + seccomp_phase2 directly. It should call seccomp_phase1 for all + syscalls if TIF_SECCOMP is set, but seccomp_phase1 does not + need to be called from a ptrace-safe context. It must then + call seccomp_phase2 if seccomp_phase1 returns anything other + than SECCOMP_PHASE1_OK or SECCOMP_PHASE1_SKIP. + + As an additional optimization, an arch may provide seccomp_data + directly to seccomp_phase1; this avoids multiple calls + to the syscall_xyz helpers for every syscall. + config SECCOMP_FILTER def_bool y depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET