Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbaBXRay (ORCPT ); Mon, 24 Feb 2014 12:30:54 -0500 Received: from mail-qa0-f53.google.com ([209.85.216.53]:50957 "EHLO mail-qa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752722AbaBXRah (ORCPT ); Mon, 24 Feb 2014 12:30:37 -0500 Date: Mon, 24 Feb 2014 12:32:39 -0500 (EST) From: Vince Weaver To: Peter Zijlstra cc: Vince Weaver , "H. Peter Anvin" , Linux Kernel , Ingo Molnar , "H.J. Lu" , Steven Rostedt Subject: Re: perf_fuzzer compiled for x32 causes reboot In-Reply-To: <20140224172536.GD9987@twins.programming.kicks-ass.net> Message-ID: References: <53084317.4090304@zytor.com> <530AD71E.50800@zytor.com> <18f0cea3-7e3b-4477-b433-0269f3de976b@email.android.com> <20140224172536.GD9987@twins.programming.kicks-ass.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Feb 2014, Peter Zijlstra wrote: > On Mon, Feb 24, 2014 at 12:10:44PM -0500, Vince Weaver wrote: > > On Mon, 24 Feb 2014, H. Peter Anvin wrote: > > > > > On February 24, 2014 8:34:30 AM PST, Vince Weaver wrote: > > > >On Mon, 24 Feb 2014, Vince Weaver wrote: > > > > > > > >> Just touching the mmap page with a write of a single byte (it doesn't > > > > > > > >> matter where) is enough to trigger the bug. > > > > > > > >OK, investigating this more. > > > > > > > >perf_fuzzer-2971 [000] 154.944114: page_fault_user: > > > >address=0xf7729000 ip=0x41efab error_code=0x6 > > > >perf_fuzzer-2971 [000] 154.944118: function: > > > >ip=0xffffffff810d40e7 parent_ip=0xffffffff810d0840 > > > >perf_fuzzer-2971 [000] 154.944119: function: > > > >ip=0xffffffff812a91a5 parent_ip=0xffffffff81013ff5 > > > >perf_fuzzer-2971 [000] 154.944120: function: > > > >ip=0xffffffff8153837c parent_ip=0xffffffff81535432 > > > >perf_fuzzer-2971 [000] 154.944121: page_fault_kernel: > > > >address=0x22e0 ip=0xffffffff812a7d5c error_code=0x0 > > > > > Ok, so the obvious question is what is at that kernel address? > > > > > > > It's in copy_user_generic_string() > > rep movsq %ds:(%rsi),%es:(%rdi) > > > > And looking at the ftrace: > > perf_fuzzer-2979 [000] 161.475920: page_fault_user: address=__per_cpu_end ip=__per_cpu_end error_code=0x6 > > perf_fuzzer-2979 [000] 161.475922: function: perf_callchain > > perf_fuzzer-2979 [000] 161.475922: function: copy_from_user_nmi > > perf_fuzzer-2979 [000] 161.475923: function: trace_do_page_fault > > perf_fuzzer-2979 [000] 161.475924: page_fault_kernel: address=irq_stack_union ip=copy_user_generic_string error_code=0x0 > > > > What is likely happening is the user page fault is triggering > > code to do a "perf_callchain" dump, which is calling copy_from_user_nmi() > > which calls copy_user_generic_string() which is somehow getting the user > > RBP in the RDI register somehow? > > So that code very much relies on the 'recursive' NMI/iret magic from > Steve, patch 3f3c8b8c4b2a3 (and assorted fixes later). > > If CR2 is getting corrupted; 7fbb98c5cb075 seems relevant. > > Peter, does x32 have a slightly different ABI/calling convention that > would make any of these patches just slightly 'off'? I do note that perf_callchain_user(); Does fp = (void __user *)regs->bp; ... bytes = copy_from_user_nmi(&frame, fp, sizeof(frame)); And in my particular executable RBP has nothing to do with a frame pointer, but is instead being used as a general purpose register. Am I missing something here? Though in that case I'm not sure why this wouldn't be easier to trigger. Vince -- 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/