Skip to content

Commit f667587

Browse files
rupranrostedt
authored andcommitted
tracing: probeevent: Correctly update remaining space in dynamic area
Commit 9178412 ("tracing: probeevent: Return consumed bytes of dynamic area") improved the string fetching mechanism by returning the number of required bytes after copying the argument to the dynamic area. However, this return value is now only used to increment the pointer inside the dynamic area but misses updating the 'maxlen' variable which indicates the remaining space in the dynamic area. This means that fetch_store_string() always reads the *total* size of the dynamic area from the data_loc pointer instead of the *remaining* size (and passes it along to strncpy_from_{user,unsafe}) even if we're already about to copy data into the middle of the dynamic area. Link: http://lkml.kernel.org/r/[email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Fixes: 9178412 ("tracing: probeevent: Return consumed bytes of dynamic area") Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Andreas Ziegler <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 0722069 commit f667587

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/trace/trace_probe_tmpl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,12 @@ store_trace_args(void *data, struct trace_probe *tp, struct pt_regs *regs,
180180
if (unlikely(arg->dynamic))
181181
*dl = make_data_loc(maxlen, dyndata - base);
182182
ret = process_fetch_insn(arg->code, regs, dl, base);
183-
if (unlikely(ret < 0 && arg->dynamic))
183+
if (unlikely(ret < 0 && arg->dynamic)) {
184184
*dl = make_data_loc(0, dyndata - base);
185-
else
185+
} else {
186186
dyndata += ret;
187+
maxlen -= ret;
188+
}
187189
}
188190
}
189191

0 commit comments

Comments
 (0)