Skip to content

Commit 3fdacf4

Browse files
committed
Merge tag 'trace-v5.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fix from Steven Rostedt: "Fix the histogram logic from possibly crashing the kernel Working on the histogram code, I found that if you dereference a char pointer in a trace event that happens to point to user space, it can crash the kernel, as it does no checks of that pointer. I have code coming that will do this better, so just remove this ability to treat character pointers in trace events as stings in the histogram" * tag 'trace-v5.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Do not reference char * as a string in histograms
2 parents d980cc0 + 704adfb commit 3fdacf4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,9 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
16891689
if (WARN_ON_ONCE(!field))
16901690
goto out;
16911691

1692-
if (is_string_field(field)) {
1692+
/* Pointers to strings are just pointers and dangerous to dereference */
1693+
if (is_string_field(field) &&
1694+
(field->filter_type != FILTER_PTR_STRING)) {
16931695
flags |= HIST_FIELD_FL_STRING;
16941696

16951697
hist_field->size = MAX_FILTER_STR_VAL;
@@ -4495,8 +4497,6 @@ static inline void add_to_key(char *compound_key, void *key,
44954497
field = key_field->field;
44964498
if (field->filter_type == FILTER_DYN_STRING)
44974499
size = *(u32 *)(rec + field->offset) >> 16;
4498-
else if (field->filter_type == FILTER_PTR_STRING)
4499-
size = strlen(key);
45004500
else if (field->filter_type == FILTER_STATIC_STRING)
45014501
size = field->size;
45024502

0 commit comments

Comments
 (0)