Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186Ab1BCW0s (ORCPT ); Thu, 3 Feb 2011 17:26:48 -0500 Received: from eru.sfritsch.de ([188.40.99.202]:57386 "EHLO eru.sfritsch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561Ab1BCW0r (ORCPT ); Thu, 3 Feb 2011 17:26:47 -0500 X-Greylist: delayed 1200 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Feb 2011 17:26:47 EST From: Stefan Fritsch To: Frederic Weisbecker , Eric Paris , Ingo Molnar Subject: Re: Using ftrace/perf as a basis for generic seccomp Date: Thu, 3 Feb 2011 23:06:33 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.32-5-amd64; KDE/4.4.5; x86_64; ; ) Cc: Masami Hiramatsu , Eric Paris , linux-kernel@vger.kernel.org, agl@google.com, tzanussi@gmail.com, Jason Baron , Mathieu Desnoyers , 2nddept-manager@sdl.hitachi.co.jp, Steven Rostedt , Arnaldo Carvalho de Melo , Peter Zijlstra , Thomas Gleixner References: <1294867725.3237.230.camel@localhost.localdomain> <1296665124.3145.17.camel@localhost.localdomain> <20110203190643.GC1769@nowhere> In-Reply-To: <20110203190643.GC1769@nowhere> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201102032306.34251.sf@sfritsch.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3499 Lines: 78 Hi, On Thursday 03 February 2011, Frederic Weisbecker wrote: > I think you won't work with trace events, so you need to make the > filtering code more tracing-agnostic. > > But I think it's quite workable and shouldn't be too hard to split > that into a filtering backend. Many parts are already pretty > standalone. > > Also I suspect the tracepoints are not what you need. Or may be > they are. But as Masami said, the syscall tracepoint is called > late. It's workable though. The other problem is that preemption > is disabled when tracepoints are called, which is probably not > what you want. One day I think we'll need to unify the tracepoints > and notifier code but until then, better keep tracepoints for > tracing. > > Now once you have the filtering code more generic, you still > need an arch backend to map register contents and layout into > syscall arguments name and type. On top of which you can finally > use the filtering code. For that you can use, again, some code we > use for tracing, which are syscalls metadata: informations > generated on build time that have syscalls fields and type. > And that also needs to be split up, but it's more trivial > than the filtering part. AFAICS the infrastructure for tracing and metadata of compat syscalls is also still missing. That would need to be added, too. Jason Baron and Ian Munsie have worked on this in mid 2010, but I don't know about the current status. Considering that all this is still quite a bit of work and that the initial suggestion by Adam Langley happened nearly two years ago, maybe a two step approach would be better: Integrate a seccomp mode 2 now, which only supports a bitmask of bitmaps and no filtering. Then, when the infrastructure for the filtering is finished, add a seccomp mode 3 with support for filtering. This would give something in the very near future that is way more usable than seccomp mode 1. I think only the following adjustments would need to be made to Adam Langley's patch: - only allow syscalls in the mode (non-compat/compat) that the prctl call was made in - deny exec of setuid/setgid binaries - deny exec of binaries with filesystem capabilities What do you think of this proposal? I have a patch lying around somewhere that already does the first two of these. BTW, given that the compat syscall layer tends to have security bugs, being able to disable compat syscalls per process would already have some value on its own. Is there a way to do this by disabling the int 80 and compat sysenter()/syscall() vectors per process? In my patch I did a check in secure_computing(), which is of course less elegant. > Note for now, filtering + syscalls metadata only works on top > of raw arguments value. Syscalls metadata don't know much > about type semantics and won't help you to dereference > syscall argument pointers. Only raw syscall parameter values. > Similarly, the filtering code can't evaluate pointer dereferencing > expression evaluation, only direct values comprehension. Pointer dereferencing at syscall entry must be avoided for seccomp anyway, or there would be race conditions. Of course if the filtering points could be put after the final copy_form_user, it would be ok. Cheers, Stefan -- 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/