Skip to content

Commit 26edad0

Browse files
committed
Merge tag 'probes-fixes-v6.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull probe events fixes from Masami Hiramatsu: - probe-events: Remove unused MAX_ARG_BUF_LEN macro - it is not used - fprobe-events: Log error for exceeding the number of entry args. Since the max number of entry args is limited, it should be checked and rejected when the parser detects it. - tprobe-events: Reject invalid tracepoint name If a user specifies an invalid tracepoint name (e.g. including '/') then the new event is not defined correctly in the eventfs. - tprobe-events: Fix a memory leak when tprobe defined with $retval There is a memory leak if tprobe is defined with $retval. * tag 'probes-fixes-v6.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: probe-events: Remove unused MAX_ARG_BUF_LEN macro tracing: fprobe-events: Log error for exceeding the number of entry args tracing: tprobe-events: Reject invalid tracepoint name tracing: tprobe-events: Fix a memory leak when tprobe with $retval
2 parents 7eb1721 + fd5ba38 commit 26edad0

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

kernel/trace/trace_fprobe.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,13 +1049,28 @@ static int parse_symbol_and_return(int argc, const char *argv[],
10491049
if (*is_return)
10501050
return 0;
10511051

1052+
if (is_tracepoint) {
1053+
tmp = *symbol;
1054+
while (*tmp && (isalnum(*tmp) || *tmp == '_'))
1055+
tmp++;
1056+
if (*tmp) {
1057+
/* find a wrong character. */
1058+
trace_probe_log_err(tmp - *symbol, BAD_TP_NAME);
1059+
kfree(*symbol);
1060+
*symbol = NULL;
1061+
return -EINVAL;
1062+
}
1063+
}
1064+
10521065
/* If there is $retval, this should be a return fprobe. */
10531066
for (i = 2; i < argc; i++) {
10541067
tmp = strstr(argv[i], "$retval");
10551068
if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
10561069
if (is_tracepoint) {
10571070
trace_probe_log_set_index(i);
10581071
trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
1072+
kfree(*symbol);
1073+
*symbol = NULL;
10591074
return -EINVAL;
10601075
}
10611076
*is_return = true;
@@ -1215,6 +1230,11 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
12151230
if (is_return && tf->tp.entry_arg) {
12161231
tf->fp.entry_handler = trace_fprobe_entry_handler;
12171232
tf->fp.entry_data_size = traceprobe_get_entry_data_size(&tf->tp);
1233+
if (ALIGN(tf->fp.entry_data_size, sizeof(long)) > MAX_FPROBE_DATA_SIZE) {
1234+
trace_probe_log_set_index(2);
1235+
trace_probe_log_err(0, TOO_MANY_EARGS);
1236+
return -E2BIG;
1237+
}
12181238
}
12191239

12201240
ret = traceprobe_set_print_fmt(&tf->tp,

kernel/trace/trace_probe.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#define MAX_BTF_ARGS_LEN 128
3737
#define MAX_DENTRY_ARGS_LEN 256
3838
#define MAX_STRING_SIZE PATH_MAX
39-
#define MAX_ARG_BUF_LEN (MAX_TRACE_ARGS * MAX_ARG_NAME_LEN)
4039

4140
/* Reserved field names */
4241
#define FIELD_STRING_IP "__probe_ip"
@@ -481,6 +480,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
481480
C(NON_UNIQ_SYMBOL, "The symbol is not unique"), \
482481
C(BAD_RETPROBE, "Retprobe address must be an function entry"), \
483482
C(NO_TRACEPOINT, "Tracepoint is not found"), \
483+
C(BAD_TP_NAME, "Invalid character in tracepoint name"),\
484484
C(BAD_ADDR_SUFFIX, "Invalid probed address suffix"), \
485485
C(NO_GROUP_NAME, "Group name is not specified"), \
486486
C(GROUP_TOO_LONG, "Group name is too long"), \
@@ -544,7 +544,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
544544
C(NO_BTF_FIELD, "This field is not found."), \
545545
C(BAD_BTF_TID, "Failed to get BTF type info."),\
546546
C(BAD_TYPE4STR, "This type does not fit for string."),\
547-
C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),
547+
C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),\
548+
C(TOO_MANY_EARGS, "Too many entry arguments specified"),
548549

549550
#undef C
550551
#define C(a, b) TP_ERR_##a

0 commit comments

Comments
 (0)