From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X47uf-0001Ut-3d for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:21:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X47uW-0002LM-2g for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:20:53 -0400 Received: from mail-qa0-x231.google.com ([2607:f8b0:400d:c00::231]:57046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X47uV-0002LG-UT for qemu-devel@nongnu.org; Mon, 07 Jul 2014 08:20:44 -0400 Received: by mail-qa0-f49.google.com with SMTP id w8so3330965qac.8 for ; Mon, 07 Jul 2014 05:20:43 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53BA9094.9080401@redhat.com> Date: Mon, 07 Jul 2014 14:20:36 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1404124096-21445-1-git-send-email-drysdale@google.com> <53B51E81.4090700@redhat.com> <20140703183927.GA1629@google.com> <53B651C5.80602@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 00/11] Adding FreeBSD's Capsicum security framework (part 1) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Drysdale Cc: Kees Cook , Greg Kroah-Hartman , Meredydd Luff , "linux-kernel@vger.kernel.org" , qemu-devel , LSM List , Alexander Viro , James Morris , Linux API Il 07/07/2014 12:29, David Drysdale ha scritto: >> I think that's more easily done by opening the file as O_RDONLY/O_WRONLY >> /O_RDWR. You could do it by running the file descriptor's seccomp-bpf >> program once per iocb with synthesized syscall numbers and argument >> vectors. > > Right, but generating the equivalent seccomp input environment for an > equivalent single-fd syscall is going to be subtle and complex (which > are worrying words to mention in a security context). And how many > other syscalls are going to need similar special-case processing? > (poll? select? send[m]msg? ...) Yeah, the difficult part is getting the right balance between: 1) limitations due to seccomp's impossibility to chase pointers (which is not something that can be lifted, as it's required for correctness) 2) subtlety and complexity of the resulting code. The problem stems when you have a single a single syscall operating on multiple file descriptors. So for example among the cases you mention poll and select are problematic; sendm?msg are not. They would be if Capsicum had a capability for SCM_RIGHTS file descriptor passing, but I cannot find it. But then you also have to strike the right balance between a complete solution and an overengineered one. For example, even though poll and select are problematic, I wonder what would really the point be in blocking them; poll/select are level-triggered, and calling them should be idempotent as far as the file descriptor is concerned. If you want to prevent a process/thread from issuing blocking system calls, but you'd do that with a per-process filter, not with per-file-descriptor filters or capabilities. > Capsicum capabilities are associated with the file descriptor (a la > F_GETFD), not the open file itself -- different FDs with different > associated rights can map to the same underlying open file. Good to know, thanks. I suppose you have testcases that cover this. Paolo