Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753332AbaDORqx (ORCPT ); Tue, 15 Apr 2014 13:46:53 -0400 Received: from mail-lb0-f172.google.com ([209.85.217.172]:64801 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbaDORqu (ORCPT ); Tue, 15 Apr 2014 13:46:50 -0400 MIME-Version: 1.0 In-Reply-To: References: <1397502179-15029-1-git-send-email-dborkman@redhat.com> <534C4179.7070704@amacapital.net> <20140414.162452.1169041476405438694.davem@davemloft.net> From: Andy Lutomirski Date: Tue, 15 Apr 2014 10:46:29 -0700 Message-ID: Subject: Re: [PATCH] seccomp: fix populating a0-a5 syscall args in 32-bit x86 BPF To: Alexei Starovoitov Cc: David Miller , Daniel Borkmann , Network Development , "linux-kernel@vger.kernel.org" , Linus Torvalds , Eric Paris , James Morris , Kees Cook 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 Mon, Apr 14, 2014 at 11:31 PM, Alexei Starovoitov wrote: > On Mon, Apr 14, 2014 at 1:28 PM, Andy Lutomirski wrote: >> On Mon, Apr 14, 2014 at 1:24 PM, David Miller wrote: >>> From: Andy Lutomirski >>> Date: Mon, 14 Apr 2014 13:13:45 -0700 >>> >>>> I think this description is wrong. (unsigned long *) &sd->args[1] is >>>> the right location, at least on 32-bit little-endian architectures. >>> >>> It absolutely is not. >> >> Huh? It's a pointer to the right address, but the type is wrong. >> >> The changelog says "on 32-bit x86 (or any other 32bit arch), it would >> result in storing a0-a5 at wrong offsets in args[] member". Unless >> I'm mistaken, this is incorrect: a0-a5 are are the correct offsets, >> but they are stored with the wrong type, so the other bits in there >> are garbage. > > agree. your above description is more correct than the log. > We were focusing on the bug itself and the log came a bit misleading > as a result of multiple iterations back and forth between me and Daniel. > > also the log says: > "gcc is clever and optimizes the copy away in other cases, e.g. x86_64" > since we actually checked assembler, so the fix doesn't pessimize > 64-bit architectures :) > This function is in critical path for seccomp, so performance definitely > matters. Yeah, I'm not entirely sure what I was thinking when I wrote that part. The new code should actually be much better than the old code for weird architectures like ia-64. For reference, ia-64 uses the unwinder (!) to look up arguments, so the fewer times it gets invoked, the better. --Andy -- 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/