From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Drewry Subject: Re: [RFC,PATCH 1/2] seccomp_filters: system call filtering using BPF Date: Fri, 13 Jan 2012 13:01:25 -0600 Message-ID: References: <1326302710-9427-1-git-send-email-wad@chromium.org> <1326302710-9427-2-git-send-email-wad@chromium.org> <20120112162231.GA23960@redhat.com> <20120112172315.GA26295@redhat.com> <20120113173153.GA24273@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, keescook@chromium.org, john.johansen@canonical.com, serge.hallyn@canonical.com, coreyb@linux.vnet.ibm.com, pmoore@redhat.com, eparis@redhat.com, djm@mindrot.org, torvalds@linux-foundation.org, segoon@openwall.com, rostedt@goodmis.org, jmorris@namei.org, scarybeasts@gmail.com, avi@redhat.com, penberg@cs.helsinki.fi, viro@zeniv.linux.org.uk, luto@mit.edu, mingo@elte.hu, akpm@linux-foundation.org, khilman@ti.com, borislav.petkov@amd.com, amwang@redhat.com, ak@linux.intel.com, eric.dumazet@gmail.com, gregkh@suse.de, dhowells@redhat.com, daniel.lezcano@free.fr, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, olofj@chromium.org, mhalcrow@google.com, dlaor@redhat.com, Roland McGrath To: Oleg Nesterov Return-path: Received: from mail-bk0-f46.google.com ([209.85.214.46]:51936 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758785Ab2AMTB2 convert rfc822-to-8bit (ORCPT ); Fri, 13 Jan 2012 14:01:28 -0500 In-Reply-To: <20120113173153.GA24273@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Jan 13, 2012 at 11:31 AM, Oleg Nesterov wrote= : > On 01/12, Will Drewry wrote: >> >> On Thu, Jan 12, 2012 at 11:23 AM, Oleg Nesterov wr= ote: >> > On 01/12, Will Drewry wrote: >> >> >> >> On Thu, Jan 12, 2012 at 10:22 AM, Oleg Nesterov = wrote: >> >> >> + =A0 =A0 =A0*/ >> >> >> + =A0 =A0 regs =3D seccomp_get_regs(regs_tmp, ®s_size); >> >> > >> >> > Stupid question. I am sure you know what are you doing ;) and I= know >> >> > nothing about !x86 arches. >> >> > >> >> > But could you explain why it is designed to use user_regs_struc= t ? >> >> > Why we can't simply use task_pt_regs() and avoid the (costly) r= egsets? >> >> >> >> So on x86 32, it would work since user_regs_struct =3D=3D task_pt= _regs >> >> (iirc), but on x86-64 >> >> and others, that's not true. >> > >> > Yes sure, I meant that userpace should use pt_regs too. >> > >> >> If it would be appropriate to expose pt_regs to userspace, then I= 'd >> >> happily do so :) >> > >> > Ah, so that was the reason. But it is already exported? At least I= see >> > the "#ifndef __KERNEL__" definition in arch/x86/include/asm/ptrace= =2Eh. >> > >> > Once again, I am not arguing, just trying to understand. And I do = not >> > know if this definition is part of abi. >> >> I don't either :/ =A0My original idea was to operate on task_pt_regs= (current), >> but I noticed that PTRACE_GETREGS/SETREGS only uses the >> user_regs_struct. So I went that route. > > Well, I don't know where user_regs_struct come from initially. But > probably it is needed to allow to access the "artificial" things like > fs_base. Or perhaps this struct mimics the layout in the coredump. Not sure - added Roland whose name was on many of the files :) I just noticed that ptrace ABI allows pt_regs access using the register macros (PTRACE_PEEKUSR) and user_regs_struct access (PTRACE_GETREGS). But I think the latter is guaranteed to have a certain layout while the= macros for PEEKUSR can do post-processing fixup. (Which could be done in the bpf evaluator load_pointer() helper if needed.) >> I'd love for pt_regs to be fair game to cut down on the copying! > > Me too. I see no point in using user_regs_struct. I'll rev the change to use pt_regs and drop all the helper code. If no one says otherwise, that certainly seems ideal from a performance perspective, and I see pt_regs exported to userland along with ptrace abi register offset macros. Thanks! will -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html