Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp295066pxj; Wed, 26 May 2021 23:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3lskYvK12ZqT4c45Jy+PQT7TIsc06uFzbufjueCL2LLefNp/xpFEmguw3Go066RE/OsHK X-Received: by 2002:a17:906:1701:: with SMTP id c1mr2150578eje.425.1622097867092; Wed, 26 May 2021 23:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622097867; cv=none; d=google.com; s=arc-20160816; b=Zre+gO0H6If0yFt/zxTNBm5jkHjRaZgFRdED6Su3b62BSICxnUhjhsdFtIym9lr/VT EwYO/td+lU9tb45oaa4DxtKDigcpKlVOB0lMzgUf5skyHsisc8yvK7j8f3DZ7aDVdGgB Y9kPMdb9UbQ8wN3FSvfI4KN6ICthrAPmFGXz8nfUXTIUPhX/1zIMT90CeoeDKVnZjzeV mU3n0wCWX62nHGz+7I+bOrlJl/xNhjA+4t/rh2+vMrqkHxk204tPJOd90vGfiGrU2dCS NFgJRYHMK8kmL0/4L/0XmKRr7w2PCO2+9dAJcWPR4OapTUgs6u84C8uSgXE1wGLHn5TD 7dwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4LQzJ3iMWd7wF3Obr9OAqMyqnQex+33MdfRB2eSrl78=; b=Yrc6tSkNw5jMjmrZZRWSyC56KTg/rW7pYrk9Mt1L5H+vxaACSszk5OfIowit2aT5lE AIAqbsrVDjouUW9s0kAtbbO7TQ9xddAbuosJaz00t4i2UgIGk5A51rBsqb+e1/JlJ/Vd SyXORVe6HOowTsPzllfauqMo4iz1ObHD8Yy0RlSXZJZuOSixOvD17dfjHhv+5PwGilP4 g6TO0i57PBKsT0W5lTxhFLsOKLoQINzFtB9rHhC2ewnmzj3mjdjApIOoLNjVoUKJq638 Stuu3+eyQCGLoJQcnMyRtGoLZHd/nLB9+AVwhjmun5or+lNozTb4ES5C+LRkLox1PnB7 101Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kUIzp22o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si1634113ejo.341.2021.05.26.23.44.04; Wed, 26 May 2021 23:44:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kUIzp22o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234703AbhE0GmS (ORCPT + 99 others); Thu, 27 May 2021 02:42:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:60512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234473AbhE0GmG (ORCPT ); Thu, 27 May 2021 02:42:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CBD2613D8; Thu, 27 May 2021 06:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622097633; bh=FkkjM9IdASzlPy5rbPRT2RtG01kVXUCEr1Rvtd2a5iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUIzp22oaxs7bdAZkppqknpu4nQorQEHVlVUIT5PVlhTfoQDkD1o75sNzoG9QpvvS KUsdYssxWebYiv3Zi0VuDW80Jq/hCWMR9WUbt65KHGO86xlSEN/PRHjoCnp/Xlo2c2 ph3nsxEyj4iVj5qr9UHp7/hpo+YfeZuJ2vzeB10tUzOzKx8xG/9tk+ZuITN3rv+T0V enIwlgkOSJswJCw2RIFBaHmY7qndRYTBSwF8tPnwjYwUovBgMm2xWLo69uFyONi7Du 33w4Z3iN44r9JyBv4pW0eV+OCLOllRrUorPG7FeRnarLtGUHv/iYlM0q+nV1eKOr9w iyaMp9wKddfuA== From: Masami Hiramatsu To: Steven Rostedt , Ingo Molnar Cc: X86 ML , Masami Hiramatsu , Daniel Xu , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kuba@kernel.org, mingo@redhat.com, ast@kernel.org, tglx@linutronix.de, kernel-team@fb.com, yhs@fb.com, Josh Poimboeuf , linux-ia64@vger.kernel.org, Abhishek Sagar , Andrii Nakryiko Subject: [PATCH -tip v7 09/13] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler Date: Thu, 27 May 2021 15:40:29 +0900 Message-Id: <162209762943.436794.874947392889792501.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <162209754288.436794.3904335049560916855.stgit@devnote2> References: <162209754288.436794.3904335049560916855.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To simplify the stacktrace with pt_regs from kretprobe handler, set the correct return address to the instruction pointer in the pt_regs before calling kretprobe handlers. Suggested-by: Josh Poimboeuf Signed-off-by: Masami Hiramatsu Tested-by: Andrii Nakryik --- Changes in v3: - Cast the correct_ret_addr to unsigned long. --- kernel/kprobes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 54e5b89aad67..1598aca375c9 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1914,6 +1914,9 @@ unsigned long __kretprobe_trampoline_handler(struct pt_regs *regs, BUG_ON(1); } + /* Set the instruction pointer to the correct address */ + instruction_pointer_set(regs, (unsigned long)correct_ret_addr); + /* Run them. */ first = current->kretprobe_instances.first; while (first) {