From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753544AbbGaOBH (ORCPT ); Fri, 31 Jul 2015 10:01:07 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57437 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753485AbbGaOBD (ORCPT ); Fri, 31 Jul 2015 10:01:03 -0400 Date: Fri, 31 Jul 2015 07:00:29 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: luto@amacapital.net, mingo@kernel.org, panand@redhat.com, peterz@infradead.org, hpa@zytor.com, srikar@linux.vnet.ibm.com, oleg@redhat.com, arapov@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: hpa@zytor.com, srikar@linux.vnet.ibm.com, peterz@infradead.org, luto@amacapital.net, panand@redhat.com, mingo@kernel.org, oleg@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, arapov@gmail.com In-Reply-To: <20150721134023.GA4776@redhat.com> References: <20150721134023.GA4776@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] uprobes: Change prepare_uretprobe() to (try to) flush the dead frames Git-Commit-ID: a5b7e1a89b820f2b9b23634ca4c59b555e8d9a0d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a5b7e1a89b820f2b9b23634ca4c59b555e8d9a0d Gitweb: http://git.kernel.org/tip/a5b7e1a89b820f2b9b23634ca4c59b555e8d9a0d Author: Oleg Nesterov AuthorDate: Tue, 21 Jul 2015 15:40:23 +0200 Committer: Ingo Molnar CommitDate: Fri, 31 Jul 2015 10:38:05 +0200 uprobes: Change prepare_uretprobe() to (try to) flush the dead frames Change prepare_uretprobe() to flush the !arch_uretprobe_is_alive() return_instance's. This is not needed correctness-wise, but can help to avoid the failure caused by MAX_URETPROBE_DEPTH. Note: in this case arch_uretprobe_is_alive() can be false positive, the stack can grow after longjmp(). Unfortunately, the kernel can't 100% solve this problem, but see the next patch. Tested-by: Pratyush Anand Signed-off-by: Oleg Nesterov Acked-by: Srikar Dronamraju Acked-by: Anton Arapov Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20150721134023.GA4776@redhat.com Signed-off-by: Ingo Molnar --- kernel/events/uprobes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 93d939c8..7e61c8c 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1511,6 +1511,16 @@ static unsigned long get_trampoline_vaddr(void) return trampoline_vaddr; } +static void cleanup_return_instances(struct uprobe_task *utask, struct pt_regs *regs) +{ + struct return_instance *ri = utask->return_instances; + while (ri && !arch_uretprobe_is_alive(ri, regs)) { + ri = free_ret_instance(ri); + utask->depth--; + } + utask->return_instances = ri; +} + static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs) { struct return_instance *ri; @@ -1541,6 +1551,9 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs) if (orig_ret_vaddr == -1) goto fail; + /* drop the entries invalidated by longjmp() */ + cleanup_return_instances(utask, regs); + /* * We don't want to keep trampoline address in stack, rather keep the * original return address of first caller thru all the consequent