From: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Andy Lutomirski <luto@amacapital.net>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Changbin Du <changbin.du@gmail.com>, Jann Horn <jannh@google.com>,
Kees Cook <keescook@chromium.org>,
Andy Lutomirski <luto@kernel.org>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Nadav Amit <namit@vmware.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v3 5/5] tracing/probe: Support user-space dereference
Date: Wed, 27 Feb 2019 21:42:45 -0500 [thread overview]
Message-ID: <20190227214245.39d6563f@vmware.local.home> (raw)
In-Reply-To: <155127868250.32576.2419537726154240743.stgit@devbox>
On Wed, 27 Feb 2019 23:44:42 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index a7012de37a00..0efef172db17 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -239,6 +239,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
> {
> struct fetch_insn *code = *pcode;
> unsigned long param;
> + int deref = FETCH_OP_DEREF;
> long offset = 0;
> char *tmp;
> int ret = 0;
> @@ -301,8 +302,17 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
> break;
>
> case '+': /* deref memory */
> - arg++; /* Skip '+', because kstrtol() rejects it. */
> case '-':
> + if (arg[0] == '+') {
> + arg++; /* Skip '+', because kstrtol() rejects it. */
> + if (arg[0] == 'u') {
> + deref = FETCH_OP_UDEREF;
> + arg++;
> + }
> + } else if (arg[1] == 'u') { /* Start with "-u" */
> + deref = FETCH_OP_UDEREF;
> + *(++arg) = '-';
> + }
What about:
if (arg[1] == 'u') {
deref = FETCH_OP_UDEREF;
arg[1] = arg[0];
arg++;
}
if (arg[0] == '+')
arg++; /* Skip '+', because kstrtol() rejects it. */
A bit less messy.
> tmp = strchr(arg, '(');
> if (!tmp)
> return -EINVAL;
> @@ -328,7 +338,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
> return -E2BIG;
> *pcode = code;
>
> - code->op = FETCH_OP_DEREF;
> + code->op = deref;
> code->offset = offset;
> }
> break;
> @@ -444,13 +454,14 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
> /* Store operation */
> if (!strcmp(parg->type->name, "string") ||
> !strcmp(parg->type->name, "ustring")) {
> - if (code->op != FETCH_OP_DEREF && code->op != FETCH_OP_IMM &&
> - code->op != FETCH_OP_COMM) {
> + if (code->op != FETCH_OP_DEREF && code->op != FETCH_OP_UDEREF
> + && code->op != FETCH_OP_IMM && code->op != FETCH_OP_COMM) {
> pr_info("string only accepts memory or address.\n");
> ret = -EINVAL;
> goto fail;
> }
> - if (code->op != FETCH_OP_DEREF || parg->count) {
> + if ((code->op == FETCH_OP_IMM && code->op == FETCH_OP_COMM)
> + || parg->count) {
How would "code->op == FETCH_OP_IMM && code->op == FETCH_OP_COMM" ever be true?
Did you mean || ?
-- Steve
> /*
> * IMM and COMM is pointing actual address, those must
> * be kept, and if parg->count != 0, this is an array
> @@ -463,7 +474,8 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
> }
> }
> /* If op == DEREF, replace it with STRING */
> - if (!strcmp(parg->type->name, "ustring"))
> + if (!strcmp(parg->type->name, "ustring") ||
> + code->op == FETCH_OP_UDEREF)
> code->op = FETCH_OP_ST_USTRING;
> else
> code->op = FETCH_OP_ST_STRING;
next prev parent reply other threads:[~2019-02-28 2:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 14:42 [PATCH v3 0/5] tracing/probes: uaccess: Add support user-space access Masami Hiramatsu
2019-02-27 14:42 ` [PATCH v3 1/5] uaccess: Add user_access_ok() Masami Hiramatsu
2019-02-27 14:43 ` [PATCH v3 2/5] uaccess: Use user_access_ok() in user_access_begin() Masami Hiramatsu
2019-02-27 14:43 ` [PATCH v3 3/5] uaccess: Add non-pagefault user-space read functions Masami Hiramatsu
2019-02-27 14:44 ` [PATCH v3 4/5] tracing/probe: Add ustring type for user-space string Masami Hiramatsu
2019-02-28 2:20 ` Steven Rostedt
2019-02-27 14:44 ` [PATCH v3 5/5] tracing/probe: Support user-space dereference Masami Hiramatsu
2019-02-28 2:31 ` Steven Rostedt
2019-02-28 7:00 ` Masami Hiramatsu
2019-02-28 16:20 ` Steven Rostedt
2019-02-28 2:42 ` Steven Rostedt [this message]
2019-02-28 6:08 ` Masami Hiramatsu
2019-02-27 22:32 ` [PATCH v3 0/5] tracing/probes: uaccess: Add support user-space access Alexei Starovoitov
2019-02-28 1:54 ` Masami Hiramatsu
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=20190227214245.39d6563f@vmware.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=changbin.du@gmail.com \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.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).