From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: Torsten Duwe <duwe@suse.de>,
Michael Ellerman <mpe@ellerman.id.au>,
Michal Suchanek <msuchanek@suse.de>,
Steven Rostedt <rostedt@goodmis.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/6] powerpc/trace: Add support for stack tracer
Date: Tue, 01 Jun 2021 19:21:27 +0530 [thread overview]
Message-ID: <1622555131.dct16s656o.naveen@linux.ibm.com> (raw)
In-Reply-To: <6ed4941e8ff48729a14b24c8e0d0f876fe8f22e0.1621577151.git.naveen.n.rao@linux.vnet.ibm.com>
Naveen N. Rao wrote:
> +
> +unsigned long ftrace_get_traced_func_if_no_stackframe(unsigned long ip, unsigned long *stack)
> +{
> + if (!is_ftrace_entry(ip))
> + return 0;
> +
> + if (IS_ENABLED(CONFIG_PPC32))
> + return stack[11]; /* see MCOUNT_SAVE_FRAME */
> +
> + if (!IS_ENABLED(CONFIG_MPROFILE_KERNEL))
> + return 0;
> +
> + return stack[(STACK_FRAME_OVERHEAD + offsetof(struct pt_regs, nip)) / sizeof(unsigned long)];
Looking at Daniel's patch to address KASAN errors with our stack walk
code in show_stack() [*], I realized that I am not validating the stack
pointer here for the above accesses...
[*] http://lkml.kernel.org/r/20210528074806.1311297-1-dja@axtens.net
> +}
> +
> +#ifdef CONFIG_STACK_TRACER
> +void stack_get_trace(unsigned long traced_ip,
> + unsigned long *stack_ref __maybe_unused,
> + unsigned long stack_size __maybe_unused,
> + int *tracer_frame)
> +{
> + unsigned long sp, newsp, top, ip;
> + int ftrace_call_found = 0;
> + unsigned long *stack;
> + int i = 0;
> +
> + sp = current_stack_frame();
> + top = (unsigned long)task_stack_page(current) + THREAD_SIZE;
> +
> + while (validate_sp(sp, current, STACK_FRAME_OVERHEAD) && i < STACK_TRACE_ENTRIES) {
> + stack = (unsigned long *) sp;
> + newsp = stack[0];
> + ip = stack[STACK_FRAME_LR_SAVE];
> +
> + if (ftrace_call_found) {
> + stack_dump_trace[i] = ip;
> + stack_trace_index[i++] = top - sp;
> + }
And I need to make the above accesses bypass KASAN as well.
- Naveen
next prev parent reply other threads:[~2021-06-01 13:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 6:48 [RFC PATCH 0/6] powerpc: Stack tracer fixes Naveen N. Rao
2021-05-21 6:48 ` [RFC PATCH 1/6] trace/stack: Move code to save the stack trace into a separate function Naveen N. Rao
2021-06-01 15:28 ` Steven Rostedt
2021-06-02 10:35 ` Naveen N. Rao
2021-06-02 14:09 ` Steven Rostedt
2021-05-21 6:48 ` [RFC PATCH 2/6] powerpc/trace: Add support for stack tracer Naveen N. Rao
2021-06-01 13:51 ` Naveen N. Rao [this message]
2021-05-21 6:48 ` [RFC PATCH 3/6] powerpc: Indicate traced function name in show_stack() Naveen N. Rao
2021-05-21 6:48 ` [RFC PATCH 4/6] powerpc/perf: Include traced function in the callchain Naveen N. Rao
2021-05-21 6:48 ` [RFC PATCH 5/6] powerpc/stacktrace: Include ftraced function in arch_stack_walk_reliable() Naveen N. Rao
2021-05-21 6:48 ` [RFC PATCH 6/6] powerpc/stacktrace: Include ftraced function in arch_stack_walk() Naveen N. Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1622555131.dct16s656o.naveen@linux.ibm.com \
--to=naveen.n.rao@linux.vnet.ibm.com \
--cc=duwe@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).