Skip to contentSkip to conversation

tracing/histogram: Do not copy the fixed-size char array field over the field size

PATCH Steven Rostedt 1 participant 1 message Nov 16, 2021 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 163673292822.195747.3696966210526410250.stgit@devnote2

A message that is not in the archive (sent off-list or not yet received): 20211116175359.GA2126@kbox

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

[ Resending to linux-kernel instead of ilinux-kernel ]

Quoted 34 lines · On Tue, 16 Nov 2021 13:34:31 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Tue, 16 Nov 2021 09:53:59 -0800 Beau Belgrave <[email protected]>…

Review static inline void __update_field_vars(struct tracing_map_elt *elt, · line 3029

Quoted 6 lines
(quoted diff) +1 -1
@@ -3025,7 +3026,7 @@ static inline void __update_field_vars(struct tracing_map_elt *elt,
 			char *str = elt_data->field_var_str[j++];
 			char *val_str = (char *)(uintptr_t)var_val;
 
-			strscpy(str, val_str, STR_VAR_LEN_MAX);
+			strscpy(str, val_str, val->size);    

Is it possible for val->size to be larger than STR_VAR_LEN_MAX? field_var_str is alloc'd to be the size of STR_VAR_LEN_MAX (256).

Yes.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=938aa33f14657c9ed9deea348b7d6f14b6d69cb7

;-)

-- Steve

Quoted 12 lines

Review static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, · line 4924

Quoted 10 lines
(quoted diff) +1 -1
 			var_val = (u64)(uintptr_t)str;
 		}
 		tracing_map_set_var(elt, var_idx, var_val);
@@ -4920,7 +4921,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
 
 				str = elt_data->field_var_str[idx];
 				val_str = (char *)(uintptr_t)hist_val;
-				strscpy(str, val_str, STR_VAR_LEN_MAX);
+				strscpy(str, val_str, hist_field->size);    

Same as above.