From patchwork Thu Sep 10 08:55:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E40FD618 for ; Thu, 10 Sep 2020 08:56:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0E2521941 for ; Thu, 10 Sep 2020 08:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728185; bh=rfxlWXkoFVg1nBhyifXGxOJ6QA+J4LqvbC5/ABiyWGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gPU0txP7b/GXDRyQ3LrIXXpfUA+d2KQDCtUo+UIdJURC+PKC1CeRq5epvb2AkXoPp ulJS9fL7IraAZLOL7VUMN1crh8c5AF9khBGHH1K5MicvXinEspez7/E6gtfCXs4W8E efjmGNynNxPpoJWjrViwfM6OR4Rwai0uGh12hH4k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730353AbgIJI4J (ORCPT ); Thu, 10 Sep 2020 04:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:36878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730367AbgIJIzO (ORCPT ); Thu, 10 Sep 2020 04:55:14 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9AC820C09; Thu, 10 Sep 2020 08:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728109; bh=rfxlWXkoFVg1nBhyifXGxOJ6QA+J4LqvbC5/ABiyWGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sWdRgGJzJ/iOoEw77p0uCQzWo6ihi5UVTZdPvCAp633+7sgdfbtl0/e3ou+I885Qp 1U3uSuCPIbtBHNpFdjTtrMnwk3OaTmx4SA0Vcmt5Pe2dDpeDkIwYUbGmS8vPhWpIGF 7fqmwQLWsYawtSEx+xgpVlSpA87TMH6T4dsihthM= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 1/8] kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot Date: Thu, 10 Sep 2020 17:55:05 +0900 Message-Id: <159972810544.428528.1839307531600646955.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Since kprobe_event= cmdline option allows user to put kprobes on the functions in initmem, kprobe has to make such probes gone after boot. Currently the probes on the init functions in modules will be handled by module callback, but the kernel init text isn't handled. Without this, kprobes may access non-exist text area to disable or remove it. Fixes: 970988e19eb0 ("tracing/kprobe: Add kprobe_event= boot parameter") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix kprobe_free_init_mem() not depending on CONFIG_DEBUG_FS. --- include/linux/kprobes.h | 5 +++++ init/main.c | 2 ++ kernel/kprobes.c | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 9be1bff4f586..8aab327b5539 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -373,6 +373,8 @@ void unregister_kretprobes(struct kretprobe **rps, int num); void kprobe_flush_task(struct task_struct *tk); void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); +void kprobe_free_init_mem(void); + int disable_kprobe(struct kprobe *kp); int enable_kprobe(struct kprobe *kp); @@ -435,6 +437,9 @@ static inline void unregister_kretprobes(struct kretprobe **rps, int num) static inline void kprobe_flush_task(struct task_struct *tk) { } +static inline void kprobe_free_init_mem(void) +{ +} static inline int disable_kprobe(struct kprobe *kp) { return -ENOSYS; diff --git a/init/main.c b/init/main.c index ae78fb68d231..038128b2a755 100644 --- a/init/main.c +++ b/init/main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1402,6 +1403,7 @@ static int __ref kernel_init(void *unused) kernel_init_freeable(); /* need to finish all async __init code before freeing the memory */ async_synchronize_full(); + kprobe_free_init_mem(); ftrace_free_init_mem(); free_initmem(); mark_readonly(); diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 287b263c9cb9..2880cdf37c47 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -2452,6 +2452,28 @@ static struct notifier_block kprobe_module_nb = { extern unsigned long __start_kprobe_blacklist[]; extern unsigned long __stop_kprobe_blacklist[]; +void kprobe_free_init_mem(void) +{ + void *start = (void *)(&__init_begin); + void *end = (void *)(&__init_end); + struct hlist_head *head; + struct kprobe *p; + int i; + + mutex_lock(&kprobe_mutex); + + /* Kill all kprobes on initmem */ + for (i = 0; i < KPROBE_TABLE_SIZE; i++) { + head = &kprobe_table[i]; + hlist_for_each_entry(p, head, hlist) { + if (start <= (void *)p->addr && (void *)p->addr < end) + kill_kprobe(p); + } + } + + mutex_unlock(&kprobe_mutex); +} + static int __init init_kprobes(void) { int i, err = 0; From patchwork Thu Sep 10 08:55:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE911698 for ; Thu, 10 Sep 2020 08:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9862120C09 for ; Thu, 10 Sep 2020 08:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728339; bh=SwrJXfeH/9hOrMi7XyK/W+RmfZgE720J1M//fWtouGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ujJpZAkUjn9L0xJwFmYUoj0n9x2fr3caLcJbp1Orchm4btmna1t+IAZo/wEn08Otq W88pK3VL2GhspDitWeeDbV+94m1Cy5JD1ZknGlRJk0/De582wQ908cKN+43UBQzNRe rUsAiikj4gb9hb4y5dFELmWHFfAoOt4tAKCOzUSE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730553AbgIJI67 (ORCPT ); Thu, 10 Sep 2020 04:58:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730386AbgIJIzU (ORCPT ); Thu, 10 Sep 2020 04:55:20 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AED4D208CA; Thu, 10 Sep 2020 08:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728119; bh=SwrJXfeH/9hOrMi7XyK/W+RmfZgE720J1M//fWtouGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivcvhJmVM32K1an7TJ7aGnBwdi+4P5XrMo4dpwItVENXdXZEe0jr8ps4/ll8mafdo tuyvq0QKHHOqBgLuQMePdIOKpfPNtc9vfpqe0Xo1w5be1LWhikneUab7/zVBBDvFEE PaNoNhfIKZbXKF+bqpq2gfIzHmAFm6APwGxS9sQk= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 2/8] tracing/boot: Add per-instance tracing_on option support Date: Thu, 10 Sep 2020 17:55:15 +0900 Message-Id: <159972811538.428528.2561315102284268611.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add per-instance tracing_on option, which will be useful with traceon/traceoff event trigger actions. For example, if we disable tracing_on by default and set traceon and traceoff on a pair of events, we can trace functions between the pair of events. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace_boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c index fa0fc08c6ef8..d52d441a17e8 100644 --- a/kernel/trace/trace_boot.c +++ b/kernel/trace/trace_boot.c @@ -40,6 +40,16 @@ trace_boot_set_instance_options(struct trace_array *tr, struct xbc_node *node) pr_err("Failed to set option: %s\n", buf); } + p = xbc_node_find_value(node, "tracing_on", NULL); + if (p && *p != '\0') { + if (kstrtoul(p, 10, &v)) + pr_err("Failed to set tracing on: %s\n", p); + if (v) + tracer_tracing_on(tr); + else + tracer_tracing_off(tr); + } + p = xbc_node_find_value(node, "trace_clock", NULL); if (p && *p != '\0') { if (tracing_set_clock(tr, p) < 0) From patchwork Thu Sep 10 08:55:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BEF1698 for ; Thu, 10 Sep 2020 08:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C10421941 for ; Thu, 10 Sep 2020 08:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728204; bh=8rOIdZ6wqgc1jq2tHq0/nusm6CFDfSurOY8zud5UQN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kNnLeWpKiVGjP6QWenwO2A8tdl+WzzagiUp2+zGtWeHoPL7h6dPRKLJjqbEjr2haC QVOi9zyoUi59dz/DWIMR8PF3Q4qJtvUQa0UYGYlDTH+2GXoThiEdvlsc9HE7BmWeNE 3hQVPiRMjPmdt+WassbzvzK2KS7IFxRCfCXI0ZBo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729161AbgIJI4k (ORCPT ); Thu, 10 Sep 2020 04:56:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730393AbgIJIza (ORCPT ); Thu, 10 Sep 2020 04:55:30 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C605B21582; Thu, 10 Sep 2020 08:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728129; bh=8rOIdZ6wqgc1jq2tHq0/nusm6CFDfSurOY8zud5UQN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=leJnOu5KxIAiH3kxW6+5yVmio/6hltm3+b4MCmPXarj9zs9k0JfOaliGHzILpIBjy UO1HgNQXiKhV5PBACneW+uP8ckCds7C3uAzStS1sYxOMjbR3qAN8LEA8OQ3RoNBPpS hTlW//UcDzeLbGuy8n3GM8H5npn9/8QOGJdtU7gk= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 3/8] Documentation: tracing: Add tracing_on option to boot-time tracer Date: Thu, 10 Sep 2020 17:55:25 +0900 Message-Id: <159972812521.428528.4047280962991773996.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add tracing_on option description to the boot-time tracer. Signed-off-by: Masami Hiramatsu --- Documentation/trace/boottime-trace.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/trace/boottime-trace.rst b/Documentation/trace/boottime-trace.rst index dcb390075ca1..1341b449acaa 100644 --- a/Documentation/trace/boottime-trace.rst +++ b/Documentation/trace/boottime-trace.rst @@ -61,6 +61,10 @@ These options can be used for each instance including global ftrace node. ftrace.[instance.INSTANCE.]options = OPT1[, OPT2[...]] Enable given ftrace options. +ftrace.[instance.INSTANCE.]tracing_on = 0|1 + Enable/Disable tracing on this instance when boot. + (you can enable it by the "traceon" event trigger action) + ftrace.[instance.INSTANCE.]trace_clock = CLOCK Set given CLOCK to ftrace's trace_clock. From patchwork Thu Sep 10 08:55:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C3F2698 for ; Thu, 10 Sep 2020 08:57:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B07A208CA for ; Thu, 10 Sep 2020 08:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728225; bh=RUqvnNc5wOwqapqqse5XrNvDpPCq89bLAr/r7gI4jU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TzXNWF6/um7N0aKt9tQKdfu2eNfCPgnVrQBPQeLMFJryrPM4051cN3sdY2Yw2enIV F9pwbzFqnDTifecZjOcBtEeLzfkbW9pluQWVfeQNjOaiwFYyHot0fMpgkFDnvjkh+b hvBrVWX2rI2RErd8maxAQEKrzqGWvj5DCLsWOQRE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730367AbgIJI5C (ORCPT ); Thu, 10 Sep 2020 04:57:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730259AbgIJIzl (ORCPT ); Thu, 10 Sep 2020 04:55:41 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26CF420770; Thu, 10 Sep 2020 08:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728140; bh=RUqvnNc5wOwqapqqse5XrNvDpPCq89bLAr/r7gI4jU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awgxyXjHGtxa4cfVDOa6QyO85fpqiltWylBoV8S/1Fl0vfU77sMSwBI2sJgnZsV0s glkbrnmhLQwKnFS4U2Y7oMjvs2UghCWBFkYj5Yz43zNyb67i/C5zZjT+dVUOMVZ/Vy FvrUUreYm3jYBACOdXJ7HpG8jIuZ5IgNLw0fTbwY= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 4/8] tracing/kprobes: Support perf-style return probe Date: Thu, 10 Sep 2020 17:55:35 +0900 Message-Id: <159972813535.428528.4437029657208468954.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support perf-style return probe ("SYMBOL%return") for kprobe events. This will allow boot-time tracing user to define a return probe event. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Update README so that user can notice the kernel supports this feature. - Add a new error message. --- kernel/trace/trace.c | 2 +- kernel/trace/trace_kprobe.c | 18 +++++++++++++++++- kernel/trace/trace_probe.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f40d850ebabc..2c8c8f7ddef7 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5122,7 +5122,7 @@ static const char readme_msg[] = "\t -:[/]\n" #ifdef CONFIG_KPROBE_EVENTS "\t place: [:][+]|\n" - "place (kretprobe): [:][+]|\n" + "place (kretprobe): [:][+]%return|\n" #endif #ifdef CONFIG_UPROBE_EVENTS " place (uprobe): :[(ref_ctr_offset)]\n" diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index aefb6065b508..e33690a12255 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -717,6 +717,9 @@ static int trace_kprobe_create(int argc, const char *argv[]) * p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS] * - Add kretprobe: * r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS] + * Or + * p:[GRP/]EVENT] [MOD:]KSYM[+0]%return [FETCHARGS] + * * Fetch args: * $retval : fetch return value * $stack : fetch stack address @@ -746,7 +749,6 @@ static int trace_kprobe_create(int argc, const char *argv[]) switch (argv[0][0]) { case 'r': is_return = true; - flags |= TPARG_FL_RETURN; break; case 'p': break; @@ -804,12 +806,26 @@ static int trace_kprobe_create(int argc, const char *argv[]) symbol = kstrdup(argv[1], GFP_KERNEL); if (!symbol) return -ENOMEM; + + tmp = strchr(symbol, '%'); + if (tmp) { + if (!strcmp(tmp, "%return")) { + *tmp = '\0'; + is_return = true; + } else { + trace_probe_log_err(tmp - symbol, BAD_ADDR_SUFFIX); + goto parse_error; + } + } + /* TODO: support .init module functions */ ret = traceprobe_split_symbol_offset(symbol, &offset); if (ret || offset < 0 || offset > UINT_MAX) { trace_probe_log_err(0, BAD_PROBE_ADDR); goto parse_error; } + if (is_return) + flags |= TPARG_FL_RETURN; if (kprobe_on_func_entry(NULL, symbol, offset)) flags |= TPARG_FL_FENTRY; if (offset && is_return && !(flags & TPARG_FL_FENTRY)) { diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index a22b62813f8c..04d00987da69 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -404,6 +404,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call, C(MAXACT_TOO_BIG, "Maxactive is too big"), \ C(BAD_PROBE_ADDR, "Invalid probed address or symbol"), \ C(BAD_RETPROBE, "Retprobe address must be an function entry"), \ + C(BAD_ADDR_SUFFIX, "Invalid probed address suffix"), \ C(NO_GROUP_NAME, "Group name is not specified"), \ C(GROUP_TOO_LONG, "Group name is too long"), \ C(BAD_GROUP_NAME, "Group name must follow the same rules as C identifiers"), \ From patchwork Thu Sep 10 08:55:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87B09618 for ; Thu, 10 Sep 2020 08:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65CD820770 for ; Thu, 10 Sep 2020 08:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728281; bh=Usei1xLmvGf2Y8buCZXpy+oUTxiyFNSfzZeT9ewnigs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ihi5zXRC+5IZIMnMbp+18U+NLsBw3AULVCIEoxXFqeVvf491lZFU3sFmh+Xt1ISbd cAzebT6PMyldFQufQNbW06Bt74F9oWmzttmrsB7pcWppP1x2D+tnzjjZJYN61Rpjou JJNNbwj4SASEhMb2JwlKfvB+u/WpCh5X9bxeGchE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730277AbgIJI5w (ORCPT ); Thu, 10 Sep 2020 04:57:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:37146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730268AbgIJIzv (ORCPT ); Thu, 10 Sep 2020 04:55:51 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C41522078B; Thu, 10 Sep 2020 08:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728150; bh=Usei1xLmvGf2Y8buCZXpy+oUTxiyFNSfzZeT9ewnigs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zgr7WfK9sDVeejvY78RJ+pkCDQOwSqegfMelvnN8fNrZSf6ipnffv0ANSDHqOxXsx Pdz2qRQMHMOM4t3Zg5CpBQjuYTw9VUhBVy6WgtNYLSd/tsVHVU/PHmbWURNMIOmqw3 CoYroNdbbR2ZmyBRbbnOoToIW/NjvFY2wzLaJakQ= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 5/8] tracing/uprobes: Support perf-style return probe Date: Thu, 10 Sep 2020 17:55:46 +0900 Message-Id: <159972814601.428528.7641183316212425445.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Support perf-style return probe ("SYMBOL%return") for uprobe events as same as kprobe events does. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace.c | 2 +- kernel/trace/trace_uprobe.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2c8c8f7ddef7..faf55f5dd99d 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5125,7 +5125,7 @@ static const char readme_msg[] = "place (kretprobe): [:][+]%return|\n" #endif #ifdef CONFIG_UPROBE_EVENTS - " place (uprobe): :[(ref_ctr_offset)]\n" + " place (uprobe): :[%return][(ref_ctr_offset)]\n" #endif "\t args: =fetcharg[:type]\n" "\t fetcharg: %, @
, @[+|-],\n" diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index f4286c9bdeb4..fb5ec4e55484 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -528,7 +528,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu) /* * Argument syntax: - * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] + * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET[%return][(REF)] [FETCHARGS] */ static int trace_uprobe_create(int argc, const char **argv) { @@ -617,6 +617,19 @@ static int trace_uprobe_create(int argc, const char **argv) } } + /* Check if there is %return suffix */ + tmp = strchr(arg, '%'); + if (tmp) { + if (!strcmp(tmp, "%return")) { + *tmp = '\0'; + is_return = true; + } else { + trace_probe_log_err(tmp - filename, BAD_ADDR_SUFFIX); + ret = -EINVAL; + goto fail_address_parse; + } + } + /* Parse uprobe offset. */ ret = kstrtoul(arg, 0, &offset); if (ret) { From patchwork Thu Sep 10 08:55:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC67B698 for ; Thu, 10 Sep 2020 08:57:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D83F20770 for ; Thu, 10 Sep 2020 08:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728273; bh=NP1Z6K6LEc0Z5cQ6QS7YeNkBtyB+Ncb3GwWlXhqAyDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QeVhyWmi+Bw6rw6+OEDwhxrwnffe7csTivzmN/jV89d9T9mE0ZgI07OEWRCP3BEbJ Jde6YWUk66LldfWjFkTnHO/69h5mvG2jYVE4YFeMCljpnK4dPUpmKQsXR9tIeQv5XU OIrfKMpziDV+iH6EuPPHO4Ue9nUJyw0Y6FMt5PH8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730116AbgIJI5j (ORCPT ); Thu, 10 Sep 2020 04:57:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:37216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730424AbgIJI4C (ORCPT ); Thu, 10 Sep 2020 04:56:02 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C0A020872; Thu, 10 Sep 2020 08:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728161; bh=NP1Z6K6LEc0Z5cQ6QS7YeNkBtyB+Ncb3GwWlXhqAyDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8cj+Cx4K7hEVWaJ3hdN0XcDhAKgVhrFPDd//yxpiFJ8Zq36Dzw+KF4KxLAC3cnmT Ed7aDyGiIwNCDu2DApfPgEL3/mVp40Upa1hLYLVl3rKjYSRiNP3O4S+7oA3KnVYKlQ gCNWfoFkhD1MDTSuKoVUo97k6M/x3kk6gynNcWZI= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 6/8] Documentation: tracing: Add %return suffix description Date: Thu, 10 Sep 2020 17:55:56 +0900 Message-Id: <159972815624.428528.10450874184415697524.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add a description of the %return suffix option for kprobe event and uprobe event. Signed-off-by: Masami Hiramatsu --- Changes in v3 - Add description for uprobe events too. Changes in v2 - Use a tab for indentation as other lines do. --- Documentation/trace/kprobetrace.rst | 2 ++ Documentation/trace/uprobetracer.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kprobetrace.rst index c1709165c553..a18eb97a263c 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -30,6 +30,7 @@ Synopsis of kprobe_events p[:[GRP/]EVENT] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS] : Set a probe r[MAXACTIVE][:[GRP/]EVENT] [MOD:]SYM[+0] [FETCHARGS] : Set a return probe + p:[GRP/]EVENT] [MOD:]SYM[+0]%return [FETCHARGS] : Set a return probe -:[GRP/]EVENT : Clear a probe GRP : Group name. If omitted, use "kprobes" for it. @@ -37,6 +38,7 @@ Synopsis of kprobe_events based on SYM+offs or MEMADDR. MOD : Module name which has given SYM. SYM[+offs] : Symbol+offset where the probe is inserted. + SYM%return : Return address of the symbol MEMADDR : Address where the probe is inserted. MAXACTIVE : Maximum number of instances of the specified function that can be probed simultaneously, or 0 for the default value diff --git a/Documentation/trace/uprobetracer.rst b/Documentation/trace/uprobetracer.rst index 98cde99939d7..a8e5938f609e 100644 --- a/Documentation/trace/uprobetracer.rst +++ b/Documentation/trace/uprobetracer.rst @@ -28,6 +28,7 @@ Synopsis of uprobe_tracer p[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a uprobe r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe) + p[:[GRP/]EVENT] PATH:OFFSET%return [FETCHARGS] : Set a return uprobe (uretprobe) -:[GRP/]EVENT : Clear uprobe or uretprobe event GRP : Group name. If omitted, "uprobes" is the default value. @@ -35,6 +36,7 @@ Synopsis of uprobe_tracer on PATH+OFFSET. PATH : Path to an executable or a library. OFFSET : Offset where the probe is inserted. + OFFSET%return : Offset where the return probe is inserted. FETCHARGS : Arguments. Each probe can have up to 128 args. %REG : Fetch register REG From patchwork Thu Sep 10 08:56:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBB3D618 for ; Thu, 10 Sep 2020 08:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE1CC20770 for ; Thu, 10 Sep 2020 08:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728319; bh=AFTvUebiyRMETzn8S38/k45wbiUemiQHqeohzIX/Qck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ttXcDXg424QG4fRn/T/K5yfJoguMbvONWZzF6YZJfXtGDmfCgc9exmEFMHvZMrdcV shZ2/Bnq3Lf5ObXkrKIOq2E1edSpUi4la1hTSSpwm2G6Fi04eQGNMfoNH+Ioz2rCmQ 3XUnWxMaXicERQdRqlYm6Cnhb1mitMJENDkw37eM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbgIJI6j (ORCPT ); Thu, 10 Sep 2020 04:58:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:37314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730270AbgIJI4L (ORCPT ); Thu, 10 Sep 2020 04:56:11 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF4E121556; Thu, 10 Sep 2020 08:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728171; bh=AFTvUebiyRMETzn8S38/k45wbiUemiQHqeohzIX/Qck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vv8tcQe7zv9uk+l9UZSlOvvWpTivIwZNWMyeR0Ille5GxORiu664nMpGfDbIcVHQv OgST9iaJ8E/CChyDqbRK0FSwFbF4+aDxaFi4W+txB/8/VxXuTC9goVeeYtxZMOW5+X dpUfQtZrGEqojNdN1MkxQ5QXmJLB8ajjY9VZ3VKE= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 7/8] Documentation: tracing: boot: Add an example of tracing function-calls Date: Thu, 10 Sep 2020 17:56:06 +0900 Message-Id: <159972816669.428528.12390560334549382316.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add an example of tracing function calls on a specific function. Signed-off-by: Masami Hiramatsu --- Documentation/trace/boottime-trace.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/trace/boottime-trace.rst b/Documentation/trace/boottime-trace.rst index 1341b449acaa..c216f5695ae2 100644 --- a/Documentation/trace/boottime-trace.rst +++ b/Documentation/trace/boottime-trace.rst @@ -168,6 +168,26 @@ is for tracing functions starting with "user\_", and others tracing The instance node also accepts event nodes so that each instance can customize its event tracing. +With the trigger action and kprobes, you can trace function-graph while +a function is called. For example, this will trace all function calls in +the pci_proc_init():: + + ftrace { + tracing_on = 0 + tracer = function_graph + event.kprobes { + start_event { + probes = "pci_proc_init" + actions = "traceon" + } + end_event { + probes = "pci_proc_init%return" + actions = "traceoff" + } + } + } + + This boot-time tracing also supports ftrace kernel parameters via boot config. For example, following kernel parameters:: From patchwork Thu Sep 10 08:56:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 11767159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 092BC698 for ; Thu, 10 Sep 2020 08:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC9BC20770 for ; Thu, 10 Sep 2020 08:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728304; bh=0PJbxvzO5I5gMwLMCGZyMr4dYyj6eWzJKi8tvIfw5go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Pg31M4CGrAz6uc+gDvYswFxA+DyMBodU25zMxeBs/RqJctta82S0utLPSsVNYclcO hMk1w7qs1fgUYEbUk8lh+r3D1YOmqqQDW4kZsWY/ZW9Z3kMslCbGU2yQlfrRZKciO1 GyeauoK3u5R/VUoqfw/i3j2NhuIj7gera1AmojHI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730268AbgIJI6X (ORCPT ); Thu, 10 Sep 2020 04:58:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730437AbgIJI40 (ORCPT ); Thu, 10 Sep 2020 04:56:26 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C4C6920C09; Thu, 10 Sep 2020 08:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599728180; bh=0PJbxvzO5I5gMwLMCGZyMr4dYyj6eWzJKi8tvIfw5go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M15lyRNu+GUJ399GEB6RWtOfd2Huf3GoD7Y4J6wNiX2mVL8R2UaJR4CqkplFi01Op b5MtW+7sNCMFtZA4N8jYufN5ROy2atU09kOCsaG7+nYogQgRWRMMhpm++Y/9JPfwaL p/AXm+Z45K/Hv+r7kVizMjmJBqMy9s4fvleql/BA= From: Masami Hiramatsu To: Steven Rostedt , Jonathan Corbet , Shuah Khan Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Ingo Molnar , linux-kselftest@vger.kernel.org Subject: [PATCH v3 8/8] selftests/ftrace: Add %return suffix tests Date: Thu, 10 Sep 2020 17:56:16 +0900 Message-Id: <159972817653.428528.9180599115849301184.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2> References: <159972809455.428528.4737752126800169128.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add kprobe %return suffix testcase and syntax error tests for %return suffix. Signed-off-by: Masami Hiramatsu --- .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 6 ++++++ .../test.d/kprobe/kretprobe_return_suffix.tc | 21 ++++++++++++++++++++ .../ftrace/test.d/kprobe/uprobe_syntax_errors.tc | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc index b4d834675e59..56b3f36c722b 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc @@ -97,4 +97,10 @@ check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"' # DIFF_ARG_TYPE check_error '^p:kprobes/testevent _do_fork abcd=\1' # SAME_PROBE fi +# %return suffix errors +if grep -q "place (kretprobe): .*%return.*" README; then +check_error 'p vfs_read^%hoge' # BAD_ADDR_SUFFIX +check_error 'p ^vfs_read+10%return' # BAD_RETPROBE +fi + exit 0 diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc new file mode 100644 index 000000000000..f07bd15cc033 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc @@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kretprobe %%return suffix test +# requires: kprobe_events '[+]%return':README + +# Test for kretprobe by "r" +echo 'r:myprobeaccept vfs_read' > kprobe_events +RESULT1=`cat kprobe_events` + +# Test for kretprobe by "%return" +echo 'p:myprobeaccept vfs_read%return' > kprobe_events +RESULT2=`cat kprobe_events` + +if [ "$RESULT1" != "$RESULT2" ]; then + echo "Error: %return suffix didn't make a return probe." + echo "r-command: $RESULT1" + echo "%return: $RESULT2" + exit_fail +fi + +echo > kprobe_events diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc index 7b5b60c3c5a2..f5e3f9e4a01f 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc @@ -17,4 +17,10 @@ check_error 'p /bin/sh:10(10)^a' # BAD_REFCNT_SUFFIX check_error 'p /bin/sh:10 ^@+ab' # BAD_FILE_OFFS check_error 'p /bin/sh:10 ^@symbol' # SYM_ON_UPROBE +# %return suffix error +if grep -q "place (uprobe): .*%return.*" README; then +check_error 'p /bin/sh:10^%hoge' # BAD_ADDR_SUFFIX +check_error 'p /bin/sh:10(10)^%return' # BAD_REFCNT_SUFFIX +fi + exit 0