mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
tracing: Add BUILD_BUG() to make sure stacktrace fits in strings
The max string length for a histogram variable is 256 bytes. The max depth of a stacktrace is 16. With 8byte words, that's 16 * 8 = 128. Which can easily fit in the string variable. The histogram stacktrace is being stored in the string value (with the given max length), with the assumption it will fit. To make sure that this is always the case (in the case that the stack trace depth increases), add a BUILD_BUG_ON() to test this. Link: https://lore.kernel.org/linux-trace-kernel/20230214002418.0103b9e765d3e5c374d2aa7d@kernel.org/ Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
fc1a9dc101
commit
8261ef2eb3
1 changed files with 3 additions and 0 deletions
|
@ -3119,6 +3119,9 @@ static inline void __update_field_vars(struct tracing_map_elt *elt,
|
|||
unsigned int i, j, var_idx;
|
||||
u64 var_val;
|
||||
|
||||
/* Make sure stacktrace can fit in the string variable length */
|
||||
BUILD_BUG_ON((HIST_STACKTRACE_DEPTH + 1) * sizeof(long) >= STR_VAR_LEN_MAX);
|
||||
|
||||
for (i = 0, j = field_var_str_start; i < n_field_vars; i++) {
|
||||
struct field_var *field_var = field_vars[i];
|
||||
struct hist_field *var = field_var->var;
|
||||
|
|
Loading…
Reference in a new issue