linux-mips
[Top] [All Lists]

Re: [PATCH v7 2/9] seccomp: split filter prep from check and apply

To: David Drysdale <drysdale@google.com>
Subject: Re: [PATCH v7 2/9] seccomp: split filter prep from check and apply
From: Kees Cook <keescook@chromium.org>
Date: Fri, 27 Jun 2014 11:45:23 -0700
Cc: LKML <linux-kernel@vger.kernel.org>, Andy Lutomirski <luto@amacapital.net>, Alexei Starovoitov <ast@plumgrid.com>, "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, Daniel Borkmann <dborkman@redhat.com>, Oleg Nesterov <oleg@redhat.com>, Will Drewry <wad@chromium.org>, Julien Tinnes <jln@chromium.org>, Linux API <linux-api@vger.kernel.org>, "x86@kernel.org" <x86@kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, linux-mips@linux-mips.org, linux-arch <linux-arch@vger.kernel.org>, linux-security-module <linux-security-module@vger.kernel.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=3P09+TtHyb9MDetCx+TCyh3w/w1Wo9MkGlneGr0Rzbc=; b=MQ+5sCqpBzDibZQVV5W3wH/b8i61B/Zib7oaGwTJyJ5ynhfnp9m9A3zx4di58eR/sA d+c+pLIetpFC0p/Fzi3mUqeSEzzbGFd5ZVyvt+4uxzDEgKvECWNDREAtbT3xg+ciT8Pz kvkQol5ZBG2djOIvFasoqsAPXaPBO+X5DZT3fhUxTfjG831sghHOLg/DjBstpNa+bqtI LwN6gQjM//BoCE40Xm3+m3l2VWtdtfpZyuBBQ6NrVNlXSB1aKUw5QZ1kjdLCfWT0aoNS 6fXMc6KSuo9/GskxSdtY8teSuS8BJb5wJOqChFxl6PIQ0Gua49dumQVzLKzhE96JtJPv pgRw==
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=3P09+TtHyb9MDetCx+TCyh3w/w1Wo9MkGlneGr0Rzbc=; b=KHUZvUi9r6cqUJwLkgnq1lrzEjZFAX7XrbazADixvZGY+ODPeqKFEEIcyOuHXL6aD+ 0gbi+CgkHp1GgDyHfo0EZtnrUWVB7dvPBzgqln3vKhjZFhcB7OaaiIy4lVG1YK220nOS TYJulU+JpV46YVrGw3a57twl3BYOLMhtOZEIY=
In-reply-to: <20140626123710.GA16204@google.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1403560693-21809-1-git-send-email-keescook@chromium.org> <1403560693-21809-3-git-send-email-keescook@chromium.org> <20140626123710.GA16204@google.com>
Sender: linux-mips-bounce@linux-mips.org
On Thu, Jun 26, 2014 at 5:37 AM, David Drysdale <drysdale@google.com> wrote:
> On Mon, Jun 23, 2014 at 02:58:06PM -0700, Kees Cook wrote:
>> In preparation for adding seccomp locking, move filter creation away
>> from where it is checked and applied. This will allow for locking where
>> no memory allocation is happening. The validation, filter attachment,
>> and seccomp mode setting can all happen under the future locks.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>>  kernel/seccomp.c |   97 
>> +++++++++++++++++++++++++++++++++++++-----------------
>>  1 file changed, 67 insertions(+), 30 deletions(-)
>>
>> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
>> index afb916c7e890..edc8c79ed16d 100644
>> --- a/kernel/seccomp.c
>> +++ b/kernel/seccomp.c
>> @@ -515,6 +551,7 @@ static long seccomp_set_mode(unsigned long seccomp_mode, 
>> char __user *filter)
>>       current->seccomp.mode = seccomp_mode;
>>       set_thread_flag(TIF_SECCOMP);
>>  out:
>> +     seccomp_filter_free(prepared);
>>       return ret;
>>  }
>
> I think this needs to be inside #ifdef CONFIG_SECCOMP_FILTER to match
> the definition of seccomp_filter_free:
>
> ../kernel/seccomp.c:554:2: error: implicit declaration of function 
> ‘seccomp_filter_free’ [-Werror=implicit-function-declaration]

Thanks for catching that! I've ended up rearranging the patch series
so the prepare/attach split happens after I've split the set_mode
functions now, so I've managed to avoid this condition now. :)

-Kees

-- 
Kees Cook
Chrome OS Security

<Prev in Thread] Current Thread [Next in Thread>