From mboxrd@z Thu Jan 1 00:00:00 1970 From: nschichan@freebox.fr (Nicolas Schichan) Date: Wed, 24 Apr 2013 17:52:34 +0200 Subject: [PATCH V2 1/3] seccomp: add generic code for jitted seccomp filters. In-Reply-To: <20130423164303.d2eb663c4a1becea4a185087@linux-foundation.org> References: <1363618233-6375-1-git-send-email-nschichan@freebox.fr> <1363618233-6375-2-git-send-email-nschichan@freebox.fr> <20130417145628.88058f0f3104ab9ae551ddd3@linux-foundation.org> <51752D98.8070709@freebox.fr> <20130423164303.d2eb663c4a1becea4a185087@linux-foundation.org> Message-ID: <5177FFC2.5020102@freebox.fr> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 04/24/2013 01:43 AM, Andrew Morton wrote: > On Mon, 22 Apr 2013 14:31:20 +0200 Nicolas Schichan wrote: >> Would including instead of in seccomp.h >> be an acceptable solution ? >> >> I have tried that and (with an additional forward declaration of struct >> sk_buff) an x86_64 "make clean; make allmodconfig" run finishes succesfully. >> >> If that's ok with you, I can resend the serie with that fix. > > It would be better to make the code and include tangle less complex, > rather than more complex. > > Did we really need to move the `struct seccomp_filter' definition into > the header file? afaict that wasn't really necessary - we can add a > few helper functions to kernel/seccomp.c and then have the remote code > treat seccomp_filter in an opaque fashion rather than directly poking > at its internals. Hi, I will resend a V3 of the patch serie with the accessors. > btw, what on earth is going on with seccomp_jit_free()? It does > disturbing undocumented typecasting and it punts the module_free into a > kernel thread for mysterious, undocumented and possibly buggy reasons. > > I realize it just copies bpf_jit_free(). The same observations apply there. The reason for this hack for both seccomp filters and socket filters is that {seccomp,bpf}_jit_free are called from a softirq. module_free() cannot be called directly from softirq, as it will in turn call vfree() which will BUG_ON() if in_interrupt() is non zero. So to call module_free(), it is therefore required to be in a process context, which is provided by the work struct. Here is the call stack for the socket filter case: [] (vfree+0x28/0x2c) from [] (bpf_jit_free+0x10/0x18) [] (bpf_jit_free+0x10/0x18) from [](sk_filter_release_rcu+0x10/0x1c) [] (sk_filter_release_rcu+0x10/0x1c) from [] (__rcu_process_callbacks+0x98/0xac) [] (__rcu_process_callbacks+0x98/0xac) from [] (rcu_process_callbacks+0x10/0x20) [] (rcu_process_callbacks+0x10/0x20) from [] (__do_softirq+0xbc/0x194) [] (__do_softirq+0xbc/0x194) from [] (run_ksoftirqd+0x40/0x64) [] (run_ksoftirqd+0x40/0x64) from [] (smpboot_thread_fn+0x150/0x15c) [] (smpboot_thread_fn+0x150/0x15c) from [] (kthread+0xa4/0xb0) [] (kthread+0xa4/0xb0) from [] (ret_from_fork+0x14/0x24) Here is the call stack for the seccomp filter case: [] (vfree+0x28/0x2c) from [] (put_seccomp_filter+0x6c/0x84) [] (put_seccomp_filter+0x6c/0x84) from [] (free_task+0x30/0x50) [] (free_task+0x30/0x50) from [] (__rcu_process_callbacks+0x98/0xac) [] (__rcu_process_callbacks+0x98/0xac) from [] (rcu_process_callbacks+0x10/0x20) [] (rcu_process_callbacks+0x10/0x20) from [] (__do_softirq+0xbc/0x194) [] (__do_softirq+0xbc/0x194) from [] (run_ksoftirqd+0x40/0x64) [] (run_ksoftirqd+0x40/0x64) from [] (smpboot_thread_fn+0x150/0x15c) [] (smpboot_thread_fn+0x150/0x15c) from [] (kthread+0xa4/0xb0) [] (kthread+0xa4/0xb0) from [] (ret_from_fork+0x14/0x24) Regards, -- Nicolas Schichan Freebox SAS