Skip to content

Commit 9a571c1

Browse files
committed
tracing/probes: Fix to set arg size and fmt after setting type from BTF
Since the BTF type setting updates probe_arg::type, the type size calculation and setting print-fmt should be done after that. Without this fix, the argument size and print-fmt can be wrong. Link: https://lore.kernel.org/all/170602218196.215583.6417859469540955777.stgit@devnote2/ Fixes: b576e09 ("tracing/probes: Support function parameters if BTF is available") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent 8c427cc commit 9a571c1

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

kernel/trace/trace_probe.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,18 +1172,6 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
11721172
trace_probe_log_err(ctx->offset + (t ? (t - arg) : 0), BAD_TYPE);
11731173
goto out;
11741174
}
1175-
parg->offset = *size;
1176-
*size += parg->type->size * (parg->count ?: 1);
1177-
1178-
ret = -ENOMEM;
1179-
if (parg->count) {
1180-
len = strlen(parg->type->fmttype) + 6;
1181-
parg->fmt = kmalloc(len, GFP_KERNEL);
1182-
if (!parg->fmt)
1183-
goto out;
1184-
snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
1185-
parg->count);
1186-
}
11871175

11881176
code = tmp = kcalloc(FETCH_INSN_MAX, sizeof(*code), GFP_KERNEL);
11891177
if (!code)
@@ -1207,6 +1195,19 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
12071195
goto fail;
12081196
}
12091197
}
1198+
parg->offset = *size;
1199+
*size += parg->type->size * (parg->count ?: 1);
1200+
1201+
if (parg->count) {
1202+
len = strlen(parg->type->fmttype) + 6;
1203+
parg->fmt = kmalloc(len, GFP_KERNEL);
1204+
if (!parg->fmt) {
1205+
ret = -ENOMEM;
1206+
goto out;
1207+
}
1208+
snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
1209+
parg->count);
1210+
}
12101211

12111212
ret = -EINVAL;
12121213
/* Store operation */

0 commit comments

Comments
 (0)