Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754454AbaGKXCs (ORCPT ); Fri, 11 Jul 2014 19:02:48 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:51683 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754212AbaGKXCr (ORCPT ); Fri, 11 Jul 2014 19:02:47 -0400 MIME-Version: 1.0 In-Reply-To: <4fa3f909-9bf8-447d-99de-ce93ebc6d27e@email.android.com> References: <13645924.XpBzvDVILV@sifl> <1405103466.2357.5.camel@flatline.rdu.redhat.com> <1433620.8yKm3TZIWM@sifl> <4fa3f909-9bf8-447d-99de-ce93ebc6d27e@email.android.com> Date: Fri, 11 Jul 2014 16:02:46 -0700 X-Google-Sender-Auth: oi2R1Kh-RM30fpSwkfm4tzOeoU8 Message-ID: Subject: Re: [PATCH 2/3] [RFC] seccomp: give BPF x32 bit when restoring x32 filter From: Kees Cook To: "H. Peter Anvin" Cc: Paul Moore , Eric Paris , Richard Guy Briggs , linux-audit@redhat.com, LKML , Al Viro , Will Drewry , Andy Lutomirski , Chris Evans , Serge Hallyn , Tyler Hicks , stgraber@ubuntu.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 11, 2014 at 3:55 PM, H. Peter Anvin wrote: > It includes the X32 bit. If the uapi for __NR_* includes the x32 bit, then that's what seccomp filters must be seeing. Building seccomp filters is documented to use the __NR_* values. -Kees > > On July 11, 2014 3:52:42 PM PDT, Kees Cook wrote: >>On Fri, Jul 11, 2014 at 3:48 PM, Kees Cook >>wrote: >>> On Fri, Jul 11, 2014 at 12:36 PM, Paul Moore >>wrote: >>>> Anyway, getting back to the idea I mentioned earlier ... as many of >>you may >>>> know, Kees (added to the CC line) is working on some seccomp filter >>>> improvements which will result in a new seccomp syscall. Perhaps >>one way >>>> forward is to preserve everything as it is currently with the >>prctl() >>>> interface, but with the new seccomp() based interface we fixup x32 >>and use the >>>> new AUDIT_ARCH_X32 token? It might result in a bit of ugliness in >>some of the >>>> kernel, but I don't think it would be too bad, and I think it would >>address >>>> both our concerns. >>> >>> Adding AUDIT_ARCH_X32: yes please. (On that note, the comment "/* >>Both >>> x32 and x86_64 are considered "64-bit". */" should be changed...) >>> >>> Just so I understand: currently x86_64 and x32 both present as >>> AUDIT_ARCH_X86_64. The x32 syscalls are seen as in a different range >>> (due to the set high bit). >>> >>> The seccomp used in Chrome, Chrome OS, and vsftpd should all only do >>> whitelisting by both arch and syscall, so adding AUDIT_ARCH_X32 >>> without setting __X32_SYSCALL_BIT would be totally fine (it would >>> catch the arch instead of the syscall). This sounds similar to how >>> libseccomp is doing things, so these should be fine. >> >>I should clarify: seccomp expects to find whatever is sent as the >>syscall nr... as in the __NR_read used like this: >> >> BPF_STMT(BPF_LD+BPF_W+BPF_ABS, >> offsetof(struct seccomp_data, nr)), >> BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_read, 0, 1), >> BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL), >> BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), >> >>Are there native x32 users yet? What does __NR_read resolve to via the >>uapi on a native x32 userspace? >> >>-Kees >> >>> The only project I know of doing blacklisting is lxc, and Eric's >>> example looks a lot like a discussion I saw with lxc and init_module. >>> :) So it sounds like we can get this right there. >>> >>> I'd like to avoid carrying a delta on filter logic based on the prctl >>> vs syscall entry. Can we find any userspace filters being used that a >>> "correct" fix would break? (If so, then yes, we'll need to do this >>> proposed "via prctl or via syscall?" change.) >>> >>> -Kees >>> >>> -- >>> Kees Cook >>> Chrome OS Security > > -- > Sent from my mobile phone. Please pardon brevity and lack of formatting. -- Kees Cook Chrome OS Security -- 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/