From: Steven Rostedt <rostedt@goodmis.org>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Sven Schnelle' <svens@linux.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Pingfan Liu <kernelfans@gmail.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Tom Zanussi <zanussi@kernel.org>,
"hca@linux.ibm.com" <hca@linux.ibm.com>,
"deller@gmx.de" <deller@gmx.de>
Subject: Re: [PATCH v2] tracing: Add test for user space strings when filtering on string pointers
Date: Thu, 13 Jan 2022 17:28:28 -0500 [thread overview]
Message-ID: <20220113172828.54b46d7b@gandalf.local.home> (raw)
In-Reply-To: <e66911061f9344fa8de2da982ab98a7b@AcuMS.aculab.com>
On Thu, 13 Jan 2022 22:11:35 +0000
David Laight <David.Laight@ACULAB.COM> wrote:
> > Too bad that the __user attribute is stripped during a normal compile.
> > But couldn't we add the information whether a pointer belongs to user
> > or kernel space in the trace event definition? For syscall tracing it's
> > easy, because pointer types in SYSCALL_DEFINE() and friends are always
> > userspace pointers?
>
> Also, when the __user pointer is saved it MUST be checked for being
> a valid user pointer (eg with access_ok(ptr, 1).
It's rather hard to even know if a pointer is __user or not. It could be
some random address in any event field.
>
> You really do need to remember whether the pointer is user or kernel
> when you save it.
>
> I also suspect that you need to check for contexts where 'current'
> isn't really valid (eg any kind on interrupt) and ensure the user
> reads aren't even attempted.
It's not going to crash, even if it is required. The
strncpy_from_user/kernel_nofault() should detect any of that, right? Or are
those functions not safe to call?
> The excuse of being 'root' in order to request/read trace isn't
> really a very good one.
Not sure what you are getting at here? If you are worried about tracing
reading anything, then disable it. There's a lockdown on tracing. for those
that are worried.
Heck I could just do:
# echo 'p:random_umem __common_interrupt add=+0(@0x7f073a188000):u64' > /sys/kernel/tracing/kprobe_events
# trace-cmd start -e random_umem
# trace-cmd show
# tracer: nop
#
# entries-in-buffer/entries-written: 15/15 #P:8
#
# _-----=> irqs-off/BH-disabled
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / _-=> migrate-disable
# |||| / delay
# TASK-PID CPU# ||||| TIMESTAMP FUNCTION
# | | | ||||| | |
<idle>-0 [000] d.h1. 844.051612: random_umem: (__common_interrupt+0x0/0x100) add=7291432837672293
<idle>-0 [000] d.h1. 844.051694: random_umem: (__common_interrupt+0x0/0x100) add=74591483011526501
<idle>-0 [000] d.H1. 844.051743: random_umem: (__common_interrupt+0x0/0x100) add=21474836483
<idle>-0 [000] d.h1. 844.383333: random_umem: (__common_interrupt+0x0/0x100) add=115964116992
<idle>-0 [000] d.h1. 844.383802: random_umem: (__common_interrupt+0x0/0x100) add=1125968626319387
<idle>-0 [000] d.h1. 844.383864: random_umem: (__common_interrupt+0x0/0x100) add=115964116992
<idle>-0 [000] d.h1. 844.533321: random_umem: (__common_interrupt+0x0/0x100) add=4032068056083813
<idle>-0 [000] d.h1. 844.533801: random_umem: (__common_interrupt+0x0/0x100) add=6929886302
kworker/0:1-15 [000] d.h.. 844.900412: random_umem: (__common_interrupt+0x0/0x100) add=17367183
<idle>-0 [000] d.h1. 844.933428: random_umem: (__common_interrupt+0x0/0x100) add=115964116992
<idle>-0 [000] d.h1. 844.933818: random_umem: (__common_interrupt+0x0/0x100) add=17367183
<idle>-0 [000] d.h1. 844.933955: random_umem: (__common_interrupt+0x0/0x100) add=74591483008647173
<idle>-0 [000] d.h1. 845.364181: random_umem: (__common_interrupt+0x0/0x100) add=1125968626319387
bash-1759 [000] d.h.. 845.364541: random_umem: (__common_interrupt+0x0/0x100) add=13912554418208784
bash-1759 [000] d.h.. 845.364592: random_umem: (__common_interrupt+0x0/0x100) add=18446744071906760329
And at every interrupt I get the memory at: 0x7f073a188000 for the current
running task that was running when the interrupt happened.
As I said. It's an API.
-- Steve
next prev parent reply other threads:[~2022-01-13 22:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 16:55 Steven Rostedt
2022-01-10 17:11 ` David Laight
2022-01-10 17:24 ` Steven Rostedt
2022-01-10 17:29 ` Steven Rostedt
2022-01-10 21:58 ` David Laight
2022-01-11 20:55 ` Sven Schnelle
2022-01-13 17:57 ` Steven Rostedt
2022-01-13 21:28 ` Sven Schnelle
2022-01-13 21:51 ` Steven Rostedt
2022-01-14 2:15 ` Steven Rostedt
2022-01-14 7:29 ` Sven Schnelle
2022-01-14 9:35 ` David Laight
2022-01-13 22:11 ` David Laight
2022-01-13 22:28 ` Steven Rostedt [this message]
2022-01-10 22:03 ` David Laight
2022-01-11 0:21 ` Steven Rostedt
2022-01-12 4:13 ` Pingfan Liu
2022-01-13 18:04 ` Steven Rostedt
2022-01-13 22:02 ` Steven Rostedt
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=20220113172828.54b46d7b@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=David.Laight@ACULAB.COM \
--cc=akpm@linux-foundation.org \
--cc=deller@gmx.de \
--cc=hca@linux.ibm.com \
--cc=kernelfans@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=svens@linux.ibm.com \
--cc=zanussi@kernel.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
all inboxes | Powered by JetHome®