Commit 6dc512a0 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'probes-fixes-v6.8-rc3' of...

Merge tag 'probes-fixes-v6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull probes fixes from Masami Hiramatsu:

 - remove unnecessary initial values of kprobes local variables

 - probe-events parser bug fixes:

    - calculate the argument size and format string after setting type
      information from BTF, because BTF can change the size and format
      string.

    - show $comm parse error correctly instead of failing silently.

* tag 'probes-fixes-v6.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  kprobes: Remove unnecessary initial values of variables
  tracing/probes: Fix to set arg size and fmt after setting type from BTF
  tracing/probes: Fix to show a parse error for bad type for $comm
parents e6f39a90 9efd24ec
...@@ -1993,7 +1993,7 @@ NOKPROBE_SYMBOL(__kretprobe_find_ret_addr); ...@@ -1993,7 +1993,7 @@ NOKPROBE_SYMBOL(__kretprobe_find_ret_addr);
unsigned long kretprobe_find_ret_addr(struct task_struct *tsk, void *fp, unsigned long kretprobe_find_ret_addr(struct task_struct *tsk, void *fp,
struct llist_node **cur) struct llist_node **cur)
{ {
struct kretprobe_instance *ri = NULL; struct kretprobe_instance *ri;
kprobe_opcode_t *ret; kprobe_opcode_t *ret;
if (WARN_ON_ONCE(!cur)) if (WARN_ON_ONCE(!cur))
...@@ -2802,7 +2802,7 @@ static int show_kprobe_addr(struct seq_file *pi, void *v) ...@@ -2802,7 +2802,7 @@ static int show_kprobe_addr(struct seq_file *pi, void *v)
{ {
struct hlist_head *head; struct hlist_head *head;
struct kprobe *p, *kp; struct kprobe *p, *kp;
const char *sym = NULL; const char *sym;
unsigned int i = *(loff_t *) v; unsigned int i = *(loff_t *) v;
unsigned long offset = 0; unsigned long offset = 0;
char *modname, namebuf[KSYM_NAME_LEN]; char *modname, namebuf[KSYM_NAME_LEN];
......
...@@ -1159,9 +1159,12 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, ...@@ -1159,9 +1159,12 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
if (!(ctx->flags & TPARG_FL_TEVENT) && if (!(ctx->flags & TPARG_FL_TEVENT) &&
(strcmp(arg, "$comm") == 0 || strcmp(arg, "$COMM") == 0 || (strcmp(arg, "$comm") == 0 || strcmp(arg, "$COMM") == 0 ||
strncmp(arg, "\\\"", 2) == 0)) { strncmp(arg, "\\\"", 2) == 0)) {
/* The type of $comm must be "string", and not an array. */ /* The type of $comm must be "string", and not an array type. */
if (parg->count || (t && strcmp(t, "string"))) if (parg->count || (t && strcmp(t, "string"))) {
trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0),
NEED_STRING_TYPE);
goto out; goto out;
}
parg->type = find_fetch_type("string", ctx->flags); parg->type = find_fetch_type("string", ctx->flags);
} else } else
parg->type = find_fetch_type(t, ctx->flags); parg->type = find_fetch_type(t, ctx->flags);
...@@ -1169,18 +1172,6 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, ...@@ -1169,18 +1172,6 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0), BAD_TYPE); trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0), BAD_TYPE);
goto out; goto out;
} }
parg->offset = *size;
*size += parg->type->size * (parg->count ?: 1);
ret = -ENOMEM;
if (parg->count) {
len = strlen(parg->type->fmttype) + 6;
parg->fmt = kmalloc(len, GFP_KERNEL);
if (!parg->fmt)
goto out;
snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
parg->count);
}
code = tmp = kcalloc(FETCH_INSN_MAX, sizeof(*code), GFP_KERNEL); code = tmp = kcalloc(FETCH_INSN_MAX, sizeof(*code), GFP_KERNEL);
if (!code) if (!code)
...@@ -1204,6 +1195,19 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, ...@@ -1204,6 +1195,19 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
goto fail; goto fail;
} }
} }
parg->offset = *size;
*size += parg->type->size * (parg->count ?: 1);
if (parg->count) {
len = strlen(parg->type->fmttype) + 6;
parg->fmt = kmalloc(len, GFP_KERNEL);
if (!parg->fmt) {
ret = -ENOMEM;
goto out;
}
snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
parg->count);
}
ret = -EINVAL; ret = -EINVAL;
/* Store operation */ /* Store operation */
......
...@@ -515,7 +515,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call, ...@@ -515,7 +515,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
C(BAD_HYPHEN, "Failed to parse single hyphen. Forgot '>'?"), \ C(BAD_HYPHEN, "Failed to parse single hyphen. Forgot '>'?"), \
C(NO_BTF_FIELD, "This field is not found."), \ C(NO_BTF_FIELD, "This field is not found."), \
C(BAD_BTF_TID, "Failed to get BTF type info."),\ C(BAD_BTF_TID, "Failed to get BTF type info."),\
C(BAD_TYPE4STR, "This type does not fit for string."), C(BAD_TYPE4STR, "This type does not fit for string."),\
C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),
#undef C #undef C
#define C(a, b) TP_ERR_##a #define C(a, b) TP_ERR_##a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment