Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757368Ab3DXPwi (ORCPT ); Wed, 24 Apr 2013 11:52:38 -0400 Received: from ns.iliad.fr ([212.27.33.1]:41375 "EHLO ns.iliad.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756641Ab3DXPwh (ORCPT ); Wed, 24 Apr 2013 11:52:37 -0400 Message-ID: <5177FFC2.5020102@freebox.fr> Date: Wed, 24 Apr 2013 17:52:34 +0200 From: Nicolas Schichan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Andrew Morton CC: Serge Hallyn , Will Drewry , Kees Cook , linux-kernel@vger.kernel.org, Eric Paris , Mircea Gherzan , Al Viro , James Morris , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH V2 1/3] seccomp: add generic code for jitted seccomp filters. 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> In-Reply-To: <20130423164303.d2eb663c4a1becea4a185087@linux-foundation.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3597 Lines: 80 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 -- 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/