Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754043AbcKPOhz (ORCPT ); Wed, 16 Nov 2016 09:37:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932664AbcKPOht (ORCPT ); Wed, 16 Nov 2016 09:37:49 -0500 Date: Wed, 16 Nov 2016 08:37:46 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: Vince Weaver , "linux-kernel@vger.kernel.org" , Ingo Molnar , Arnaldo Carvalho de Melo , "davej@codemonkey.org.uk" , "dvyukov@google.com" , Stephane Eranian Subject: Re: perf: fuzzer KASAN unwind_get_return_address Message-ID: <20161116143746.zoxdxrfqvmx35wln@treble> References: <20161115185756.GL3142@twins.programming.kicks-ass.net> <20161115205748.xtroftp55igs55bz@treble> <20161116130337.GT3142@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161116130337.GT3142@twins.programming.kicks-ass.net> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 16 Nov 2016 14:37:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8676 Lines: 228 On Wed, Nov 16, 2016 at 02:03:37PM +0100, Peter Zijlstra wrote: > On Tue, Nov 15, 2016 at 02:57:48PM -0600, Josh Poimboeuf wrote: > > Would you mind posting a disassembly of unwind_get_return_address()? > > Any idea how recreatable it is? (In particular I'd be interested in > > seeing this dump with the latest unwinder improvements in the -tip tree, > > which dump the pt_regs associated with an interrupt.) > > Fairly reproducable it seems, doesn't seem to include pt_regs dumps > though :/ > > tip/master as of this morning. Thanks. This is actually a different issue than the one reported by Vince. In this case FRAME_POINTER is disabled, so it uses the "guess" unwinder which scans every address on the stack, looking for text addresses. So the kasan errors are expected. (The missing pt_regs are also expected: the guess unwinder doesn't show them.) I'll work up a patch to fix this. I still have no idea what's causing Vince's bug in the frame pointer unwinder. > 3================================================================== > 3BUG: KASAN: stack-out-of-bounds in unwind_next_frame+0x1ba/0x1f0 at addr ffff88042fc87be0 > 3Read of size 8 by task swapper/28/0 > 0page:ffffea0010bf21c0 count:1 mapcount:0 mapping: (null) index:0x0c > 0flags: 0x2ffff8000000400(reserved) > 1page dumped because: kasan: bad access detected > dCPU: 28 PID: 0 Comm: swapper/28 Not tainted 4.9.0-rc5-00530-gd8866fc-dirty #2 > dHardware name: Intel Corporation S2600GZ/S2600GZ, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013 > dCall Trace: > d > d ? dump_stack+0x5e/0x89 > d ? kasan_report_error+0x4a5/0x4d0 > d ? __asan_report_load8_noabort+0x45/0x50 > d ? __kernel_text_address+0x20/0xa0 > d ? unwind_next_frame+0x1ba/0x1f0 > d ? unwind_next_frame+0x1ba/0x1f0 > d ? perf_callchain_kernel+0x33c/0x540 > d ? arch_perf_update_userpage+0x340/0x340 > d ? get_perf_callchain+0x24d/0x610 > d ? put_callchain_buffers+0x50/0x50 > d ? number+0x653/0x830 > d ? perf_callchain+0x126/0x190 > d ? perf_prepare_sample+0x720/0x1010 > d ? perf_event_output_forward+0x81/0xf0 > d ? perf_prepare_sample+0x1010/0x1010 > d ? pointer+0x880/0x880 > d ? perf_event_update_userpage+0x16/0x730 > d ? __perf_event_overflow+0x1a0/0x510 > d ? intel_pmu_handle_irq+0x34b/0xa90 > d ? intel_pmu_save_and_restart+0xd0/0xd0 > d ? acpi_os_read_memory+0x205/0x23c > d ? format_decode+0xc5/0x7a0 > d ? vunmap_page_range+0x26a/0x400 > d ? ghes_copy_tofrom_phys+0x141/0x270 > d ? ghes_read_estatus+0x112/0x5a0 > d ? ghes_copy_tofrom_phys+0x270/0x270 > d ? early_printk+0xa4/0xd0 > d ? devkmsg_sysctl_set_loglvl+0x160/0x160 > d ? perf_event_nmi_handler+0x28/0x40 > d ? nmi_handle+0xa1/0x250 > d ? default_do_nmi+0x61/0x170 > d ? do_nmi+0x191/0x200 > d ? end_repeat_nmi+0x1a/0x1e > d ? format_decode+0xc5/0x7a0 > d ? format_decode+0xc5/0x7a0 > d ? format_decode+0xc5/0x7a0 > d > d > d ? vsnprintf+0xfc/0x15e0 > d ? pointer+0x880/0x880 > d ? x86_pmu_enable_all+0x1c0/0x1c0 > d ? vscnprintf+0x9/0x30 > d ? early_vprintk+0xb0/0x130 > d ? trace_raw_output_console+0x160/0x160 > d ? memcpy+0x34/0x50 > d ? x86_pmu_commit_txn+0x180/0x260 > d ? events_sysfs_show+0xb0/0xb0 > d ? save_stack+0x33/0xb0 > d ? hrtimer_init+0x120/0x120 > d ? timerqueue_del+0x62/0x140 > d ? perf_event_update_userpage+0x16/0x730 > d ? perf_event_update_userpage+0x16/0x730 > d ? x86_perf_event_set_period+0x239/0x450 > d ? perf_event_update_userpage+0x16/0x730 > d ? x86_pmu_enable+0x5f7/0xaa0 > d ? printk+0xb6/0xef > d ? printk_emit+0xa0/0xa0 > d ? _raw_spin_unlock_irqrestore+0x42/0x70 > d ? ___ratelimit+0x1e4/0x3f0 > d ? irq_work_run_list+0xa1/0xf0 > d ? irq_work_run+0x14/0x40 > d ? smp_call_function_single_interrupt+0x60/0x80 > d ? call_function_single_interrupt+0x89/0x90 > d > d ? cpuidle_enter_state+0x113/0x780 > d ? cpuidle_enter_state+0x10e/0x780 > d ? cpu_load_update_nohz_stop+0x155/0x1b0 > d ? cpu_startup_entry+0x19a/0x2c0 > d ? start_cpu+0x5/0x14 > 3Memory state around the buggy address: > 3 ffff88042fc87a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 3 ffff88042fc87b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 3>ffff88042fc87b80: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 > 3 ^ > 3 ffff88042fc87c00: 00 f4 f4 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00 > 3 ffff88042fc87c80: 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 > 3================================================================== > > > 3================================================================== > 3BUG: KASAN: stack-out-of-bounds in unwind_next_frame+0x1ba/0x1f0 at addr ffff880424a97878 > 3Read of size 8 by task perf_fuzzer/3451 > 0page:ffffea001092a5c0 count:0 mapcount:0 mapping: (null) index:0x0c > 0flags: 0x2ffff8000000000() > 1page dumped because: kasan: bad access detected > dCPU: 28 PID: 3451 Comm: perf_fuzzer Not tainted 4.9.0-rc5-00530-gd8866fc-dirty #2 > dHardware name: Intel Corporation S2600GZ/S2600GZ, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013 > dCall Trace: > d ? dump_stack+0x5e/0x89 > d ? kasan_report_error+0x4a5/0x4d0 > d ? __asan_report_load8_noabort+0x45/0x50 > d ? __kernel_text_address+0x20/0xa0 > d ? unwind_next_frame+0x1ba/0x1f0 > d ? unwind_next_frame+0x1ba/0x1f0 > d ? perf_callchain_kernel+0x33c/0x540 > d ? arch_perf_update_userpage+0x340/0x340 > d ? get_perf_callchain+0x24d/0x610 > d ? put_callchain_buffers+0x50/0x50 > d ? ipv6_flowlabel_opt+0x1111/0x17d0 > d ? perf_log_itrace_start+0x3a0/0x3a0 > d ? cpumask_next_and+0x5a/0xa0 > d ? ktime_get_raw_fast_ns+0xd3/0x1e0 > d ? perf_callchain+0x126/0x190 > d ? perf_prepare_sample+0x720/0x1010 > d ? perf_event_output_forward+0x81/0xf0 > d ? perf_prepare_sample+0x1010/0x1010 > d ? perf_event_update_userpage+0x16/0x730 > d ? kasan_unpoison_shadow+0x31/0x40 > d ? get_page_from_freelist+0x52e/0x2310 > d ? perf_output_begin+0x3a1/0x9b0 > d ? cpu_clock_event_add+0x17/0x20 > d ? __perf_event_overflow+0x1a0/0x510 > d ? perf_swevent_overflow+0x156/0x1f0 > d ? perf_tp_event+0x3e8/0x5c0 > d ? perf_output_begin_backward+0x960/0x960 > d ? perf_tp_event_match.isra.85.part.86+0x140/0x140 > d ? __mark_inode_dirty+0x459/0xa50 > d ? legitimize_path.isra.28+0x6b/0x150 > d ? unlazy_walk+0x456/0x790 > d ? memset+0x1f/0x40 > d ? perf_trace_writeback_dirty_inode_template+0x3af/0x610 > d ? save_stack+0x33/0xb0 > d ? inode_congested+0x450/0x450 > d ? dput+0x1de/0x530 > d ? walk_component+0x2cc/0xdc0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? pick_link+0xbe0/0xbe0 > d ? inode_congested+0x450/0x450 > d ? __mark_inode_dirty+0x459/0xa50 > d ? proc_sys_setattr+0x84/0xb0 > d ? notify_change+0x4d6/0xc40 > d ? security_inode_need_killpriv+0x58/0x80 > d ? do_truncate+0xd7/0x160 > d ? file_open_root+0x1a0/0x1a0 > d ? path_openat+0x97f/0x3b30 > d ? vfs_rename+0x14a0/0x14a0 > d ? getname_flags+0xba/0x500 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? do_filp_open+0x175/0x230 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? may_open_dev+0xc0/0xc0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? save_stack+0x33/0xb0 > d ? do_sys_open+0x16d/0x310 > d ? SyS_write+0xab/0x160 > d ? filp_open+0x50/0x50 > d ? task_stopped_code+0xf0/0xf0 > d ? trace_hardirqs_on_thunk+0x1a/0x1c > d ? entry_SYSCALL_64_fastpath+0x18/0xa8 > 3Memory state around the buggy address: > 3 ffff880424a97700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 3 ffff880424a97780: 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3 f3 > 3>ffff880424a97800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 > 3 ^ > 3 ffff880424a97880: f1 f1 f1 04 f4 f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f3 > 3 ffff880424a97900: f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 > 3================================================================== -- Josh