lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 25 Jul 2011 10:05:26 +1000 From: Anton Blanchard <anton@...ba.org> To: David Ahern <dsahern@...il.com> Cc: Paul Mackerras <paulus@...ba.org>, linux-perf-users@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>, linuxppc-dev@...ts.ozlabs.org Subject: [PATCH] perf: powerpc: Disable pagefaults during callchain stack read Hi David, > > I am hoping someone familiar with PPC can help understand a panic > > that is generated when capturing callchains with context switch > > events. > > > > Call trace is below. The short of it is that walking the callchain > > generates a page fault. To handle the page fault the mmap_sem is > > needed, but it is currently held by setup_arg_pages. > > setup_arg_pages calls shift_arg_pages with the mmap_sem held. > > shift_arg_pages then calls move_page_tables which has a > > cond_resched at the top of its for loop. If the cond_resched() is > > removed from move_page_tables everything works beautifully - no > > panics. > > > > So, the question: is it normal for walking the stack to trigger a > > page fault on PPC? The panic is not seen on x86 based systems. > > Can anyone confirm whether page faults while walking the stack are > normal for PPC? We really want to use the context switch event with > callchains and need to understand whether this behavior is normal. Of > course if it is normal, a way to address the problem without a panic > will be needed. I talked to Ben about this last week and he pointed me at pagefault_disable/enable. Untested patch below. Anton -- We need to disable pagefaults when reading the stack otherwise we can lock up trying to take the mmap_sem when the code we are profiling already has a write lock taken. This will not happen for hardware events, but could for software events. Reported-by: David Ahern <dsahern@...il.com> Signed-off-by: Anton Blanchard <anton@...ba.org> Cc: <stable@...nel.org> --- Index: linux-powerpc/arch/powerpc/kernel/perf_callchain.c =================================================================== --- linux-powerpc.orig/arch/powerpc/kernel/perf_callchain.c 2011-07-25 09:54:27.296757427 +1000 +++ linux-powerpc/arch/powerpc/kernel/perf_callchain.c 2011-07-25 09:56:08.828367882 +1000 @@ -154,8 +154,12 @@ static int read_user_stack_64(unsigned l ((unsigned long)ptr & 7)) return -EFAULT; - if (!__get_user_inatomic(*ret, ptr)) + pagefault_disable(); + if (!__get_user_inatomic(*ret, ptr)) { + pagefault_enable(); return 0; + } + pagefault_enable(); return read_user_stack_slow(ptr, ret, 8); } @@ -166,8 +170,12 @@ static int read_user_stack_32(unsigned i ((unsigned long)ptr & 3)) return -EFAULT; - if (!__get_user_inatomic(*ret, ptr)) + pagefault_disable(); + if (!__get_user_inatomic(*ret, ptr)) { + pagefault_enable(); return 0; + } + pagefault_enable(); return read_user_stack_slow(ptr, ret, 4); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists