Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753551AbaFMQ3b (ORCPT ); Fri, 13 Jun 2014 12:29:31 -0400 Received: from mail-ig0-f178.google.com ([209.85.213.178]:59768 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753037AbaFMQ31 (ORCPT ); Fri, 13 Jun 2014 12:29:27 -0400 MIME-Version: 1.0 In-Reply-To: References: <9e11cd988a0f120606e37b5e275019754e2774da.1402517933.git.luto@amacapital.net> <5398D59A.3030900@zytor.com> <5398D7B4.5000303@zytor.com> Date: Fri, 13 Jun 2014 11:29:26 -0500 Message-ID: Subject: Re: [RFC 5/5] x86,seccomp: Add a seccomp fastpath From: Will Drewry To: Kees Cook Cc: Andy Lutomirski , "H. Peter Anvin" , Alexei Starovoitov , "linux-kernel@vger.kernel.org" , Oleg Nesterov , X86 ML , "linux-arm-kernel@lists.infradead.org" , linux-mips@linux-mips.org, linux-arch , LSM List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 11, 2014 at 5:32 PM, Kees Cook wrote: > On Wed, Jun 11, 2014 at 3:28 PM, Andy Lutomirski wrote: >> On Wed, Jun 11, 2014 at 3:27 PM, H. Peter Anvin wrote: >>> On 06/11/2014 03:22 PM, Andy Lutomirski wrote: >>>> On Wed, Jun 11, 2014 at 3:18 PM, H. Peter Anvin wrote: >>>>> On 06/11/2014 02:56 PM, Andy Lutomirski wrote: >>>>>> >>>>>> 13ns is with the simplest nonempty filter. I hope that empty filters >>>>>> don't work. >>>>>> >>>>> >>>>> Why wouldn't they? >>>> >>>> Is it permissible to fall off the end of a BPF program? I'm getting >>>> EINVAL trying to install an actual empty filter. The filter I tested >>>> with was: >>>> >>> >>> What I meant was that there has to be a well-defined behavior for the >>> program falling off the end anyway, and that that should be preserved. >>> >>> I guess it is possible to require that all code paths must provably >>> reach a termination point. >>> >> >> Dunno. I haven't ever touched any of the actual BPF code. This whole >> patchset only changes the code that invokes the BPF evaluator. > > Yes, this is how BPF works: runs to the end or exit early. With > seccomp BPF specifically, the return value defaults to kill the > process. If a filter was missing (NULL), or empty, or didn't > explicitly return with a new value, the default (kill) should be > taken. Yup - this is just a property of BPF (and a nice one :) On seccomp_attach_filter this check fires: if (fprog->len == 0 || fprog->len > BPF_MAXINSNS) return -EINVAL; As well as in sk_chk_filter: if (flen == 0 || flen > BPF_MAXINSNS) return -EINVAL; And: /* last instruction must be a RET code */ switch (filter[flen - 1].code) { case BPF_S_RET_K: case BPF_S_RET_A: return check_load_and_stores(filter, flen); } cheers! will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/