Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 28 Feb 2012 11:18:26 -0600
From: Will Drewry <wad@...omium.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org, 
	linux-doc@...r.kernel.org, kernel-hardening@...ts.openwall.com, 
	netdev@...r.kernel.org, x86@...nel.org, arnd@...db.de, davem@...emloft.net, 
	hpa@...or.com, mingo@...hat.com, peterz@...radead.org, rdunlap@...otime.net, 
	mcgrathr@...omium.org, tglx@...utronix.de, luto@....edu, eparis@...hat.com, 
	serge.hallyn@...onical.com, djm@...drot.org, scarybeasts@...il.com, 
	indan@....nu, pmoore@...hat.com, akpm@...ux-foundation.org, corbet@....net, 
	eric.dumazet@...il.com, markus@...omium.org, coreyb@...ux.vnet.ibm.com, 
	keescook@...omium.org
Subject: Re: [PATCH v11 06/12] seccomp: add system call filtering using BPF

On Tue, Feb 28, 2012 at 9:13 AM, Oleg Nesterov <oleg@...hat.com> wrote:
> On 02/27, Will Drewry wrote:
>>
>> On Mon, Feb 27, 2012 at 11:09 AM, Oleg Nesterov <oleg@...hat.com> wrote:
>>
>> >> +static long seccomp_attach_filter(struct sock_fprog *fprog)
>> >> +{
>> >> +     struct seccomp_filter *filter;
>> >> +     unsigned long fp_size = fprog->len * sizeof(struct sock_filter);
>> >> +     long ret;
>> >> +
>> >> +     if (fprog->len == 0 || fprog->len > BPF_MAXINSNS)
>> >> +             return -EINVAL;
>> >
>> > OK, this limits the memory PR_SET_SECCOMP can use.
>> >
>> > But,
>> >
>> >> +     /*
>> >> +      * If there is an existing filter, make it the prev and don't drop its
>> >> +      * task reference.
>> >> +      */
>> >> +     filter->prev = current->seccomp.filter;
>> >> +     current->seccomp.filter = filter;
>> >> +     return 0;
>> >
>> > this doesn't limit the number of filters, looks like a DoS.
>> >
>> > What if the application simply does prctl(PR_SET_SECCOMP, dummy_filter)
>> > in an endless loop?
>>
>> It consumes a massive amount of kernel memory and, maybe, the OOM
>> killer gives it a boot :)
>
> may be ;) but most probably oom-killer kills another innocent task,
> this memory is not accounted.
>
>> I wasn't sure what the normal convention was for avoiding memory
>> consumption by user processes. Should I just add a sysctl
>
> Perhaps we can add a sysctl later, but personally I think that we
> can start with some "arbitrary" #define BPF_MAXFILTERS.

Sounds good - I'll wire something like this up in the next round.

>> and a
>> per-task counter for the max number of filters?
>
> Do we really need the counter? attach_filter is not the fast path,
> perhaps seccomp_attach_filter() could simply iterate the chain and
> count the number?
>
> In any case, if this hurts perfomance-wise then seccomp_run_filters()
> has even more problems.
>
>> I'm fine doing whatever makes sense here.
>
> I am fine either way too.
>
> Oleg.
>

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.